其他分享
首页 > 其他分享> > winform 绘图控件 chart 实时曲线图

winform 绘图控件 chart 实时曲线图

作者:互联网

 

官方教程:http:////files.cnblogs.com/files/HelloQLQ/Winform图表.rar 更多参考:https://blog.csdn.net/boxuming/article/details/89678159 实现思路:线程 while (true)循环,当集合满了10个元素之后,每次再进行绘制 需要移除第一个点,添加新点到集合末尾。 这个chart控件十分的强大 网上资料也很多。我也只了解皮毛,刚好够解决我的问题。所以没啥写的。 chart初始化:
 th = new Thread(GetData);
            chart1.Series[0].Name = strLinePh;
            chart1.Series[0].Color = Color.Red;
            chart1.Series.Add(strLinePress);
            chart1.Series[1].Color = Color.Blue;
           
            chart1.ChartAreas[0].AxisY2.ArrowStyle = AxisArrowStyle.Triangle;
            //chart1.ChartAreas[0].Axes[3].Interval = 50;
            chart1.Series[strLinePress].YAxisType = AxisType.Secondary;
            chart1.Titles.Add("PH 压力 实时曲线");
            chart1.Legends[0].LegendStyle = LegendStyle.Row;
            chart1.Legends[0].Docking = Docking.Top;
            chart1.ChartAreas[0].AxisX2.LineColor = Color.Transparent;

            var cArea = chart1.ChartAreas[0];
            cArea.AxisY.LineColor = Color.Red;
            cArea.AxisY2.LineColor = Color.Blue;
            cArea.AxisY.Minimum = 0;
            cArea.AxisY.Maximum = 7;
            cArea.AxisY2.Minimum = -50;
            cArea.AxisY2.Maximum = 50;

            cArea.AxisX2.LineColor = Color.DarkGreen;
            cArea.AxisY2.MajorGrid.LineColor = Color.Transparent;
            cArea.AxisX.MajorGrid.LineColor = Color.Transparent;
            cArea.AxisX.ArrowStyle = AxisArrowStyle.Triangle;
            cArea.AxisY.ArrowStyle = AxisArrowStyle.Triangle;


            // Set series chart type
            chart1.Series[strLinePh].ChartType = SeriesChartType.Line;
            chart1.Series[strLinePress].ChartType = SeriesChartType.Line;

            // Set point labels
            chart1.Series[strLinePh].IsValueShownAsLabel = true;
            chart1.Series[strLinePress].IsValueShownAsLabel = true;

            // Enable X axis margin
            chart1.ChartAreas[0].AxisX.IsMarginVisible = true;

            chart1.Visible = false;

 

标签:控件,Color,Series,chart,chart1,cArea,LineColor,ChartAreas,winform
来源: https://www.cnblogs.com/HelloQLQ/p/15359049.html