Jump to content
Software FX Community

Changing PIE Chart Legend Color


vivekmehtani

Recommended Posts

  • 4 months later...

 There is a difference between the legend box shown in a Pie chart and in a Bar chart (for instance). In a Bar chart (and most other types of charts) each item in the legend box represents a Series, while in a Pie chart each item represents a Point. To change the color of a slice in a Pie and have your change be reflected in the legend box, try the following sample.

 

ChartServer chart1 = new ChartServer(pageContext,request,response);chart1.getData().setSeries(1);chart1.getData().setPoints(4);java.util.Random r = new java.util.Random(1);for (int i = 0; i < chart1.getData().getPoints(); i++){   for (int j = 0; j < chart1.getData().getSeries(); j++)   {     chart1.getData().set(j, i,r.nextDouble()* 80);   }}chart1.setGallery(Gallery.PIE);chart1.getPoints().get(0).setColor(java.awt.Color.LIGHT_GRAY);chart1.renderControl();

Link to comment
Share on other sites

  • 4 months later...

 chart1.Data.Series = 1;chart1.Data.Points = 4;Random r = new Random();for (int i = 0; i < chart1.Data.Points; i++){   for (int j = 0; j < chart1.Data.Series; j++)   {   chart1.Data[j, i] = r.Next() * 80;   }}chart1.Gallery = Gallery.Pie;chart1.Points[0].Color = Color.LightGray;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...