4,816
社区成员
发帖
与我相关
我的任务
分享
private void ShowPoints()
{
//绑定 MSCHART
Series series = new Series("series1");
series.Color = Color.Yellow; // 系列的颜色;
series.ChartType = SeriesChartType.Column; //曲线;
series.IsVisibleInLegend = false; //不需要自动生成图例
chart1.Series.Add(series);
//make the chart can scroll and zoom
chart1.ChartAreas[0].CursorX.IsUserEnabled = true;
chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
chart1.ChartAreas[0].CursorX.Interval = 1;
chart1.ChartAreas[0].CursorX.IntervalType = DateTimeIntervalType.Minutes;//变了,而且改成hours也一样
chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisX.ScrollBar.Enabled = true;
chart1.ChartAreas[0].AxisX.IsLabelAutoFit = true;
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm";
// Populate series data
double[] yValues = { 2.8684, 2.8994, 2.9252, 2.9557, 2.9714, 2.9136, 3.0097, 2.8994, 2.9854, 2.8993, 2.9646, 2.9140 };
DateTime currentDate = DateTime.Now;
Random random = new Random();
chart1.Series["series1"].Points.Clear();
for (int pointIndex = 0; pointIndex < yValues.Length; pointIndex++)
{
chart1.Series["series1"].Points.AddXY(currentDate, yValues[pointIndex]);
currentDate = currentDate.AddMinutes(random.Next(600, 601));//变了,而且改成hours也一样
}
}