Hello JAV,
Let me try to explain. When a series value hasn't a color assigned, the color of the series is used to draw it. However, as soon as you add your values with color, this color is used to draw the point.
So you have two options here:
1. Add your values without color (using clTeeColor as color parameter) so the series color will be used to draw its points. Then, changing the series color will modify both the series points and the series legend symbol. Example:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = True
TChart1.Aspect.Chart3DPercent = 50
TChart1.Legend.Visible = True
TChart1.Legend.CheckBoxes = True
TChart1.Legend.Alignment = laBottom
Dim i As Integer
Dim icolor As Long
For i = 0 To 2
icolor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
TChart1.AddSeries scBar
With TChart1.Series(i)
.Add 10, "first", clTeeColor
.Add 20, "second", clTeeColor
.Add 30, "third", clTeeColor
.Add 40, "fourth", clTeeColor
.asBar.BarWidthPercent = 40
.asBar.MultiBar = mbNone
.Color = icolor
End With
Next i
End Sub
Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If SeriesIndex > -1 Then
TChart1.Series(SeriesIndex).Color = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
End If
End Sub
2. Add your values with color. Then, if you want to change the colors of all the points in a series, you'll have to loop them. Example:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = True
TChart1.Aspect.Chart3DPercent = 50
TChart1.Legend.Visible = True
TChart1.Legend.CheckBoxes = True
TChart1.Legend.Alignment = laBottom
Dim i As Integer
Dim icolor As Long
For i = 0 To 2
icolor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
TChart1.AddSeries scBar
With TChart1.Series(i)
.Add 10, "first", icolor
.Add 20, "second", icolor
.Add 30, "third", icolor
.Add 40, "fourth", icolor
.asBar.BarWidthPercent = 40
.asBar.MultiBar = mbNone
.Color = icolor
End With
Next i
End Sub
Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim i As Integer
If SeriesIndex > -1 Then
With TChart1.Series(SeriesIndex)
.Color = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
For i = 0 To .Count - 1
.PointColor(i) = .Color
Next i
End With
End If
End Sub