A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
Michelle
Post
by Michelle » Tue Jan 27, 2004 6:51 pm
Hello,
I am currently using an XYSeries line chart and I want to be able
to draw a rectangle over any part of the graph and have the view
zoom it to fit the selection section to screen (zoom to fit). Has anyone
done this before? Is there a way to draw the rectangle in JFreeChart?
I see that the the ChartPanel class has a zoom(rectangle2d) method
so it appears that all I have to do is create the rectangle selection.
Thanks!!
Michelle

-
Stacey
- Posts: 15
- Joined: Tue Jan 27, 2004 5:09 pm
Post
by Stacey » Tue Jan 27, 2004 6:56 pm
Actually I believe the functionallity is more simple to reference than passing it your own rectangle. You simple need to "turn on" the zoom functionality and the features (seem to me anyway) are already implemented nicely.
ChartPanel freeChartPanel = new ChartPanel(myFreeChart);
freeChartPanel.setHorizontalZoom(true);
freeChartPanel.setVerticalZoom(true);
Hope this works.
-
sunkid
- Posts: 3
- Joined: Tue Jan 27, 2004 10:54 pm
Post
by sunkid » Tue Jan 27, 2004 11:09 pm
Hi,
I just started using jfreechart and really like it!! Thanks for a great package.
That said, here is my first bug report: when only verticalZoom is enabled, it seems that the chart is only zoomed, if the mouse is dragged horizontally in addition to vertically. Maybe the if statement on line 1051 (0.9.16 release) of ChartPanel would need to check the drag size in X direction if horizontalZoom is true and in y direction if verticalZoom is true:
Code: Select all
if ((horizontalZoom && Math.abs(e.getX() - zoomPoint.getX()) >= MINIMUM_DRAG_ZOOM_SIZE) ||
(verticalZoom && Math.abs(e.getY() - zoomPoint.getY()) >= MINIMUM_DRAG_ZOOM_SIZE)) {
cheers,
h.
-
beems135
Post
by beems135 » Fri Jan 30, 2004 9:32 am
Michelle,
Did you check out the MouseZoomDemo (in: jfreechart-0.9.16\src\org\jfree\chart\demo)?
-
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 02, 2004 4:42 pm
sunkid wrote:That said, here is my first bug report: when only verticalZoom is enabled, it seems that the chart is only zoomed, if the mouse is dragged horizontally in addition to vertically. Maybe the if statement on line 1051 (0.9.16 release) of ChartPanel would need to check the drag size in X direction if horizontalZoom is true and in y direction if verticalZoom is true:
Code: Select all
if ((horizontalZoom && Math.abs(e.getX() - zoomPoint.getX()) >= MINIMUM_DRAG_ZOOM_SIZE) ||
(verticalZoom && Math.abs(e.getY() - zoomPoint.getY()) >= MINIMUM_DRAG_ZOOM_SIZE)) {
Thanks! For the 0.9.17 release, I've modified the code as you suggested, and also made the MINIMUM_DRAG_ZOOM_SIZE an attribute so you can change the default value if necessary.