本文讲述了c# winform chart绑定list数据!具有很好的参考价值,希望对大家有所帮助。一起跟随六星小编过来看看吧,具体如下:
在介绍实现方法前需要先了解chart控件的几个属性
实现思路
代码实现
double[] data = {...};//需要显示的数据 长度为200万。 public List<double[]> DataPanel = new List<double[]>(); for(int m =0;m<40;m++) { double [] smallArray = new double [50000]; for(int n = 0;n<50000;n++) { smallArray [n] = data [i*50000+n]; } DataPanel .add(smallArray); }
private void ChartScrollbarStyle() { chartAmend.ChartAreas[0].AxisX.ScrollBar.Enabled = true; chartAmend.ChartAreas[0].AxisX.ScaleView.Position = 1; chartAmend.ChartAreas[0].AxisX.ScaleView.Size = 300; chartAmend.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll; chartAmend.ChartAreas[0].AxisX.ScrollBar.ButtonColor = Color.Silver; chartAmend.ChartAreas[0].AxisX.ScrollBar.LineColor = Color.Black; chartAmend.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = false; }
int DataCount = 0; chart1.Series[0].Points.DataBindY(DataPanel[DataCount]);
private void Chart1_MouseWheel(object sender, MouseEventArgs e) { int position = Convert.ToInt32(chart1.ChartAreas[0].AxisX.ScaleView.Position); int WindowSize = chart1.ChartAreas[0].AxisX.ScaleView.Size; if (e.Delta < 0) { position += 200;//滚轮动一下,移动多少数据 if (position >= chartAmend.ChartAreas[0].AxisX.Maximum - WindowSize)//一段数据显示完毕 { DataCount++; if (DataCount >= DataPanel.Count) { MessageBox.Show("所有数据已经全部显示完毕","提示"); DataCount = DataPanel.Count-1; return; } chart1.Series[0].Points.DataBindY(Overall.DataPanel[DataCount]); position = 1;//新的一段数据开始时 滚动条移动到最左侧 } } else { position -= 200; if (position < 1) { if (DataCount == 0) { position = 1; MessageBox.Show("已经是第一个数据", "提示"); } else { DataCount--; } chart1.Series[0].Points.DataBindY(Overall.DataPanel[DataCount]); position = Convert.ToInt32(chart1.ChartAreas[0].AxisX.Maximum - WindowSize); } } chart1.ChartAreas[0].AxisX.ScaleView.Position = position; }
更多相关技术内容咨询欢迎前往并持续关注六星社区了解详情。
长按或扫描下方二维码,免费获取 Python公开课和大佬打包整理的几百G的学习资料,内容包含但不限于Python电子书、教程、项目接单、源码等等
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!