When setHorizontalAxis(HorizontalDateAxis axis) in one TimeSeriesChart,it will report
java.lang.NullPointerException
at com.jrefinery.chart.DateAxis.findAxisMagnitudeIndex(DateAxis.java:411)
at com.jrefinery.chart.HorizontalDateAxis.calculateAutoTickUnits(HorizontalDateAxis.java:456)
at com.jrefinery.chart.HorizontalDateAxis.refreshTicks(HorizontalDateAxis.java:312)
at com.jrefinery.chart.HorizontalDateAxis.reserveHeight(HorizontalDateAxis.java:417)
......
......
just eg
public TimeSeriesCollection createSingleTimeCollections(){
BasicTimeSeries t1 = new BasicTimeSeries("EUR/GBP");
try {
t1.add(new Day(2, SerialDate.JANUARY, 2001), new Double(1.5788));
t1.add(new Day(3, SerialDate.JANUARY, 2001), new Double(1.5913));
t1.add(new Day(4, SerialDate.JANUARY, 2001), new Double(1.5807));
t1.add(new Day(5, SerialDate.JANUARY, 2001), new Double(1.5711));
t1.add(new Day(8, SerialDate.JANUARY, 2001), new Double(1.5778));
t1.add(new Day(9, SerialDate.JANUARY, 2001), new Double(1.5851));
t1.add(new Day(10, SerialDate.JANUARY, 2001), new Double(1.5846));
t1.add(new Day(11, SerialDate.JANUARY, 2001), new Double(1.5727));
t1.add(new Day(12, SerialDate.JANUARY, 2001), new Double(1.5585));
t1.add(new Day(15, SerialDate.JANUARY, 2001), new Double(1.5694));
t1.add(new Day(16, SerialDate.JANUARY, 2001), new Double(1.5629));
t1.add(new Day(17, SerialDate.JANUARY, 2001), new Double(1.5831));
t1.add(new Day(18, SerialDate.JANUARY, 2001), new Double(1.5624));
}
catch (Exception e) {
System.err.println(e.getMessage());
}
TimeSeriesCollection tsc=new TimeSeriesCollection();
tsc.addSeries(t1);
return tsc;
}
public void createTimeChart(){
JFreeChart timeChart=ChartFactory.createTimeSeriesChart("TimeSerie","Date","Value",createSingleTimeCollections(),true);
HorizontalDateAxis hda=new HorizontalDateAxis("Date Axis");
// hda.setGridLinesVisible(false);
.....
timeChart.getPlot().setHorizontalAxis(hda);
try{
ChartUtilities.saveChartAsPNG(new File("test.png"),timeChart,600,600);
}catch(IOException e){
System.out.println(e.getMessage());
}
}
call the createTimeChart() will throw the Exception.
Some Problem in setHorizontal(Date)Axis
Re: Some Problem in setHorizontal(Date)Axis
Thanks for the report and the sample code. Same as for the other bug you reported, I've reproduced this against 0.7.3 but it works OK against my latest source tree (0.7.4 soon). So when 0.7.4 is released (I hope next week) your problem will be solved.
Regards,
Dave Gilbert
Regards,
Dave Gilbert