Color and label in a PieChart
Color and label in a PieChart
Hello!!
I'm using JFreeChart in order to make a PieChart.
It works good but I want to change the colors of the different parts of the PieChart.If someone knows how to do, please tell me!!!
Another question: How can I drop the label (with the name and the value)in yellow on the PieChart
Thanks a lot!!!
[/img]
I'm using JFreeChart in order to make a PieChart.
It works good but I want to change the colors of the different parts of the PieChart.If someone knows how to do, please tell me!!!
Another question: How can I drop the label (with the name and the value)in yellow on the PieChart
Thanks a lot!!!
[/img]
Hi
To change pie section colors, i think you should look at setSectionPaint(int section, java.awt.Paint paint) method, for a PiePlot Object. See javadoc.
To drop labels, see the setLabelGenerator(PieSectionLabelGenerator generator) for a PiePlot. I know you can use it to format the labels ( Class StandardPieItemLabelGenerator is really easy to use), so i think you can use it to drop the labels.
But i didn't understand all the javadoc (English is not my native language).
Enjoy.
Florian
To change pie section colors, i think you should look at setSectionPaint(int section, java.awt.Paint paint) method, for a PiePlot Object. See javadoc.
To drop labels, see the setLabelGenerator(PieSectionLabelGenerator generator) for a PiePlot. I know you can use it to format the labels ( Class StandardPieItemLabelGenerator is really easy to use), so i think you can use it to drop the labels.
But i didn't understand all the javadoc (English is not my native language).
Enjoy.
Florian
Truc qui n'a rien a voir, mais tu ne serais pas français des fois? Je crois que j'ai vu ton nom sur un forum français (presence-pc)?
Je te demande ça parceque je pourrais peut-etre mieux t'aider (enfin...) en français.
Voilà, c'était la touche française du forum.
Florian, contre l'hégémonie de l'anglo-amériacain dans le monde des affaires et dans l'informatique.
Je te demande ça parceque je pourrais peut-etre mieux t'aider (enfin...) en français.
Voilà, c'était la touche française du forum.
Florian, contre l'hégémonie de l'anglo-amériacain dans le monde des affaires et dans l'informatique.
Tiens ben j'en profite aussi : est-ce que JFreeChart permet de mettre exactement les couleurs que l'on souhaite ? J'ai un client très exigeant sur le rendu final et bleu-jaune-rouge ne va pas vraiment lui convenir.
J'aimerais être certain que l'on peut définir exactement les couleurs style RGB ou hexa dans tous les types de graphe...
Merci d'avance
Jérôme
J'aimerais être certain que l'on peut définir exactement les couleurs style RGB ou hexa dans tous les types de graphe...
Merci d'avance
Jérôme
PieChart Label Colors
Okay,
with my limited French, I gather that this means it is not yet possible
to set different label colors for different Pie Segments, non?
Does anyone know of a way to do this otherwise?
Cheers,
nick
with my limited French, I gather that this means it is not yet possible
to set different label colors for different Pie Segments, non?
Does anyone know of a way to do this otherwise?
Cheers,
nick
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: PieChart Label Colors
There is a single attribute that controls the background color for all labels. To use a different background color for each label, you are going to need to override the drawLeftLabels() and drawRightLabels() methods.pelski wrote:with my limited French, I gather that this means it is not yet possible
to set different label colors for different Pie Segments, non?
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 13
- Joined: Fri Apr 28, 2006 2:53 pm
Answers
To the first question, how can you set individual colors to each section of the pie chart:
To the second questions, to hide the labels in a piechart:
Code: Select all
// the "0, 1, 2, 3, (and on) are the indexes of the dataset.
plot.setSectionPaint(0, new Color(160, 160, 255));
plot.setSectionPaint(1, new Color(128, 128, 32));
plot.setSectionPaint(2, myCustomPaint);
plot.setSectionPaint(3, Color.white);
Code: Select all
plot.setLabelGenerator(null);
Re: PieChart Label Colors
how do you set the attribute that controls the color of the label backgrounds?david.gilbert wrote:There is a single attribute that controls the background color for all labels. To use a different background color for each label, you are going to need to override the drawLeftLabels() and drawRightLabels() methods.pelski wrote:with my limited French, I gather that this means it is not yet possible
to set different label colors for different Pie Segments, non?