A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
tedbyers
- Posts: 50
- Joined: Fri Oct 12, 2007 7:05 pm
Post
by tedbyers » Thu May 15, 2008 4:15 pm
Here is a little code snippet:
Code: Select all
org.jfree.chart.plot.XYPlot plot = (org.jfree.chart.plot.XYPlot) theChart.getPlot();
org.jfree.chart.renderer.xy.XYBarRenderer renderer = (org.jfree.chart.renderer.xy.XYBarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setSeriesPaint(0, dg);
renderer.setSeriesItemLabelsVisible(0, true);
There is only one series in the dataset, but it is time series data with one value for each month in each year from 200 to the present.
The series gets the right colour, but the item labels do not appear. What have I missed?
Ted
-
david.gilbert
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
-
Contact:
Post
by david.gilbert » Thu May 15, 2008 4:22 pm
Probably the baseItemLabelGenerator for the renderer is null (the default, although it would probably be better to have a non-null default).
-
tedbyers
- Posts: 50
- Joined: Fri Oct 12, 2007 7:05 pm
Post
by tedbyers » Thu May 15, 2008 5:11 pm
david.gilbert wrote:Probably the baseItemLabelGenerator for the renderer is null (the default, although it would probably be better to have a non-null default).
I recall seeing a function to set the baseItemLabelGenerator, but it didn't seem to like any argument I passed to it (based on what I saw in the demos). The exception said something about the label generators used in the demos not being valid for anXYPlot (I forgot the precise wording, but ... from what I saw, not all possible label generators are valid for all types of charts - that might be something to refactor since a label is just a string, possibly derived from a numeric value with some format - why have different sets of label generators for different kinds of charts).
Anyway, what would be a safe argument for the function that sets the baseItemLabelGenerator?
Thanks
Ted
-
skunk
- Posts: 1087
- Joined: Thu Jun 02, 2005 10:14 pm
- Location: Brisbane, Australia
Post
by skunk » Thu May 15, 2008 5:17 pm
Code: Select all
org.jfree.chart.labels.StandardXYItemLabelGenerator
-
tedbyers
- Posts: 50
- Joined: Fri Oct 12, 2007 7:05 pm
Post
by tedbyers » Thu May 15, 2008 5:23 pm
skunk wrote:Code: Select all
org.jfree.chart.labels.StandardXYItemLabelGenerator
Perfect!
Thanks.
Ted