12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using Sunny.UI;
- using System.Data;
- namespace WWPipeLine.MapBasic.Results
- {
- public class RWWithChartBar : RWWithChart
- {
- protected override void AddOptionSeries(DataTable dt)
- {
- foreach (DataRow dr in dt.Rows)
- {
- var color = m_Colors[dt.Rows.IndexOf(dr)];
- UIBarSeries series = new UIBarSeries();
- for (int i = 1; i < dr.ItemArray.Length; i++)
- {
- double.TryParse(dr[i].ToString(), out double val);
- series.AddData(val, color);
- }
- ((UIBarOption)m_UIOption).AddSeries(series);
- }
- }
- protected override void AddXAxis(DataTable dt)
- {
- UIBarOption option = m_UIOption as UIBarOption;
- option.XAxis.Scale = true;
- option.XAxis.MaxAuto = true;
- option.XAxis.MinAuto = true;
- var colIndex = 0;
- foreach (DataColumn colum in dt.Columns)
- {
- if (colIndex++ == 0) continue;
- option.XAxis.Data.Add(colum.ColumnName);
- }
- if (option.XAxis.Data.Count > 5)
- {
- option.XAxis.AxisLabel.Angle = 45;
- }
- else
- {
- option.XAxis.AxisLabel.Angle = 0;
- }
- }
- protected override void SetLegendItem(DataTable dt)
- {
- foreach (DataRow dr in dt.Rows)
- {
- ((UIBarOption)m_UIOption).Legend.AddData(dr[0].ToString(), m_Colors[dt.Rows.IndexOf(dr)]);
- }
- }
- protected override void CreateChart()
- {
- m_UIChart = new UIBarChart();
- m_UIOption = new UIBarOption();
- }
- protected override void SetOptionEx()
- {
- ((UIBarOption)m_UIOption).XAxis.Name = SetXAxisName();
- ((UIBarOption)m_UIOption).YAxis.Name = SetYAxisName();
- ((UIBarOption)m_UIOption).Grid.Left = 80;
- }
- }
- }
|