Color and label in a PieChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
agaillar

Color and label in a PieChart

Post by agaillar » Thu Dec 02, 2004 3:51 pm

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]

flobel
Posts: 8
Joined: Mon Nov 29, 2004 10:31 am

Post by flobel » Thu Dec 02, 2004 4:08 pm

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

agaillar

Post by agaillar » Thu Dec 02, 2004 5:32 pm

I manage to change the colors of the different sections of the pie chart but i don't manage to delete the label.
I'm trying to change the color of each part of the label, but i don't know why, it doesn't work!

Thanks a lot if you have a solution!

Guest

Post by Guest » Fri Dec 03, 2004 9:44 am

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.

agaillar

Post by agaillar » Fri Dec 03, 2004 10:10 am

Et si je suis francais.
j'ai reussi a changer les couleur et grace a un peu de bidouille enlever les etiquettes.
par contre là j'essais de rajouter des liens à chacune des partie du camembert mais j'y arrive pas....

Jerome

Post by Jerome » Wed Jan 05, 2005 4:08 pm

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

flobel
Posts: 8
Joined: Mon Nov 29, 2004 10:31 am

Post by flobel » Thu Jan 06, 2005 9:01 am

Je pense que c'est possible, mais je ne paux etre affirmatif : tu devrais mettre un post, en anglais, sur le forum. Je pense que c'est ecrit dans la javadoc sinon.

PS : faut ptetre mieux ecrire aussi les messages en anglais, parceque la je pense qu'il vont mal le prendre ) à la fin.

A+

Florian

pelski
Posts: 16
Joined: Thu Feb 23, 2006 2:02 am

PieChart Label Colors

Post by pelski » Fri Apr 28, 2006 8:01 am

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

flobel
Posts: 8
Joined: Mon Nov 29, 2004 10:31 am

Post by flobel » Fri Apr 28, 2006 1:20 pm

No, agaillar said he could do it with a "bidouille" (tummy, but I'm not sure about the translation).

Unfortunately, I don't know how he did it.

Good luck.

Florian

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: PieChart Label Colors

Post by david.gilbert » Fri Apr 28, 2006 4:40 pm

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?
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.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

socrateone
Posts: 13
Joined: Fri Apr 28, 2006 2:53 pm

Answers

Post by socrateone » Wed May 03, 2006 6:10 pm

To the first question, how can you set individual colors to each section of the pie chart:

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);

To the second questions, to hide the labels in a piechart:

Code: Select all

plot.setLabelGenerator(null);

uroojk
Posts: 13
Joined: Thu Oct 25, 2007 10:48 pm

Re: PieChart Label Colors

Post by uroojk » Wed Nov 14, 2007 2:53 pm

david.gilbert wrote:
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?
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.
how do you set the attribute that controls the color of the label backgrounds?

Locked