[英]How to set scroll bar scale view position of chart to recently added value using c#
在我的應用程序中,我使用圖表控件並每隔一秒不斷更新實時值。我為圖表啟用了滾動條,並且滾動條工作正常。但是我想將滾動條的位置設置為最近添加的值(右側)總是。 請指導我,
Chart chart = new Chart();
Series series1 = new Series("testing");
chart1.ChartAreas[0].CursorX.AutoScroll = true;
chart1.ChartAreas[0].CursorY.AutoScroll = true;
chart1.ChartAreas[0].AxisX.ScrollBar.Size = 15;
chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = false;
chart1.ChartAreas[0].AxisX.ScrollBar.Enabled = true;
chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisX.ScaleView.Zoom(2, 5);
chart1.ChartAreas[0].RecalculateAxesScale();
chart1.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Microsoft Sans Serif", 10, FontStyle.Bold);
chart1.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("Microsoft Sans Serif", 10, FontStyle.Bold);
chart1.ChartAreas[0].AxisY2.TitleFont = new System.Drawing.Font("Microsoft Sans Serif", 10, FontStyle.Bold);
最后,我找到了將滾動條的位置保持在最近增加的值的解決方案。
chart1.ChartAreas[0].AxisX.ScaleView.Position = chart1.ChartAreas[0].AxisX.Maximum;
AxisX.Maximum是圖表中最近添加的值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.