Page 1 of 1

Custom colors on Pie

Posted: Mon Nov 08, 2010 8:27 pm
by 15354147
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

Re: Custom colors on Pie

Posted: Tue Nov 09, 2010 10:18 am
by narcis
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.