I am still trying to debug the problem that I am experiencing with displaying a time series chart with a single point.
I tried removing the auto tick selection code and went back to setting the manually but that had no effect the single point does not show up.
Now I am trying to debug this.
I can walk through my code where I loop through my result set (with a single row) and create a single time series which is then added to the time series collection. When I evaluate the time series collection and look at its data object I can see its length is one and looking further down I can see that there is a single time series with a period (a date "11/17/2002") and a value (1.0).
OK, now I am stepping into ChartFactory.createTimeSeriesChart. In there I am looking at when the XYPlot is built. When I evaulate XYPlot I see its dataset and then its data list which has a length of 1 and the element is the same as mentioned above.
So the plot is then passed to the creation of the JFreeChart object where it is added to this object.
Stepping through my code again. I am setting the title and then I use the renderer to do: standardXYItemRenderer.setPlotShapes(true);
This is to put shapes around points. This was added a while ago just for this purpose. If the chart was for a very short date range and had only a single point then the shape made the point easier to see.
After that my code messes with the axis, setting colors etc.
Next I get the output stream.
Then I call: ChartUtilities.writeChartAsJPEG(out, chart, width, height);
Stepping into this I can't see any errors thrown.
Went down into where the XYPlot is trying to render points. Down into StandardXYItemRenderer's drawItem method. Got a line where its doing:
if (shape.intersects(dataArea)){
and this doesn't eval to true so it doesn't do the g2.draw() call.
Am I in the right area? Is the point's shape somehow not in the right area when its single point?
The chart works fine when I increase the range and make a dataset with two points, then this displays fine.
Tried taking out the code where I use the renderer to turn on shapes for points and retried but still the problem.
Is there a bug in 0.9.5 when you try to display a time series chart with a single point?
More info on time series chart with a single point problem
Re: More info on time series chart with a single point probl
Backed out changes and rebuilt with 0.9.4 and the time series chart build fine with a single point.
I would prefer to go to 0.9.5 though because of fixes etc.
I would prefer to go to 0.9.5 though because of fixes etc.
Re: More info on time series chart with a single point probl
There is an attribute 'auto-range-minimum-size' that should be set to some positive value - this prevents the axis range from having a length of zero when the max and min data values are the same (as in the case where there is only one data value). It looks like the default setting has been removed accidentally...I fixed this, and a related bug, in CVS ready for the 0.9.6 release.
As a workaround, you can set the value for your axis using the setAutoRangeMinimumSize(...) method.
Regards,
Dave Gilbert
As a workaround, you can set the value for your axis using the setAutoRangeMinimumSize(...) method.
Regards,
Dave Gilbert
Re: More info on time series chart with a single point probl
Thanks Dave,
I will make sure to get that 0.9.6 release.
Again, thanks for the help!
I will make sure to get that 0.9.6 release.
Again, thanks for the help!