开发者

Allowing zooming when point range is less than [-1,1] in DataVisualization.Charting?

开发者 https://www.devze.com 2023-04-02 17:21 出处:网络
I have a DataVisualization.Charting.Chart and in order to enable user controlled zooming I have set chartArea1.CursorX.IsUserEnabled = true;

I have a DataVisualization.Charting.Chart and in order to enable user controlled zooming I have set

        chartArea1.CursorX.IsUserEnabled = true;
        chartArea1.CursorX.IsUserSelectionEnabled = true;
        chartArea1.CursorY.IsUserEnabled开发者_StackOverflow社区 = true;
        chartArea1.CursorY.IsUserSelectionEnabled = true;

However, if I make a series that has an axis along which the range of the data is within [-1,1] the chart will not allow zooming on that axis. Is there a way to enable zooming?

Also the zooming selector seems quite chunky (it snaps to major intervals or something) is it possible to get smoother selection?


Covering both WPF and WinForms as you did not specify in your question.

WPF

It sounds like that the chart is virtualizing the contents (i.e. only drawing what is in view). You probably verify if this is the case by setting ScrollViewer.CanContentScroll to False. You will want to keep the virtualizng on as otherwise performance will suffer with a large data set.

WinForms

Have you set the Chart.DoubleBuffered property? Setting this property to true will make the chart control redraw its surface using a secondary buffer to reduce or prevent flicker.

  • Chart Class (MSDN)
  • Control.DoubleBuffered Property (MSDN)


The problem turned out to be caused by the zooming cursor only being able to take position coordinates on a discrete grid. These are controled by Cursor.Interval and Cursor.Offset. You can change this by setting

Chart.ChartAreas[0].CursorX.Interval = 0;
Chart.ChartAreas[0].CursorY.Interval = 0;

This makes the grid continuous so the zooming cursor can take any coordinates.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号