Secondary axis incorrect after zoom out

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
daress
Posts: 22
Joined: Tue Mar 13, 2007 4:52 pm
Contact:

Secondary axis incorrect after zoom out

Post by daress » Thu Jan 15, 2015 8:42 pm

First of all, I have really enjoyed JFreeChart for the past seven years in conjunction with WebObjects development. It worked seamlessly.

However, I recently started a standalone application using JFreeChart. I have 1 dataset in an XYPlot with the primary domain axis on the bottom, the primary range on the left, the secondary domain on the top and the secondary range on the right.

When I run the application, it plots the data and axes correctly. If I click and draw a rectangle to zoom in on the plot, the data and axes are still correct. My problem is with zooming out to the original data/image. The image is correct but both secondary axes have lost their range information and reverted to a 0 to 1 range.

I am creating the secondary axes as follows:

Code: Select all

NumberAxis degreeAxis = new NumberAxis("Degree Around Hole");
degreeAxis.setLowerBound( 0.0 );
degreeAxis.setUpperBound( 360.0 );
plot.setDomainAxis(1, degreeAxis);
plot.setDomainAxisLocation( 1, AxisLocation.TOP_OR_LEFT);

NumberAxis depthAxis = new NumberAxis("Depth (in)");
depthAxis.setLowerBound( mDepthMin );
depthAxis.setUpperBount( mDepthMax );
plot.setRangeAxis(1, depthAxis);
plot.setRangeAxisLocation( 1, AxisLocation.BOTTOM_OR_RIGHT);
I attempted to use the

Code: Select all

plot.mapDatasetToDomainAxis(0, 1);
and

Code: Select all

plot.mapDatasetToRangeAxis(0, 1);
methods, but that messes up the initial drawing - it seems a dataset does not like being mapped to multiple range and domain axes.

The code follows the examples within the JFreeChart demo for DualAxisDemos with two exceptions - I have a single dataset and I am not mapping the dataset to the axes (bad results as mentioned above). Thus, my concern is that having a single dataset is my issue, but I wanted to check the forum to see if anyone has any suggestions.

Thanks in advance,
David

Post Reply