10

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?

itsmatt
  • 31,265
  • 10
  • 100
  • 164

2 Answers2

11

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.

itsmatt
  • 31,265
  • 10
  • 100
  • 164
  • I've been trying to figure this out for quite awhile: can't zoom with a resolution lower than 1. Glad I finally found your answer. I totally agree this was not obvious from the demo! – Chris Zeh Nov 16 '12 at 19:29
  • this is awesome. I'll never have to hear my boss complain about this again. – RussellStewart Oct 14 '13 at 21:59
7

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

Mehdi LAMRANI
  • 11,289
  • 14
  • 88
  • 130