Page 1 of 1

ColorEachPoint won't color each one

Posted: Tue May 10, 2005 6:32 pm
by 9524644
I know I've had this issue before & I can't remember how to fix it. I want every slice of the pie to be a different color Using VFP 9.0 with TeeChart Pro v7.0.0.2, with a Pie Chart. Color Each Slice is checked. What am I supposed to pass to .Series[0].Add(nVal,cVal,?nColor) as nColor? Here's the code to setup the data...

Code: Select all

.Series[0].Title = cSeriesName
FOR i = 1 TO .SeriesCount
	.Series[i-1].Clear
ENDFOR
.Axis.Left.Labels.RoundFirstLabel = .T.	&& Always round off axis labels.
.Axis.Bottom.Labels.RoundFirstLabel = .T.	&& Always round off axis labels.
SELECT (cDataSource)
num_Fields = FCOUNT(cDataSource)
cLblField = FIELD(1)
SCAN ALL
	FOR i = 1 TO MIN(num_fields - ,.SeriesCount)	&& Now insert the data
		cValField = FIELD(i+1)
		.Series[i-1].ColorEachPoint = .T.
		.Series[i-1].Add(NVL(&cValField,0),ALLTRIM(TRANSFORM(&cLblField)),.Series[i-1].Color)
	ENDFOR
ENDSCAN
.Visible = .T.

Posted: Thu May 12, 2005 6:10 am
by Pep
Hi Ken,

passing a correct RGB color should be sufficient, as in the following code :

Code: Select all

Form1.OleControl1.Series(0).Add( 100, 'Apples', RGB( 255, 0,0) )
Form1.OleControl1.Series(0).Add( 300, 'Pears', RGB( 0,255,0) )
Form1.OleControl1.Series(0).Add( 200, 'Bananas', RGB( 255,255,0) )

Posted: Thu May 12, 2005 1:00 pm
by 9524644
I thought there was some way for TeeChart to handle this itself. Guess not, so I used RAND()*RGB(255,255,255) to generate random colors. Thanks.