panning charts while zoomed in

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

panning charts while zoomed in

Post by RichardWest » Sat Feb 10, 2007 8:30 am

I have searched the forum and found many people asking about panning charts while zoomed. There are couple suggested answers, and even a couple proposed solutions. My question isn't exactly "How can I pan a chart while zoomed" more if JFreeChart has added support to make this possible/easier.

In my normal style, here are links to other threads discussing this exact topic:

Asking:
http://www.jfree.org/phpBB2/viewtopic.p ... ht=panning
http://www.jfree.org/phpBB2/viewtopic.p ... ht=panning
http://www.jfree.org/phpBB2/viewtopic.p ... ht=panning
http://www.jfree.org/phpBB2/viewtopic.p ... ht=panning

Asking and mention a solution from an old version of JFreeChart:
http://www.jfree.org/phpBB2/viewtopic.p ... ht=panning
http://www.jfree.org/phpBB2/viewtopic.p ... ht=panning

Asking and mention that there would be a possible solution added to JFreeChart:
http://www.jfree.org/phpBB2/viewtopic.p ... ht=panning

Asking and present a temporary solution:
http://www.jfree.org/phpBB2/viewtopic.php?t=644
http://www.jfree.org/phpBB2/viewtopic.php?t=6342
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Feb 12, 2007 6:11 pm

Henry Proudhon (who has been working on the experimental SWT support) is currently looking at adding panning support (I think both in the ChartPanel class for Swing, and the ChartComposite class for SWT). I'll let him know about this thread, and I'll try to take a look myself also (I'm short on time as always).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

heprom
Posts: 91
Joined: Sat May 27, 2006 4:25 am
Location: Paris

Post by heprom » Tue Feb 13, 2007 1:12 pm

Thanks for the review, it will help me to get started on this and hopefully provide a clever solution to add panning in JFreeChart.

aiello
Posts: 6
Joined: Mon Sep 24, 2007 7:29 pm

Post by aiello » Fri Oct 05, 2007 3:51 pm

Any word on the state of this enhancement? My application would certainly benefit from panning.... I'll look into hacking a solution together if this is still pretty far off, but if we can expect experimental support in the not-too-distant future, I'll hold off and wait for it.

Thanks!

annac
Posts: 24
Joined: Mon Oct 01, 2007 7:56 pm
Location: Canada

Post by annac » Fri Oct 05, 2007 4:50 pm

I've also been looking for a solution.

I didn't want to get rid of the built-in zooming feature so I ended up subclassing the ChartPanel class and overriding the mousePressed and mouseDragged methods to check if the shift key was a modifier to the event. this way, if you hold down the shift key while moving the mouse you can pan (by changing the upper and lower bounds of the domain axis), and otherwise the methods pass the event to their super method and the mouse will initiate zooming. it seems to work quite well so far. I haven't tried to implement this with subplots yet.

annac
Posts: 24
Joined: Mon Oct 01, 2007 7:56 pm
Location: Canada

Post by annac » Fri Oct 05, 2007 4:52 pm

oh. and the mouseReleased method as well

annac
Posts: 24
Joined: Mon Oct 01, 2007 7:56 pm
Location: Canada

Post by annac » Fri Oct 05, 2007 6:14 pm

got panning to work with subplots :D

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Post by RichardWest » Fri Oct 05, 2007 6:52 pm

annac wrote:got panning to work with subplots :D
Submit the code as a patch. You will receive a contributor credit and help others as well. The code will also help Henry and David work towards a generic solution.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

gribas
Posts: 32
Joined: Thu Jan 26, 2006 5:34 pm

Post by gribas » Wed Oct 31, 2007 8:48 pm

Hello,

I didn't quite get the "while zoomed" part. A pan is a pan, the zoom level should not come into play. If you'd like you can establish some min/max limits to the axis (I do that).
Anyway, I think this class will do what you're asking for:

http://www.jfree.org/phpBB2/viewtopic.php?p=59287#59287

HTH,
Gustavo

Locked