RWWithChartPie.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Sunny.UI;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. namespace WWPipeLine.MapBasic.Results
  8. {
  9. public class RWWithChartPie : RWWithChart
  10. {
  11. protected override void AddOptionSeries(DataTable dt)
  12. {
  13. foreach (DataRow dr in dt.Rows)
  14. {
  15. var series = new UIPieSeries
  16. {
  17. Name = dr[0].ToString()
  18. };
  19. for (int i = 1; i < dr.ItemArray.Length; i++)
  20. {
  21. double.TryParse(dr[i].ToString(), out double val);
  22. series.AddData(dt.Columns[i].Caption, val);
  23. }
  24. ((UIPieOption)m_UIOption).AddSeries(series);
  25. }
  26. }
  27. protected override void SetLegendItem(DataTable dt)
  28. {
  29. foreach (DataColumn dc in dt.Columns)
  30. {
  31. if (dt.Columns.IndexOf(dc) == 0) continue;
  32. ((UIPieOption)m_UIOption).Legend.AddData(dc.Caption);
  33. }
  34. }
  35. protected override void CreateChart()
  36. {
  37. this.m_UIChart = new UIPieChart();
  38. this.m_UIOption = new UIPieOption();
  39. }
  40. }
  41. }