How to enable panning via CTRL + mouse dragging?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
aremington1612
Posts: 3
Joined: Thu Sep 17, 2015 2:54 am
antibot: No, of course not.

How to enable panning via CTRL + mouse dragging?

Post by aremington1612 » Thu Sep 17, 2015 3:22 am

Hi guys,

I've come here because I'm developing a very simple stock watching application. I was able to create a candlestick chart via the ChartFactory class and passing in a data set. It works very nicely. However,

What I want to do is enable the CTRL + mouse dragging panning that I see in Dave Gilbert's post here:

http://www.jroller.com/dgilbert/entry/m ... ive_charts

I was able to enable the mouse zooming feature via the setMouseZoomable method.. but I'm not sure how to enable this other functionality to make my chart truly interactive.

Can someone please show me how to do this? Maybe there is a method that I haven't found yet?

Also, I apologize if maybe this has been answered before or maybe the answer is simple. I couldn't find anything relevant via the search engine or Google. Google mostly returns results from older versions of JFreeChart, and this functionality seems to be a somewhat newer one. I'm using version 1.0.19.

aremington1612
Posts: 3
Joined: Thu Sep 17, 2015 2:54 am
antibot: No, of course not.

Re: How to enable panning via CTRL + mouse dragging?

Post by aremington1612 » Thu Sep 17, 2015 8:03 am

Nevermind guys - after returning to my project and doing some more digging around, I found out the ff:

All one needs to do is use the getXYPlot() method of the newly created chart to get the XYPlot object. Then one uses two setters on this Plot object to set both values to true: a.)setDomainPannable, and b.) setRangePannable.

Problem solved. :lol:

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: How to enable panning via CTRL + mouse dragging?

Post by John Matthews » Fri Sep 18, 2015 5:17 am

For reference, note that the pan gesture on Mac OS X requires dragging while holding down the option (alt) key, while control-click opens a popup context menu. A related example is examined here.

Locked