Custom colors on Pie

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
ZooX
Newbie
Newbie
Posts: 18
Joined: Tue Aug 25, 2009 12:00 am

Custom colors on Pie

Post by ZooX » Mon Nov 08, 2010 8:27 pm

Hi, how exactly do I control/get to the colors of a pie chart?

In bar, stacked and Line I grab the series and change the color.

For example, I have only one series yet the slices of the pie are all different colors and I can't find for the life of me how to adjust them. The naming of a few of the methods/classes etc... doesn't seem very intuitive to me, the documentation is mediocre at best and I obviously can't see the source code so I need to ask questions like this here.

Brian

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Custom colors on Pie

Post by Narcís » Tue Nov 09, 2010 10:18 am

Hi Brian,

You have 2 options here:

1. Populating series specifying a color for each slice:

Code: Select all

        com.steema.teechart.styles.Pie pie1 = new com.steema.teechart.styles.Pie(tChart1.getChart());
        Random y = new Random();

        for (int i= 0; i < 10; i++) {
            pie1.add(y.nextDouble(), Color.fromArgb(i * 25, i * 25, i * 25));
        }
2. Changing Colors ValueLists colors:

Code: Select all

        com.steema.teechart.styles.Pie pie1 = new com.steema.teechart.styles.Pie(tChart1.getChart());
        pie1.fillSampleValues(10);

        for (int i= 0; i < pie1.getCount(); i++) {
            pie1.getColors().setColor(i, Color.fromArgb(i * 25, i * 25, i * 25));
        }
Why can't you see the source code? Full sources are included in all TeeChart for Java licenses.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply