If you amend this example code so that you only have 1 value in each axis
so that you have :-
private static XYDataset createDataset1() {
TimeSeries s1 = new TimeSeries("Random Data 1");
s1.add(new Month(2, 2016), 181.;
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s1);
return dataset;
}
and likewise for createDataset2 you end up with some wierd values on the axis scales.
4.296E2 for example
Any ideas ?
Problem with 1.5 Example Source DualAxisDemo2.java
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Problem with 1.5 Example Source DualAxisDemo2.java
I see this also. What is happening is that the range for the axes is determined by looking at the minimum and maximum data values. In this case, there is just a single value (429.6) so JFreeChart has to decide what should be the minimum and maximum values on the axis. It does this by looking at an attribute 'autoRangeMinimumSize' - the default is very small, and it doesn't seem to interact so well with the tick label format. One workaround is that you can override the autoRangeMinimumSize as follows (choose some value that is appropriate for your data):
Code: Select all
NumberAxis axis1 = (NumberAxis) plot.getRangeAxis();
axis1.setAutoRangeMinimumSize(1.0);
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Re: Problem with 1.5 Example Source DualAxisDemo2.java
Yes that seems to have fixed the problem.
Many thanks for such a quick response - most appreciated.
Dave
Many thanks for such a quick response - most appreciated.
Dave