Hi,
Is it possible to add a part to a legend?
In fact, I want my legend to be composed of one or many words, and after, my "normal" legend.
I have many item and want to gain some place. It is important for my work!
I want for instance to do that :
"presentation 1 : ° presentation 2 : ° presentation 3 : °"
become -->
"presentation : 1 : ° 2 : ° 3 : °"
Thank you!
Customize legend?
Yes its possible to customize legends. First you need to remove the existing legends from the chart using the following piece of code.
//Remove all the legends from chart.
for(int i=0;i<mycollection.getItemCount();i++){
chart.removeLegend();
}
Now create
LegendItemSource mysource= new MyLegendSource(mycollection);
LegendTitle legend= new LegendTitle(mysource);//,(Arrangement)HorizontalAlignment.CENTER,(Arrangement)VerticalAlignment.BOTTOM);
legend.setPosition(RectangleEdge.BOTTOM);
legend.setBackgroundPaint((Paint)ChartColor.WHITE);
legend.setBorder(new BlockBorder());
Add this new legend to your chart
chart.addLegend(legend);
//Remove all the legends from chart.
for(int i=0;i<mycollection.getItemCount();i++){
chart.removeLegend();
}
Now create
LegendItemSource mysource= new MyLegendSource(mycollection);
LegendTitle legend= new LegendTitle(mysource);//,(Arrangement)HorizontalAlignment.CENTER,(Arrangement)VerticalAlignment.BOTTOM);
legend.setPosition(RectangleEdge.BOTTOM);
legend.setBackgroundPaint((Paint)ChartColor.WHITE);
legend.setBorder(new BlockBorder());
Add this new legend to your chart
chart.addLegend(legend);
Zzzzz....
Thanks for your answer.
I already have tried that :
But I want to customize the content of my legend...
And I still don't know how to do what I have explain up.
I already have tried that :
Code: Select all
jfreechart = ChartFactory.createXYLineChart("", "", "", (XYDataset)ds, PlotOrientation.VERTICAL, false, true, false);
LegendTitle legend = new LegendTitle(jfreechart.getPlot());
legend.setItemFont(new Font(null,Font.PLAIN,10));
legend.setPosition(RectangleEdge.BOTTOM);
legend.setBorder(1, 1, 1, 1);
jfreechart.addLegend(legend);
And I still don't know how to do what I have explain up.