Scrollbar moving to right instead of left

可紊 提交于 2019-12-11 19:56:33

问题


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.


回答1:


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..



来源:https://stackoverflow.com/questions/27250118/scrollbar-moving-to-right-instead-of-left

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!