Hi, I'd like to know if it's possible to write the categories in the vertical instead of horizontal...
thanks any help...
Writting Vertical Legends
Re: Writing Vertical Legends
Hi Tony,
Try out the setAnchor(...) method in the Legend class. You should be able to use the constants Legend.NORTH, Legend.SOUTH, Legend.EAST and Legend.WEST. East and West will draw the legend "vertically".
Regards,
DG.
Try out the setAnchor(...) method in the Legend class. You should be able to use the constants Legend.NORTH, Legend.SOUTH, Legend.EAST and Legend.WEST. East and West will draw the legend "vertically".
Regards,
DG.
Re: Writing Vertical Legends
Hi --
I'd like to have a vertical legend with the anchor set to Legend.SOUTH. Is this possible?
Basically, I've got some pie and bar charts which I need to have a vertical legend for, but the lengths of the legend labels can vary, and really don't want their lengths to affect the size of the pie and bar chart, which they do if you anchor them east or west.
Thanks for the great tool-
Mike
I'd like to have a vertical legend with the anchor set to Legend.SOUTH. Is this possible?
Basically, I've got some pie and bar charts which I need to have a vertical legend for, but the lengths of the legend labels can vary, and really don't want their lengths to affect the size of the pie and bar chart, which they do if you anchor them east or west.
Thanks for the great tool-
Mike
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
It is not possible without rewriting the legend class (which will happen at some point).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Thanks --
I was able to workaround it by creating 2 plots.. one with just the legend and aligning it underneath using HTML.
The way I created the legend-only plot was rather crude. I extended StandandLegend and overrode the draw() method as follows. Is there a better way to do this?
I was able to workaround it by creating 2 plots.. one with just the legend and aligning it underneath using HTML.
The way I created the legend-only plot was rather crude. I extended StandandLegend and overrode the draw() method as follows. Is there a better way to do this?
Code: Select all
public class ChartlessStandardLegend extends StandardLegend {
public ChartlessStandardLegend(JFreeChart chart) {
super(chart);
}
protected Rectangle2D draw(Graphics2D g2, Rectangle2D available,
boolean horizontal, boolean inverted,
ChartRenderingInfo info) {
super.draw(g2, available, horizontal, inverted, info);
return new Rectangle(0,0);
}
}
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
That's not a bad workaround. Off the top of my head, it might be possible to make this cleaner by adding a 'legendVisible' flag to the StandardLegend class (or your own extension) so that it functions within the original chart (to fetch legend items etc) but doesn't get drawn. Then you could get your own code to call the draw(...) method (somehow overriding the 'visible' flag) to draw the legend somewhere outside the original chart.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Re: Writting Vertical Legends
I want to achieve the same behavior. I am using 1.0.19. LegendTitle class doesn't have setAnchor(...) method. Any suggestion?
Thanks,
AW
Thanks,
AW