ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Pie Chart Colors
Posted by Mark on May-07-2009 20:46
(classic Asp)

I have a pie chart, that is generated dynamically..
and need to be able to make 1 slice of the pie 1 color all of the time

i would have a list like

part #1
part #2
part #3
part #4

and i need part #2 to always be Blue

the data may come in any order... and may have 2 - 200 parts...
and it may not alwyas have part #2...

so, is there a way i can set in the pie chart

when i run into part #2 to set that color to blue?

  Re: Pie Chart Colors
Posted by Peter Kwan on May-08-2009 04:15
Hi Mark,

You may set any sector to blue using BaseChart.setColors2. If you want to set part #2, you may just set the sector for part #2 to blue.

For example:

'get where is "part #2"
For i = 0 To Ubound(myLabels)
   If myLabels(i) = "part #2" Then Exit For
Next

'set it to blue
Call c.setColors2(cd.DataColor + i, Array(&H0000ff))

However, note that if you set the color of one sector, you probably want to set the colors of all sectors. ChartDirector will pre-defined the colors of all sectors, even before you add data to the chart. It is possible ChartDirector has already set a similar color to another sector. So your pie chart may end up with two sectors having the same color or similar colors.

My suggest is to add the following code before the above code:

Call c.setColors(cd.DataColor, array(&Hff3333, &H33ff33, &Hffff00, &Hff66ff, &H99ffff, &Hffcc33, &Hcccccc, &Hcc9999, &H339966, &H999900, &Hcc3300))

The above line asks ChartDirector to use the given colors for the sectors. The given colors do not contain blue, so it will not result in two sectors having the same blue color. Then you can use the code to set the "part #2" to blue.

Hope this can help.

Regards
Peter Kwan