RWWithChartBar.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Sunny.UI;
  2. using System.Data;
  3. namespace WWPipeLine.MapBasic.Results
  4. {
  5. public class RWWithChartBar : RWWithChart
  6. {
  7. protected override void AddOptionSeries(DataTable dt)
  8. {
  9. foreach (DataRow dr in dt.Rows)
  10. {
  11. var color = m_Colors[dt.Rows.IndexOf(dr)];
  12. UIBarSeries series = new UIBarSeries();
  13. for (int i = 1; i < dr.ItemArray.Length; i++)
  14. {
  15. double.TryParse(dr[i].ToString(), out double val);
  16. series.AddData(val, color);
  17. }
  18. ((UIBarOption)m_UIOption).AddSeries(series);
  19. }
  20. }
  21. protected override void AddXAxis(DataTable dt)
  22. {
  23. UIBarOption option = m_UIOption as UIBarOption;
  24. option.XAxis.Scale = true;
  25. option.XAxis.MaxAuto = true;
  26. option.XAxis.MinAuto = true;
  27. var colIndex = 0;
  28. foreach (DataColumn colum in dt.Columns)
  29. {
  30. if (colIndex++ == 0) continue;
  31. option.XAxis.Data.Add(colum.ColumnName);
  32. }
  33. if (option.XAxis.Data.Count > 5)
  34. {
  35. option.XAxis.AxisLabel.Angle = 45;
  36. }
  37. else
  38. {
  39. option.XAxis.AxisLabel.Angle = 0;
  40. }
  41. }
  42. protected override void SetLegendItem(DataTable dt)
  43. {
  44. foreach (DataRow dr in dt.Rows)
  45. {
  46. ((UIBarOption)m_UIOption).Legend.AddData(dr[0].ToString(), m_Colors[dt.Rows.IndexOf(dr)]);
  47. }
  48. }
  49. protected override void CreateChart()
  50. {
  51. m_UIChart = new UIBarChart();
  52. m_UIOption = new UIBarOption();
  53. }
  54. protected override void SetOptionEx()
  55. {
  56. ((UIBarOption)m_UIOption).XAxis.Name = SetXAxisName();
  57. ((UIBarOption)m_UIOption).YAxis.Name = SetYAxisName();
  58. ((UIBarOption)m_UIOption).Grid.Left = 80;
  59. }
  60. }
  61. }