0

我正在尝试用图表可视化数据。我已经做了几个小时,需要做几天和几周来比较。这是我如何每小时可视化的示例代码,在周一,周二到周日的时间间隔内做同样的事情时遇到问题。我怎样才能做到这一点?

chart1.ChartAreas.Add("area");
chart1.ChartAreas["area"].AxisX.Minimum = 0;
chart1.ChartAreas["area"].AxisX.Maximum = 24;
chart1.ChartAreas["area"].AxisX.Interval = 1;
chart1.ChartAreas["area"].AxisY.Minimum = 0;
chart1.ChartAreas["area"].AxisY.Maximum = intYAxisMax;
chart1.ChartAreas["area"].AxisY.Interval= 10;

chart1.Series.Add("Electric");
chart1.Series.Add("Gas");

chart1.Series["Electric"].Color = Color.Red;
chart1.Series["Gas"].Color = Color.Green;

chart1.ChartAreas["area"].AxisX.Title = "Hours";
chart1.ChartAreas["area"].AxisY.Title = "KW/H";

Title objTest = new Title("Daily Data Usage");
chart1.Titles.Add(objTest);

Legend objLegend = new Legend("Testing");
chart1.Legends.Add(objLegend);

//chart1.Series["Electric"].Points.AddXY(20 , 203);
//chart1.Series["Gas"].Points.AddXY(11, 70);
4

1 回答 1

1

尝试这个:

chart1.Series["Electric"].IsXValueIndexed = true;

//Add data
chart1.Series["Electric"].Points.AddXY(1, 203);
chart1.Series["Electric"].Points.AddXY(2, 70);

//X-axis labels
chart1.Series["Electric"].Points[0].AxisLabel = "Sunday";
chart1.Series["Electric"].Points[1].AxisLabel = "Monday";

ETC...

于 2012-05-17T14:15:36.527 回答