Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Chart Control Zoom MinSize issue

I'm implementing a scatter plot using the MS Chart Control .NET 3.5, WinForms, C#. My x-axis data is DateTime and noticed I couldn't zoom in smaller than a resolution of 1 day, despite setting the ScaleView as follows:

chart1.ChartAreas["MyChart"].AxisX.ScaleView.MinSize = 4;
chart1.ChartAreas["MyChart"].AxisX.ScaleView.MinSizeType = DateTimeIntervalType.Hours;

Has anyone else had this issue? Any ideas?

like image 276
itsmatt Avatar asked Oct 26 '09 19:10

itsmatt


2 Answers

Figured this out... perhaps I didn't RTFM close enough, but it wasn't obvious from the interactive demo.

Set

chart1.ChartAreas["MyChart"].CursorX.Interval = 0;

and then it allowed me to zoom along the x-axis just fine.

like image 133
itsmatt Avatar answered Oct 22 '22 21:10

itsmatt


Works Great ! Very handy and mandatory if you want to have smooth Zooming behavior.
Didn't stumble upon it, though I did RTFM :-)

However, if you handle doubles or floats instead of integer based types (such as hours or days), setting the interval to Zero may be a little bit extreme : While zooming, you will end up having overly precise labels such as 2,907343253253235

A good combination is to use these two properties :

chartArea1.AxisY.ScaleView.MinSize = 0;
chartArea1.CursorY.Interval = 0.001;

this way you can zoom as much as you want, while still controlling precision at a reasonable level

like image 7
Mehdi LAMRANI Avatar answered Oct 22 '22 21:10

Mehdi LAMRANI