TeeChart Pro ActiveX教程(十九):TeeChart工具集(四)
本文將續(xù)講工具集中的畫線工具、附加示例工具、甘特拖動工具和網(wǎng)格帶工具。
一、畫線工具
繪制線工具允許使用鼠標(biāo)在圖表上繪制,選擇,拖動和刪除完全可自定義的線條。
設(shè)計時:
可以將繪制線工具設(shè)置為特定系列,也可以將調(diào)用與任何圖表系列保持關(guān)聯(lián),也可以通過鼠標(biāo)按鈕將其設(shè)置為特定的鼠標(biāo)按鈕。筆配置線條本身的顏色,寬度,樣式和可見性,而“Enable Drawing/啟用繪圖”和“Enable Select/啟用選擇”分別啟用/禁用線條的繪制和選擇。
運行時:
在運行時添加繪制線工具是一項簡單的操作,如下例所示:
With TChart1 .Tools.Add tcDrawLine With .Tools.Items(0) .Active = True With .asDrawLine .Button = mbLeft .EnableDraw = True .EnableSelect = True .Series = 0 .Pen.Color = vbCyan End with End With End With
二、附加圖例工具
附加圖例工具允許在圖表畫布上的任何位置繪制完全可自定義的附加圖例。
設(shè)計時:
運行時:
附加圖例工具必須設(shè)置為特定系列才能顯示。該編輯圖例按鈕可以存取傳奇編輯器,允許附加的圖例的風(fēng)格,位置,標(biāo)志,格式,文本,漸變和陰影來進(jìn)行配置。
Private Sub Form_Load() With TChart1 .AddSeries scBar .Series(0).FillSampleValues 6 .AddSeries scBar .Series(1).FillSampleValues 6 .Legend.LegendStyle = lsValues .Environment.InternalRepaint .Tools.Add tcExtraLegend With .Tools.Items(0).asExtraLegend .Series = TChart1.Series(1) .Legend.CustomPosition = True .Legend.Left = TChart1.Legend.ShapeBounds.Left .Legend.Top = TChart1.Legend.ShapeBounds.Bottom + 10 End With End With End Sub
三、甘特拖動工具
甘特拖動工具可以拖動和/或調(diào)整甘特系列的條形。
設(shè)計時:
甘特拖曳工具必須設(shè)置為特定的甘特系列才能顯示。像素調(diào)整大小容差指定甘特圖欄移動/調(diào)整大小的像素的最小數(shù)量,允許拖動啟用/禁用甘特圖欄的拖動,允許調(diào)整大小啟用/禁用甘特圖欄的大小調(diào)整,而光標(biāo)設(shè)置將在各自的業(yè)務(wù)。
運行時:
在運行時添加額外的圖例工具是一項簡單的操作,如下例所示:
Private Sub Form_Load() TChart1.Aspect.View3D = False TChart1.AddSeries scGantt TChart1.Series(0).XValues.Order = loNone With TChart1.Series(0) .asGantt.AddGantt DateSerial(2017, 4, 1), DateSerial(2017, 4, 10), 0, "A" .asGantt.AddGantt DateSerial(2017, 4, 5), DateSerial(2017, 4, 15), 1, "B" .asGantt.AddGantt DateSerial(2017, 4, 2), DateSerial(2017, 4, 8), 2, "C" .asGantt.AddGantt DateSerial(2017, 4, 9), DateSerial(2017, 4, 21), 3, "D" .Marks.Visible = True .Marks.ShadowSize = 0 .Marks.Gradient.Visible = True End With TChart1.Axis.Bottom.SetMinMax DateSerial(2017, 4, 1), DateSerial(2017, 5, 1) TChart1.Axis.Left.SetMinMax -2, 5 TChart1.Axis.Left.GridCentered = False TChart1.Zoom.Enable = False TChart1.Axis.Bottom.Increment = TChart1.GetDateTimeStep(dtOneDay) TChart1.Axis.Bottom.Labels.Angle = 90 TChart1.Axis.Bottom.Labels.DateTimeFormat = "dd-mmm" TChart1.Tools.Add tcGantt TChart1.Tools.Items(0).asGantt.Series = TChart1.Series(0) TChart1.Tools.Items(0).Active = True End Sub Private Sub TChart1_OnGanttToolDragBar(ByVal Tool As Long, ByVal GanttBar As Long) With TChart1.Tools.Items(0).asGantt.Gantt Label1.Caption = FormatDateTime(.StartValues.Value(GanttBar)) + " - " + _ FormatDateTime(.EndValues.Value(GanttBar)) End With End Sub Private Sub TChart1_OnGanttToolResizeBar(ByVal Tool As Long, ByVal GanttBar As Long, ByVal BarPart As TeeChart.EGanttToolPartBar) With TChart1.Tools.Items(0).asGantt.Gantt Label1.Caption = FormatDateTime(.StartValues.Value(GanttBar)) + " - " + _ FormatDateTime(.EndValues.Value(GanttBar)) End With End Sub Private Sub TChart1_OnGetSeriesMark(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, MarkText As String) Select Case ValueIndex Case 0: MarkText = "John" Case 1: MarkText = "Ann" Case 2: MarkText = "David" Case 3: MarkText = "Carol" End Select End Sub Private Sub TChart1_OnMouseUp(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal x As Long, ByVal y As Long) Label1.Caption = "" End Sub
四、網(wǎng)格帶工具
網(wǎng)格帶工具為定義的軸的網(wǎng)格添加完全可配置的顏色帶。
設(shè)計時:
Grid Band Tool必須與指定的Axis相關(guān)聯(lián)。波段1和波段2定義兩個波段的筆刷特征,而背面定義背面顏色,通過波段是否具有圖案化筆刷來顯示。透明度設(shè)置每個相應(yīng)樂隊的透明度級別。
運行時:
在運行時添加網(wǎng)格帶工具是一項簡單的操作,如下例所示:
Private Sub Form_Load() With TChart1 .AddSeries scBar .Series(0).FillSampleValues 6 .Tools.Add tcGridBand With .Tools.Items(0).asGridBand .Axis = TChart1.Axis.Left .Band1.Color = vbGreen .Band2.Color = vbBlue End With End With End Sub
購買TeeChart Pro AciveX正版授權(quán),請點擊“咨詢在線客服”喲!