我们如何才能只为系列中的一个条形图提供模式。假设我的系列有4个条形图。单击条形图时,应该更改模式。我知道更改特定点的颜色的功能。
您可以将模式存储在一个数组中,并在OnGetSeriesBarStyle
事件中设置它们。这里有一个例子:
Dim myPatterns() As Integer
Private Sub Form_Load()
TChart1.AddSeries scBar
TChart1.Series(0).FillSampleValues
ReDim myPatterns(TChart1.Series(0).Count)
Dim i As Integer
For i = LBound(myPatterns) To UBound(myPatterns)
myPatterns(i) = 0
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 And ValueIndex > -1 Then
myPatterns(ValueIndex) = (myPatterns(ValueIndex) + 1) Mod 20
End If
TChart1.Repaint
End Sub
Private Sub TChart1_OnGetSeriesBarStyle(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, BarStyle As TeeChart.EBarStyle)
If SeriesIndex > -1 And ValueIndex > -1 Then
TChart1.Series(SeriesIndex).asBar.BarBrush.ClearImage
TChart1.Series(SeriesIndex).asBar.BarBrush.Style = myPatterns(ValueIndex)
End If
End Sub