A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
jaypee
- Posts: 32
- Joined: Fri Mar 24, 2006 2:35 am
Post
by jaypee » Wed Apr 26, 2006 9:48 am
Currently I'm using this to add labels to my chart:
Code: Select all
plot.getRenderer().setSeriesPaint(0, Color.blue);
plot.getRenderer().setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
plot.getRenderer().setItemLabelFont(new Font("Arial",Font.PLAIN,8));
plot.getRenderer().setItemLabelsVisible(true);
plot.getRenderer().setItemLabelPaint(Color.MAGENTA);
but with these, it puts labels on all the points.
Is there a way to put labels only on the points I specify?
-
doudou
- Posts: 27
- Joined: Tue Mar 14, 2006 6:05 pm
Post
by doudou » Wed Apr 26, 2006 10:08 am
hmmm it looks like we're looking for the same thing.
will keep you informed if I find...
-
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 » Wed Apr 26, 2006 10:39 am
One way would be to implement your own label generator that only returns a label for the items you want (this means the generator will have to have some mechanism for determining which items should have labels, perhaps a look-up table).
-
jaypee
- Posts: 32
- Joined: Fri Mar 24, 2006 2:35 am
Post
by jaypee » Thu Apr 27, 2006 12:20 am
Thanks
What methods do I need to override?
-
angel
- Posts: 899
- Joined: Thu Jan 15, 2004 12:07 am
- Location: Germany - Palatinate
Post
by angel » Thu Apr 27, 2006 7:42 am
Code: Select all
public class MyPieSectionLabelGenerator implements PieSectionLabelGenerator {
public String generateSectionLabel(PieDataset dataset, Comparable key) {
return ...;
}
public AttributedString generateAttributedSectionLabel(PieDataset dataset, Comparable key) {
return null;
}
}
-
angel
- Posts: 899
- Joined: Thu Jan 15, 2004 12:07 am
- Location: Germany - Palatinate
Post
by angel » Thu Apr 27, 2006 10:01 am
For CategoryDataset you should extend the StandardCategoryItemLabelGenerator and overwrite the generateLabels() method.
-
jaypee
- Posts: 32
- Joined: Fri Mar 24, 2006 2:35 am
Post
by jaypee » Wed May 03, 2006 3:31 am
thanks i'll try it out
