Hi everyone,
I tried to the order of my LegendItems in a CategoryPlot via Postprocessor.
I have overridden the getLegentItems()-Method in my Postprocessor owned CategoryPlot, but I can not find any possibility to set this Plot into the Chart.
Is there any possibility to do so?
TIA
Markus
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No, you can't set a different Plot object - you need to work with the one that already exists (which you can get at via chart.getPlot()). Then you need to cast that Plot object to the specific Plot subtype that you're working with, after which you can get at the Renderer, and through that at the LegendItem objects - which you can then alter to your heart's content.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to get the LegendItemCollection plot.getRenderer().getLegendItems(); (plot is a CategoryPlot),
iterate over the collection LegendItem item = (LegendItem) legendItemIter.next();
and to change the color of the label.
I tried to use legendItem.setLabelPaint(Paint paint)
but it does not change anything.
What is wrong on my approache?
I am using jfreechart 1.0.13 and cewolf 1.0.0,
I tried to change the color of the legendItemLabel via PostProcessor.
Kind regards,
Markus
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's a postprocessor that changes the label colors on a category plot; I've verified that it works fine. (As an aside, you should use the cewolf distribution from http://www.ulfdittmer.com/code/cewolf.html, not the one downloadable here).
public class LegendItemPostProcessor implements ChartPostProcessor, Serializable
{
public void processChart (Object chart, Map params) {
CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot();
LegendItemCollection liColl = plot.getLegendItems();
for (int i = 0; i < liColl.getItemCount();i++){LegendItemli =liColl.get(i);StringcolorStr =(String)params.get(String.valueOf(i));li.setLabelPaint(Color.decode(colorStr));}}}<jsp:useBeanid="legendItems"class="de.laures.cewolf.example.LegendItemPostProcessor"/><cewolf:chartpostprocessorid="legendItems"><cewolf:paramname="0"value="#FF0000"/><cewolf:paramname="1"value="#00FF00"/><cewolf:paramname="2"value="#0000FF"/><cewolf:paramname="3"value="#FFFFFF"/></cewolf:chartpostprocessor>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone,
I tried to the order of my LegendItems in a CategoryPlot via Postprocessor.
I have overridden the getLegentItems()-Method in my Postprocessor owned CategoryPlot, but I can not find any possibility to set this Plot into the Chart.
Is there any possibility to do so?
TIA
Markus
No, you can't set a different Plot object - you need to work with the one that already exists (which you can get at via chart.getPlot()). Then you need to cast that Plot object to the specific Plot subtype that you're working with, after which you can get at the Renderer, and through that at the LegendItem objects - which you can then alter to your heart's content.
Hello,
thanks a lot for the answer..
I tried to get the LegendItemCollection plot.getRenderer().getLegendItems(); (plot is a CategoryPlot),
iterate over the collection LegendItem item = (LegendItem) legendItemIter.next();
and to change the color of the label.
I tried to use legendItem.setLabelPaint(Paint paint)
but it does not change anything.
What is wrong on my approache?
I am using jfreechart 1.0.13 and cewolf 1.0.0,
I tried to change the color of the legendItemLabel via PostProcessor.
Kind regards,
Markus
Here's a postprocessor that changes the label colors on a category plot; I've verified that it works fine. (As an aside, you should use the cewolf distribution from http://www.ulfdittmer.com/code/cewolf.html, not the one downloadable here).
Actually, scratch that - it doesn't seem to work; not sure why.