Can't get my secondaryAxis drawn

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Diego Garber

Can't get my secondaryAxis drawn

Post by Diego Garber » Wed Feb 12, 2003 6:22 pm

Hi, I am usinf the secondary axis feature for the first time and I pasted and adapted the code from the samples. My code is this:

NumberAxis axis2 = new VerticalNumberAxis("Secondary");
axis2.setAutoRangeIncludesZero(false);
//subPlotPpal is an overlaid plot
subPlotPpal.setSecondaryRangeAxis(axis2);
tsm2do = new TimeSeriesCollectionExt(myTimeSeries);
subPlotPpal.setSecondaryDataset(tsm2do);


subPlotPpal is an overlaid plot which is embedded in a CombinedPlot.
The axis appears but no series gets drawn after this (myTimeSeries has data!). Can anybody help me?

Diego.

Diego Garber

Re: Can't get my secondaryAxis drawn

Post by Diego Garber » Thu Feb 13, 2003 4:06 pm

oops!, I didnt have data after all!.
Anyway I have three other problems,

1) The secondary axis doesn't seem to scale automatically, it copies the primary axis unless you say something else.

2) The secondary Dataset legend references, dont show.

2) I can't change it's the colors of the secondary series.

Here is my code:

NumberAxis axis2 = new VerticalNumberAxis("Secundario");
axis2.setAutoRangeIncludesZero(false);
subPlotPpal.setSecondaryRangeAxis(axis2);
subPlotPpal.setSecondaryDataset(tsm2do);
StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
renderer2.setDrawingSupplier(new DefaultDrawingSupplier());
subPlotPpal.setSecondaryRenderer(renderer2);

renderer2.setSeriesPaint(0, Color.blue);
axis2.setMaximumAxisValue(2); //this is a test to change the 2nd scale.

Help!, please...

Diego Garber

Re: Can't get my secondaryAxis drawn

Post by Diego Garber » Fri Feb 14, 2003 7:54 pm

To the problems described before I add another one. I have a Vertically CombinedPlot with 2 subplots (sharing the same horizontal axis).
When I set the secondary axis in one of the subplots, it resizes the subplot making it smaller and making the horizontal axis get desinchronized. The result is that the domain of the subplot with the secondary axis does NOT match the 2nd subplot's domain!!!
Please help me!, I tried resetting the domainaxis for both subplots and for the combinedPlot, but nothing seems to work.
Is this a bug?

David Gilbert

Re: Can't get my secondaryAxis drawn

Post by David Gilbert » Mon Feb 17, 2003 9:58 am

Hi Diego,

I haven't tested the new dual axis code with combined / overlaid plots, so I'm sure there is some debugging to be done.

Regarding setting the series colors for the secondary dataset, you need to use the setSeriesPaint(...) method that has an extra parameter for the dataset index (0 for the primary dataset, 1 for the secondary dataset).

Regards,

Dave Gilbert

Diego Garber

Re: Can't get my secondaryAxis drawn

Post by Diego Garber » Mon Feb 17, 2003 4:16 pm

David, thaNk you for your answer and I am eager to hear any news about impovements in secondary axis, as you can see I've been having some problems with it. Let me know if I can be of any help.
I tried the setSeriesPaint as you told me any it works fine, I didn't got the idea that the first parameter was refering to the secondary Dataset. Further more, I thought that as you can have a secondary renderer, one could use it for settting colors (and other stuff) in the series belonging to the secondary axis. Nevermind, thank you anyway, and if you can help me with my question about drawing lines in plot that would be great!.
Regards,

Diego.

Locked