changing line color issue

TeeChart for ActiveX, COM and ASP
Post Reply
scott
Newbie
Newbie
Posts: 10
Joined: Mon Dec 22, 2003 5:00 am
Location: Phoenix, AZ

changing line color issue

Post by scott » Tue Jul 20, 2004 6:18 pm

I have having difficulty changing the line color for a series. I use the following code:

Code: Select all

'Change line color and axis colors
'tempColor = ConvertColorToRGB(TChart1.Series(optTraceNum.value).Color)
'msgbox "currentColor = " & tempColor
lColor = ConvertColorToBGR(colorCell.bgColor)
TChart1.Series(optTraceNum.value).Color = lColor
With TChart1.Axis.Custom(optTraceNum.value - 1)
      .AxisPen.Color = lColor
      .Ticks.Color = lColor
      .Labels.Font.Color = lColor
End With
TChart1.Series(optTraceNum.value).RefreshSeries
'TChart1.repaint
'tempColor = ConvertColorToRGB(TChart1.Series(optTraceNum.value).Color)
'msgbox "changedColor = " & tempColor
I am using TChart version 6.0.0.4 in an HTML page; The issue that I am having with the above code, is that all colors are applied correctly to the AxixPen, Ticks and Label.Fonts and get updated as soon at the color setting is changed. However, the line representing the Series does not get changed. Is there some type of series refresh that I need to do? The original code did not have the .Refresh Series call, but adding it seemed to have not affect. When I enable the msgbox, the display of the color is correct; the only issue is that the line color within the Chart area is not changed.

Thanks in advance for your assistance

Scott Small

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Jul 21, 2004 12:37 am

Hi Scott,

how are you adding the data ?
Using the clteeColor constant Array and then the same line you write should work fine :

TChart1.Series(optTraceNum.value).AddXY x,y,"",clteeColor
TChart1.Series(optTraceNum.value).Color = lColor

scott
Newbie
Newbie
Posts: 10
Joined: Mon Dec 22, 2003 5:00 am
Location: Phoenix, AZ

Post by scott » Wed Jul 21, 2004 4:38 pm

Pep,
Originally I was using the AddArray function to add the trace data array (values and times arrays): this worked as expected. Code used was:

Code: Select all

TChart1.Series(i + 1).AddArray UBound(avValue) + 1, avValue, adtTimestamp
In order to be able to correctly display NULL values, I modified the code to use the following mechanism to add each value pair:

Code: Select all

TChart1.Series(currentDatasetIndex+1).AddXY adtTimestamp(j),avValue(j),"",g_TraceColors(currentDatasetIndex)
When I use this code, the color of the line does not get changed when setting the TChart1.Series(optTraceNum.value).Color = lColor.

I modified (per your suggestion) the code to use the

Code: Select all

TChart1.Series(currentDatasetIndex+1).AddXY adtTimestamp(j),avValue(j), "", clteeColor
setting, but the line always appears as black and still does not get changed when processing the TChart1.Series(optTraceNum.value).Color = lColor line of code.

For our application, our users have identified a specific set of colors that are to be used (and the order) when traces are added. Hence the use of a color array g_TraceColors(currentDatasetIndex) when invoking the AddXY method. Is there something else I need to do on the initial setup of the Series to allow runtime changes of the trace color?

Thanks

Scott Small

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Jul 22, 2004 4:04 pm

Hi Scott,

yes, to be able to change the color of a individual point you must set the ColorEachPoint property to true, like :
TChart1.Series(0).ColorEachPoint = True
TChart1.Series(0).AddXY x, y, "", vbBlue

Post Reply