Using the mouse scrollwheel to zoom in/out ?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
snid3ly
Posts: 23
Joined: Wed Aug 07, 2013 4:21 am
antibot: No, of course not.

Using the mouse scrollwheel to zoom in/out ?

Post by snid3ly » Sun Mar 29, 2015 10:35 pm

I would like my mouse scrollwheel to do the same zoom as clicking zoom->both-axes. Is there an example of that or can someone suggest the best way to do it?

Thanks

Naxter
Posts: 45
Joined: Thu Jun 26, 2014 8:24 am
antibot: No, of course not.
Location: Germany, Aachen

Re: Using the mouse scrollwheel to zoom in/out ?

Post by Naxter » Mon Mar 30, 2015 10:22 am

If you extend the ChartPanel, you can actually set it via "super"

Code: Select all

public CustomChartPanel(JFreeChart chart)
{
    //the fifth boolean is actually for "zoom" and the scrollwheel is default
    super(chart, false, true, false, true, true);
}
I actually never tried to use "setDomainZoomable(boolean flag)" or "setRangeZoomable(boolean flag)", but i guess that´ll work too.

snid3ly
Posts: 23
Joined: Wed Aug 07, 2013 4:21 am
antibot: No, of course not.

Re: Using the mouse scrollwheel to zoom in/out ?

Post by snid3ly » Thu Apr 02, 2015 4:31 am

turns out I just needed chartPanel.setMouseWheelEnabled(true);

Locked