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

Message ListMessage List     Post MessagePost Message

  Example
Posted by Kevin Kidson on Mar-09-2016 19:08
I just saw exactly wnat I want - in the http://www.advsofteng.com/gallery_pie.html examples there are Alpha, Beta and Gamma division pie charts - how where these created to be one colour ? Sorry - just cannot find these in the examples

  Re: Example
Posted by Peter Kwan on Mar-10-2016 03:22
Hi Kevin,

The example you mentioned are included in the ChartDirector download:

http://www.advsofteng.com/doc/cdnet.htm#multipie.htm

Like the data in the example, the different shades in the example are hard coded as an array of colors. Of course, like the data, in your real code, you can create the array using any method you like. For example, you can interpolate a deep starting color with white to compute the various shades used in the array.

Suppose you start with a color with the red, green and blue component being (R, G, B). and you want the lightest shade to be 80% white mixes with 20% of your starting color. (You probably would not want the lightest shade to be 100% white otherwise it is invisible.) If you have N sectors, the interpolation would be like:

R(i) = (255 * 0.8 * i + R x (N - 1 - 0.8 * i) / (N - 1)
... same for green and blue .....

In the above, i = 0 to N - 1 for the colors of the N sectors. You can therefore compute the RGB components of all colors in the array.

Hope this can help.

Regards
Peter Kwan

  Re: Example
Posted by Peter Kwan on Mar-10-2016 04:22
Hi Kevin,

I have just remembered there is a "BaseChart.adjustBrightness" API in ChartDirector that can create a brighter or darker version of a given color. See:

http://www.advsofteng.com/doc/cdnet.htm#BaseChart.adjustBrightness.htm

We use this API in the following sample code to create different shades of colors for the meters:

http://www.advsofteng.com/doc/cdnet.htm#neonroundmeter.htm

You can also use this method to create different shades of colors for the color array in a pie chart.

Regards
Peter Kwan