label background color in line chart
label background color in line chart
Is it possible to set label background color into in line chart ?
Bruno
No, you can't do it. Quote from the developer's guide:
I am not a Java 2D expert, but AFAIK there is nothing like a background color for strings drawn on the Graphic2D device. Which is probably the reason why this possibility does not exist in the JFreeChart API (yet).
You would probably need to add code for drawing filled rectangles before drawing the text of the label. There are methods for determining the space (width) occupied by a text in order to calculate the required width of the rectangle.
If you definitely need it, you should have a look at the drawItemLabel method for the renderer class you are using to render your line chart.In the current release of JFreeChart, labels are drawn with a transparent background. You cannot set a background color for the labels, nor can you specify that a border be drawn around the labels. This may change in the future.
I am not a Java 2D expert, but AFAIK there is nothing like a background color for strings drawn on the Graphic2D device. Which is probably the reason why this possibility does not exist in the JFreeChart API (yet).
You would probably need to add code for drawing filled rectangles before drawing the text of the label. There are methods for determining the space (width) occupied by a text in order to calculate the required width of the rectangle.