hi all;
I would like to add an explanation (legend per my understanding displayed somewhere on the chart) to a thermometer chart in order to explain subrange colors. for example:
[red]=hot
[yellow]=cool
[blue]=cold
I was able to define the sub ranges and their color, but I cant seem to find the way to add the descriptive text to these colors.
your help is appreciated.,
thanks.
legend in thermometer plot (to explain subrange colors)?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: legend in thermometer plot (to explain subrange colors)?
To add a legend with manually specified entries, you can do something like this:
Code: Select all
LegendTitle legend = new LegendTitle(new LegendItemSource() {
@Override
public LegendItemCollection getLegendItems() {
LegendItemCollection items = new LegendItemCollection();
items.add(new LegendItem("Item A", Color.RED));
items.add(new LegendItem("Item B", Color.GREEN));
items.add(new LegendItem("Item C", Color.BLUE));
return items;
}
});
legend.setPosition(RectangleEdge.RIGHT);
chart.addLegend(legend);
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program