【TeeChart Pro ActiveX教程】(四):轴控制—关键领域

本文档详细介绍了TeeChart Pro ActiveX的轴控制功能,包括自动和手动设置轴刻度、增量、偏移,以及标题、标签格式、多行标签和自定义轴标签的设置。此外,还涵盖了对数标签、刻度和网格的调整,以及轴位置的改变等。
摘要由CSDN通过智能技术生成

下载TeeChart Pro ActiveX最新版本

TeeChart Pro将自动为您定义所有Axis标签,并提供足够的灵活性来定制您可能具有的任何特定要求。TeeChart Pro提供真正的多轴。它们可在设计或运行时使用,并为Axis定义提供无数可能性和灵活性。有关详细信息,请参阅本教程中的部分。

(一)Scales

将Series数据添加到图表时,会自动设置轴刻度。您可以使用Axis属性在设计时或运行时更改默认值。

teechart

非日期时间数据

添加新系列时,图表编辑器的“Axis”页面的“Scales”部分将显示“Automatic”和其他灰色选项。显示的所有值均为数字。

teechart

日期时间数据

当系列在系列,常规页面上将日期时间设置为true(对于该轴)时,图表编辑器的轴页面的“Scales”部分将显示“Automatic”和其他灰色显示的选项。值显示为日期时间值。

自动选择最佳轴刻度范围以适合您的数据。如果您打开自动关闭比例部分将ungrey选项,您可以更改轴值。重要的是,请记住从页面左侧的轴列表中选择要配置的轴。 将行系列添加到图表中添加一个命令按钮,其中包含以下代码:

Dim t As Integer
For t = 0 To 40
  With TChart1.Series(0)
    .Add CInt((Rnd) * t), "", vbRed
  End With
Next t

在按钮中运行代码将绘制一个包含40个随机值的Line Series。在设计时转到图表编辑器。在“Axis”页面的“Bottom Axis”部分中,将“Automatic”设置为“off”。您现在可以配置轴刻度的最大值和最小值。再次运行代码将显示值,具体取决于您为Axis配置的值。使用鼠标右键可以滚动查看剩余值。

按代码设置轴刻度

您可以使用以下代码更改运行时的最大值和最小值:

With TChart1.Axis.Bottom
  .Automatic = False
  .Maximum = 36
  .Minimum = 5
End With

您可以将Axis scale Maximum和Minimum设置为自动单独。例如:

With TChart1.Axis.Bottom
  .AutomaticMaximum = True
  .AutomaticMinimum = False
  .Minimum = 5
End With

偏移

您可以将轴设置为具有最小和最大比例的偏移(以像素为单位)。

TChart1.Axis.Left.MaximumOffset = 4 
TChart1.Axis.Left.MinimumOffset = 4

(二)Increment

您可以定制Axis的间隔。从Axis页面的Scales部分选择Desired Increment组合框,并添加所需的增量。您可以在运行时通过代码更改它:

With TChart1.Axis.Bottom
  .Increment = 20
End With

日期时间数据

如果您的数据是datetime(您可以通过转到Series,General页面将数据设置为系列的datetime),Chart,Axis页面,scales部分将显示日期时间范围。从Desired Increment组合框中显示的范围中选择增量。 添加一些示例数据

For t = 1 To 25
   With TChart1.Series(0)
       .AddXY DateValue("2017, 11, " & t), Rnd(t) * t, "", vbRed
   End With
Next t

在运行时更改增量:

With TChart1.Axis.Bottom
  .Increment = TChart1.GetDateTimeStep(dtTwoDays)
End With

注意

更改轴标签频率时,请记住TeeChart将根据LabelsSeparation属性的设置避免标签重叠。这意味着如果标签频率太高而不适合标签,那么TeeChart将分配“最适合”。更改标签角度和标签分离是2个选项,可帮助您安装所需的标签。

Titles

标题在Axis页面的标题部分中设置。您可以更改Axis及其字体的标题文本。该角度可以从值0,90,180,270度中选择。

Labels

有关标签属性的简历,请参阅AxisLabels类(IAxislabels接口)。

注意

更改轴标签频率时,请记住TeeChart将根据Labels.separation属性的设置避免标签重叠。这意味着如果标签频率太高而不适合标签,那么TeeChart将分配“最适合”。更改标签角度和标签分离是2个选项,可帮助您安装所需的标签。请参阅Labels.Angle属性。

标签格式

您可以将所有标准数字和日期格式应用于Axis标签。“Axis”页面的“Labels”部分包含“Values format”字段。如果您的数据是datetime,则字段名称将更改为“Date time format”。在编辑器中拖动帮助“?” 在该字段上的图标,以获得完整的选项列表。在运行时使用:

With TChart1.Axis.Bottom
  .Labels.ValueFormat = "#,##0.00;(#,##0.00)" 
End With

'or for datetime data

With TChart1.Axis.Bottom
  .Labels.DateTimeFormat = "dd/mmm/yy" 'Datetime
End With

MultiLine标签

轴标签可以显示为多行文本而不是单行文本。使用回车符ascii字符(#13)分隔行,例

//Add the Series labels in this way and apply 'Marks' as Axis labelling style
  TChart1.Series(0).Add 1234, "New"+chr$(13)+"cars", vbRed
  TChart1.Series(0).Add 2000, "Old"+chr$(13)+"bicycles", vbBlue 

DateTime标签的示例: 以下将在两行文本中显示底轴标签,一行显示月份和日期,第二行显示年份: 2月28日3月1日... 1999 1999 ..

TChart1.Series(0).AddXY DateValue("28,2,1999"), 100, "", clTeeColor
TChart1.Series(0).AddXY DateValue("1,3,1999"), 200, "", clTeeColor
TChart1.Series(0).AddXY DateValue("2,3,1999"), 150, "", clTeeColor
TChart1.Series(0).XValues.DateTime = True
TChart1.Axis.Bottom.Labels.DateTimeFormat = "mm/dd hh:mm" 'space 

如果将Labels.MultiLine属性设置为True,则轴将自动将标签拆分为找到空格的行。

TChart1.Axis.Bottom.Labels.MultiLine = True

将标签分为两部分:

'mm / dd'代表第二行 'hh:mm'代表第二行

在运行时,您始终可以使用OnGetAxisLabel事件以编程方式将标签拆分为行:

Private Sub TChart1_OnAfterDraw()
  TChart1.Axis.Left.Labels.TeeSplitInLines LabelText, " "
End Sub

全局“TeeSplitInLines”过程将“LabelText”中的所有空格转换为行分隔符(返回)。 轴标签。角度属性(标度旋转角度为0度,90度,180度或270度)也可用于多线轴标签。

自定义轴标签

可以使用Axis事件获得更多标签控件。事件允许您激活/停用/更改任何单个Axis标签。以下示例修改每个Label,将文本短语放在点索引值的前面。

'set LabelStyle to 'Mark' with the TChart editor or use:-
TChart1.Axis.Bottom.Labels.Style = talMark

'OnGetaxisLabel event
Private Sub TChart1_OnGetAxisLabel(ByVal aAxis As Long, ByVal SeriesIndex As Long, ByVal ValueIndex As Long, LabelText As String)
 If aAxis = atBottom Then
   LabelText = "Period " + Str(ValueIndex)
 End If
End Sub

可以使用自定义文本和格式在特定位置修改轴标签,而无需使用TeeChart事件,从而可以更轻松地在ASP方案中修改服务器端。

Private Sub Form_Load()
Dim v As Variant
  v = Array(200, 0, 123, 300, 260, -100, 650, 400)
  TChart1.AddSeries scLine
  TChart1.Series(0).AddArray 8, v
  AddCustomLabels
End Sub

Private Sub AddCustomLabels()
  TChart1.Axis.Left.Labels.Clear
  TChart1.Axis.Left.Labels.Add 123, "Hello"
  TChart1.Axis.Left.Labels.Item(0).Font.Size = 16
    
  TChart1.Axis.Left.Labels.Add 466, "Good" & Chr(13) & "Bye"
  TChart1.Axis.Left.Labels.Item(1).Transparent = False

  TChart1.Axis.Left.Labels.Add 300, ""
  
  TChart1.Axis.Left.Labels.Add -100, ""
  With TChart1.Axis.Left.Labels.Item(3)
    .Transparent = False
    .Transparency = 50
    .Color = vbBlue
  End With
End Sub

对数标签

正常对数标签可以通过以下方式设置:

With TChart1.Axis.Left
 .Logarithmic = True
 .Increment = 0 ' the default
 .SetMinMax 0, 10000
 .Labels.ValueFormat = "#e+0" ' exponential format
End With

标签将根据对数基数(默认为10)进行设置,因此,在此情况下,标签为1,10,100,1000,10000。

Ticks和Minor

teechart

有3种刻度类型和2种类型的网格。您可以更改每个刻度和网格类型的长度,宽度和颜色。可以通过«Ticks»选项卡对Ticks及其关联的Grid和Inner Ticks进行更改; 可以通过«Minor»选项卡更改Minor Ticks及其关联的Grid。

With TChart1.Axis.Bottom
  .TickLength = 7
  .Ticks.Color = vbGreen
  .MinorTickCount = 10 'change number of minorticks between (major) Ticks
End With

轴位置

轴具有修改每个轴所在位置的属性。在此示例中,轴移动了图表宽度的50%,因此它显示在图表中心:

TChart1.Axis.Left.PositionPercent = 50
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
=========================================== TeeChart Pro Activex Control v2018 MS .NET COMPATIBILITY Copyright (c) 1997-2018 by Steema Software SL All Rights Reserved. http://www.steema.com email: info@steema.com supportx@steema.com =========================================== Document updated: June 2004 TeeChart Pro Activex Control MS Visual Studio .NET compatibility notes =========================================== Please see the release.txt release notes for bugfix and feature information about this release. =========================================== Changes for NET compatibility - The Chart.Series(xx) read-only property has been replaced by a Function method (affects only code written in VC++ and similar languages that make direct reference to Get_ and Set_ of properties). The new Series method (called Series) changes visibly by removal of the property 'Get_' element of the Function. The change is required due to a current MS.NET import restriction causing non-import of ActiveX properties that have an index parameter (only affects the root level of controls !). For a VB application no code change is necessary. Please see the following notes for other environments. The original property has been hidden in the interface and renamed to aSeries keeping its existing Dispid to support backward compatibility with applications compiled with previous releases of TeeChart 5. - The TChart OnSeriesBeforeAdd method uses a boolean variable called 'Continue'. "continue" is a keyword in C# (the language used to interim compile TeeChart namespace information in .NET). This had caused an import problem with the earlier releases of Visual Studio .NET. As a precaution we have chosen to rename the parameter to 'MoreValues' for the TeeChart Pro ActiveX Control. Notes on use: ------------- - Constant names in NET require full reference by default: eg. AxTChart1.AddSeries(TeeChart.ESeriesClass.scLine) Upgrading existing projects: ---------------------------- Upgrading existing Visual Studio projects works without manual intervention in code for most simple projects. Notable points relating to import: VISUAL BASIC project: ===================== - Designtime saved content of a Chart does not always successfully import to a NET project. We recommend you open the project first in its current environment (eg. Visual Basic v6) and provoke a change in the Chart and resave the project. That will update the saved frx Chart information data to v5.0.3. Then save the Chart content as a tee file by right-clicking the Chart and selecting 'Export'. Some projects 'may' then import the saved Chart correctly without further steps required. If the Chart content doesn't import successfully then right-click on the Chart and import the saved tee file. If the project fails to import, clear the Chart content after saving it to tee (remove and replace the Chart with an empty one) and re-import following the above step to later import the saved tee file. - Calls to interfaces not supported. In Visual Studio v6 and prior versions, it was possible to connect components by interface. eg. TeeCommander.Chart=TChart1 This is no longer possible. You should use the integer link: eg. TeeCommander.ChartLink=TChart1.ChartLink - Colour definition requires update TeeChart colours map as UInt32 when imported to NET. The colour definition when applied takes the following form: .Labels.Font.Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Cyan)) - Some event syntax is incorrect on import. Notably the Mouse events which are 'duplicated' by default NET appointed events. If you find event syntax to be incorrect, modify the syntax as follows: eg. Private Sub TChart1_OnMouseUpEvent(ByVal eventSender As System.Object, _ ByVal eventArgs As AxTeeChart.ITChartEvents_OnMouseUpEvent) _ Handles TChart1.OnMouseUp 'do something End Sub - Some form object (eg. Checkbox) events may fire before the Chart is loaded. That didn't occur in VB6 and will require a workaround in VB.NET if Chart properties are referenced in this way at Form load. eg. taken from VB Drag Points example: 'Check1.CheckStateChanged may fire when form is intialized Private Sub Check1_CheckStateChanged(ByVal eventSender As System.Object, _ ByVal eventArgs As System.EventArgs) _ Handles Check1.CheckStateChan ' switch 2D / 3D view... TChart1.Aspect.View3D = Check1.CheckState ' enable scroll-bar only in 3D... HScroll1.Enabled = Check1.CheckState End Sub In the above event the View3D line will fail as the Chart isn't yet loaded when the event is called. An option to workaround it may be to set a boolean 'OK_To_Run' variable to set after the first Chart Repaint. eg. OK_To_Run false on load and set to true in Form_Load event after Chart is populated, etc. Private Sub Check1_CheckStateChanged(ByVal eventSender As System.Object, _ ByVal eventArgs As System.EventArgs) _ Handles Check1.CheckStateChan ' switch 2D / 3D view... If OK_To_Run = True Then TChart1.Aspect.View3D = Check1.CheckState End if ' enable scroll-bar only in 3D... HScroll1.Enabled = Check1.CheckState End Sub Microsoft recommend a similar step (add a IsInitializing property to the Form). We'll be taking a closer look at these issues to see if we can recommend less demanding steps to resolve them. VISUAL C++ project: ===================== The Series declaration has changed. The easiest way to upgrade the project is to import TeeChart classes before upgrading the project to .NET. 1. All references to 'GetSeries(xx)' should be changed to 'Series(xx)' That will call the new Series method that returns the Series Interface (just as the predecesor property did). The Series property has been name changed to aSeries, retaining its DispId to support existing compiled applications. 2. The following is handled automatically if you import the TeeChart classes. For reference, the following changes occur to the Series declaration. *Note you should not need to do anything if you import TeeChart to your project. a) In the TChart.h Class header file the GetSeries declaration changes to: CSeries Series(long SeriesIndex); b) In the TChart.cpp Class impl. file the GetSeries declaration changes to: CSeries CTChart::Series(long SeriesIndex) { LPDISPATCH pDispatch; static BYTE parms[] = VTS_I4; InvokeHelper(0x14, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch;, parms, SeriesIndex); return CSeries(pDispatch); } Projects should then compile without issue. =========================================== Use of Strong Named Assemblies =========================================== If you compile Strong Named Assemblies then imported ActiveX Controls must also be Strong Named. The Utilities folder contains a Strong Name compiled version of: \Utilities\VS.NET\Strong Named DLLs - AxInterop.TeeChart.dll - TeeChart.dll They may be used to replace the automatically generated AxInterop.TeeChart.dll and Interop.TeeChart.dll created when TeeChart AX is added to a Windows Form. You should remove auto-generated dlls from the references list in the project Solution Explorer and from the Obj folder of the project and Debug or Release Bin folder. Then copy in the new Dlls to Obj and Bin folders and reference the new Dlls from their Obj folder location. =========================================== Please send us details about any other issues found to: http://www.teechart.net/support/modules.php?name=Forums Many thanks ! =========================================== http://www.steema.com support: http://www.teechart.net/support/modules.php?name=Forums -------------------------------------------
=========================================== TeeChart Pro Activex Control v5 Copyright (c) 1997-2002 by David Berneda and Marc Meumann All Rights Reserved. http://www.steema.com email: info@steema.com supportx@steema.com =========================================== July 2002 TeeChart Pro Activex Control v5 v5.0.4.0 Release notes: ===================================== For information about differences and use of TeeChart Pro ActiveX v5 with respect to TeeChart Pro ActiveX v4 please refer to the 'Upgrading from TeeChart v4.doc' document accessible via the TeeChart Program Manager group. =========================================== Changes for this release: ------------------------- Bugs resolved: 1. Print Preview from TeeCommander for multi-page Charts in v5.0.3.x functioned incorrectly. Now resolved. 2. ZoomPen definition failed to save in tee files. Now resolved. 3. Integer overflow error reported after multiple zooms. Now resolved. 4. The property 'Controls' in TeeCommander coincides with a protected word in VBA. To permit access to this functionality in VBA the method has been duplicated with name 'Buttons'. 5. Omission in previous releases, the OffsetValues ValueList for Bar3D Series is accessible by code for this release. 6. Omission in previous releases, MACD function has new Period3 property. 7. Visual Studio.NET doesn't support the passing as Interface of the Chart to the TeePreviewPanel AddChart method. A substitute AddChartLink has been added for this release to accept ChartLink. 8. The keyword 'Months' as a database field name was incompatible with prior translation system for non-english language versions' db access via the Editor. Now resolved. 9. TeePolar/Radar Series problem when labelling datasets of 13, 19, 25, etc. values. Internal rounding error resolved. 10.Help button on Chart Editor not functioning. Now resolved. New features: 1.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值