Teechart条形图单元格条形图案

时间:2013-08-08 06:51:41

标签: activex teechart

我们如何才能将模式只提供给系列的单个条。我假设我的系列有4个条点单击条形图时它应该更改模式。我知道更改特定点颜色的功能。

1 个答案:

答案 0 :(得分:0)

您可以将模式存储在数组中并将其设置为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