【TeeChart Pro ActiveX教程】(七):使用函数(下)

下载TeeChart Pro ActiveX最新版本

在上一篇文章中,我们介绍到了在Teechart Pro ActiveX中的功能特点和添加功能,今天我们接着讲定义数据源、功能期间和周期样式

(一)定义数据源

上一节中的示例重点介绍如何使用Datasource通过代码填充Function.Series使用datasource定义Function的输入或定义Series ODBC数据源(请参阅有关访问数据库的教程)。

使用图表编辑器,在添加函数后,函数系列的“数据源”页面将显示包含在函数定义中的可用系列列表。在这里,您可以更改要应用于系列的函数类型,并从左侧列表框“Available”中选择系列,并将它们添加到右侧列表框“Selected”。

按代码的数据源使用Series.Datasource属性。

例:假设我们在图表中有2个数据系列。我们添加了一个由2系列的平均值组成的函数:

With TChart1
  .AddSeries scLine
  'Define the Function Type for the new Series
  .Series(2).SetFunction tfAverage
  .Series(2).DataSource = "Series0,Series1"
End With

我们为2系列添加点数:

Dim t As Integer
With TChart1
  For t = 0 To 10
    .Series(0).Add 2 * t, "", clTeeColor
    .Series(1).Add 3 * t, "", clTeeColor
  Next t
End With

请注意,该功能不会显示。您需要使用Series.CheckDatasource方法读取Function的值。

TChart1.Series(2).CheckDataSource
'Read in data for Function

可以使用Setfunction方法在运行时更改函数定义,以便为Series分配新函数。

TChart1.Series(2).Setfunction tfMovavg

使用上面的代码行,Setfunction将Series(2)的Function更改为Moving Moving。

(二)功能期

Period是使用函数的重要属性,因为Period定义了循环应用Function的点的范围。

例:我们有6个数据点(例如Bar系列的条形图),其值为: 3,8,6,2,9和12

我们定义一个具有周期0的函数系列(默认),绘制的平均值为: 6.667

将Period设置为2,我们得到3个平均值作为函数的输出: 5.5,4和10.5

这些值将在其周期范围中集中绘制,即输入系列的第1和第2列之间的第1个值,第3个和第4个条之间的第2个值等。 您可以通过在“Datasource”页面中选择相关的“Series和Function”并单击“Options”选项卡来定义“Period”,也可以使用“FunctionType”在运行时修改“Period”。 例如,系列2是功能系列:

teechart

周期样式

期间可以定义为范围。这在使用Date-Time系列时非常有用,并且想要在“OneMonth”或“OneDay”等日期时间步骤中表达函数的“Period”。属性“PeriodStyle”控制如何表达“Period”。 例如,您现在可以使用日期时间源系列上的常规“Average”功能绘制“monthly average of sales\月平均销售额”功能,并将功能期间设置为“one month”:

'Add a Series and fill it with datetime data values at runtime (or from a database)

TChart1.Series(1).SetFunction tfAverage
TChart1.Series(1).FunctionType.PeriodStyle =psRange
TChart1.Series(1).FunctionType.Period = TChart1.GetDateTimeStep dtOneMonth 
TChart1.Series(1).DataSource = "Series0"

这将产生几个点,每个点显示Series0中每个月数据的“Average”。 在计算日期时间段的函数时,必须按源日期对源Series0中的点进行排序。 该范围也可用于非日期时间序列:

TChart1.Series(1).SetFunction tfAverage
TChart1.Series(1).FunctionType.PeriodStyle =psRange
TChart1.Series(1).FunctionType.Period=100
TChart1.Series(1).DataSource= "Series0"

这将计算每个“100”间隔内每组点的平均值。 ( X > = 0,X < 100的点将用于计算第一个平均值,X> = 100的点,X < 200将用于计算第二个平均值,依此类推......)。 请注意,这与计算每100个点的平均值不同。 使用“Period Alignment”属性可以对齐“Series”范围内的功能点。以下将绘制每月结束时的功能点:

TChart1.Series(1).FunctionType.PeriodStyle = psRange
TChart1.Series(1).FunctionType.Period = TChart1.GetDateTimeStep dtOneMonth
TChart1.Series(1).FunctionType.PeriodAlign =paLast

PeriodStyle = OneMonth and PeriodAlign = paLast

从下图中可以看出,“average”是在月底绘制的。

teechart

PeriodStyle = OneMonth and PeriodAlign = paFirst

在这种情况下,“average”在月初绘制。

teechart

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
=========================================== 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、付费专栏及课程。

余额充值