滚动条向右移动,而不是向左移动 [英] Scrollbar moving to right instead of left
问题描述
我制作了一个在收到数据时动态绘制尖峰的图表。
在这个图表中,我创建了一个滚动条,所以只有20个数据点按时显示。
I have made a chart which dynamically draw a spike when data received. In this chart I have made a scrollbar, so only 20 datapoints get shown at on time.
public void Chart()
{
ChartArea mov = SleepMovChar.ChartAreas["Movement"];
mov.AxisX.ScrollBar.Size = 12;
mov.AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
mov.AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All ^ ScrollBarButtonStyles.ResetZoom;
mov.AxisX.ScrollBar.IsPositionedInside = true;
mov.AxisX.ScrollBar.Enabled = true;
mov.AxisX.ScaleView.Size = 20;
}
我的问题是,我想让数据收到时滚动条向右移动。现在,它向左移动,因此显示第一个数据。我只是希望显示最新的数据,以便滚动条跟随数据接收。
My problem is, that I want that scrollbar to move to right when data received. At the time now, it moves to left, so the first data is shown. I just want that the latest data is shown instead, so that the scrollbar follows the data receive.
推荐答案
如果希望可见区域跟踪示波器中的新数据,可以设置滚动位置:
If you want the visible area to follow the new data like in an oscilloscope, you can set the scroll position :
Series S1 = SleepMovChar.Series["yourSeriesByNameOrNumber"];
mov.AxisX.ScaleView.Position = S1.Points.Count - mov.AxisX.ScaleView.Size;
您需要在添加数据点后重复此操作。
You will need to repeat this whenever you have added data points..
这篇关于滚动条向右移动,而不是向左移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!