I am using Microsoft Chart control in my project and I want to enable zooming feature in Chart Control by using Mouse Wheel, how can I achieve this?
but user don't have to click on chart, It should be like if mouse position is on my Chart than from that point onward by mouse wheel rolling it can zoom in / out
I modificated code from above and added a reverse zooming. So when you rotate a mouse wheel back the chart zoom out. Also i don't recommend use 2^n as divider of the interval because it cause lag.
You'll want to use the
MouseWheel
event.First make both axes of your chart zoomable:
And assign the event:
Then in the event handler:
The
e.Delta
property tells you how many wheel "scrolls" you've done, and can be useful.Scrolling out at all will zoom out the whole way.
There's probably a cleaner way of doing this, but there it is. Hope this helps!
Waaaay late to the party, but I had this challenge myself today. I am sure the following can be improved, still, but it's what I came up with. I tested this with .net 4.5.2 and 4.6, so I am not sure if it works with older frameworks.
I've combined a couple of answers from way in the past and made the following: