Teechart单点的多箱图

时间:2013-04-18 06:55:31

标签: activex teechart

我们可以为单点绘制多个盒子策略,类似于我们在条形图中我们在单点处有多个柱子的情况。

由于 阿克沙伊

1 个答案:

答案 0 :(得分:0)

您可以拥有多个BoxSeries,类似于以下示例: http://www.teechart.net/support/viewtopic.php?f=3&t=13048&hilit=boxplot

这是一个Delphi示例,但它在ActiveX中应该没有什么不同。


更新:

根据您的评论,我了解您希望在不同的X位置有一些方框,可能还有小组。这里有一个简单的例子,说明如何使用Positions来实现同样的目标:

Dim nSeries, groupSize As Integer
Private Sub Form_Load()
  Dim i, aIndex, sIndex, lIndex, tmpX As Integer

  TeeCommander1.ChartLink = TChart1.ChartLink
  'TChart1.Header.Text.Text = TChart1.Version

  TChart1.Aspect.View3D = False
  TChart1.Panel.MarginTop = 7
  TChart1.Header.Visible = False
  TChart1.Axis.Bottom.Ticks.Visible = False
  TChart1.Axis.Bottom.MinorTicks.Visible = False

  nSeries = 8
  groupSize = 2

  aIndex = TChart1.Tools.Add(tcAnnotate)
  TChart1.Tools.Items(aIndex).asAnnotation.Text = "group 1"

  tmpX = 0
  For i = 0 To nSeries - 1
    sIndex = TChart1.AddSeries(scBox)
    TChart1.series(sIndex).FillSampleValues
    TChart1.series(sIndex).asBoxPlot.Position = tmpX

    If (i + 1) Mod groupSize Then
      tmpX = tmpX + 1
    Else
      If i + 1 < nSeries - 1 Then
        lIndex = TChart1.Tools.Add(tcColorLine)
        TChart1.Tools.Items(lIndex).asColorLine.Axis = TChart1.Axis.Bottom
        TChart1.Tools.Items(lIndex).asColorLine.Value = tmpX + 1
        tmpX = tmpX + 2

        aIndex = TChart1.Tools.Add(tcAnnotate)
        TChart1.Tools.Items(aIndex).asAnnotation.Text = "group " + Str$(((i + 1) / groupSize) + 1)
      End If
    End If
  Next i

  TChart1.Environment.InternalRepaint
End Sub

Private Sub TChart1_OnAfterDraw()
  Dim tmpX As Integer
  For i = 0 To TChart1.Tools.Count - 1
    If TChart1.Tools.Items(i).ToolType = tcAnnotate Then
      With TChart1.Tools.Items(i).asAnnotation
        If i = TChart1.Tools.Count - 1 Then
          tmpX = TChart1.GetChartRect.Right
        Else
          tmpX = TChart1.Axis.Bottom.CalcXPosValue(TChart1.Tools.Items(i + 1).asColorLine.Value)
        End If

        If i = 0 Then
          tmpX = TChart1.GetChartRect.Left + (tmpX - TChart1.GetChartRect.Left) / 2
        Else
          tmpX = TChart1.Axis.Bottom.CalcXPosValue(TChart1.Tools.Items(i - 1).asColorLine.Value) + (tmpX - TChart1.Axis.Bottom.CalcXPosValue(TChart1.Tools.Items(i - 1).asColorLine.Value)) / 2
        End If

        .Left = tmpX - .Width / 2
      End With
    End If
  Next i
End Sub

Private Sub TChart1_OnGetAxisLabel(ByVal Axis As Long, ByVal SeriesIndex As Long, ByVal ValueIndex As Long, LabelText As String)
  If Axis = 3 Then
    LabelText = " "
  End If
End Sub

enter image description here