zoukankan      html  css  js  c++  java
  • TeeChart Pro VCL/FMX教程之使用函数

      函数类型

      函数特点

      TeeChart Pro功能是一个系列,几乎可以是任何系列类型,应用代数函数,数据源是另一个图表系列。

      所有函数都派生自TTeeFunction组件并继承TeeFunction的Period属性。

      TeeChart Pro包含以下预定义功能列表。有关所有功能类型的完整列表,请参阅TeeChart Editor Gallery和Helpfile:

      函数类别导入数量描述

      Add无限绘制输入的总和

      Average无限平均函数将计算每组Period点的平均值

      Bollinger1布林线函数使用简单或指数移动平均线来构建布林线交易区间

      Copy1输入系列的直接副本

      Curve Fitting1使用TypeFitting公式通过数据输入绘制拟合多项式

      Divide无限分割函数绘制输入按包含的降序划

      Exponential Average1基于权重的指数平均值

      Exponential Moving Average1基于权重的指数移动平均线

      Exponential Trend1通过输入系列中的点绘制最佳指数趋势

      High无限高功能绘制高输入点

      Low无限低功能绘制低输入点

      MACD1移动平均收敛分歧

      Momentum1每个Y值是当前点的Y值减去最后一个Period点的Y值

      Momentum Division1每个Y值是当前点的Y值除以最后一个Period点的YValue,以百分比表示

      Moving Average1移动平均线功能将计算每组周期点的简单或加权平均值

      Multiply无限乘法函数绘制输入值的乘积

      Root Mean Square无限均方根函数绘制输入的RMS值

      Relative Strength Index1RSI函数根据财务数据计算百分比值。根据TRSISyle类型,将使用不同的公式来计算RSI值

      Standard Deviation1映射每组Period点的标准偏差(或完全标准差)

      Stochastic1

      Subtract无限绘图的输入值按包含的降序减去

      Trend1通过输入系列点绘制最佳趋势线

      多种函数类型仅支持一个输入系列。但是,可以链接链接函数,例如,将图表中多个系列的平均值创建为平均函数系列,然后使用平均函数作为趋势函数的输入来标识平均值的趋势。

      添加函数

      使用图表编辑器,在“第一个图表”页面上,选择“ 添加”按钮,就像将新系列添加到图表一样。在TeeChart Gallery中,选择Functions选项卡以选择所需的功能。每个功能都显示为一个系列,您可以稍后通过选择第一个图表页面上的更改按钮来更改与该功能关联的系列类型。之后,在函数系列的“数据源”页面上可以轻松更改函数定义。在这里,同样容易,您可以将已添加到Chart的正常Series的定义更改为Function的定义(Function实际上是数据源的定义,而不是Series Type的定义)。

      下图显示了编辑函数时的“数据源”页面。线系列(名称“Series2”,标题“平均”)被定义。数据源页面底部的左侧列表框显示了可用于输入的图表中的其他系列(此处为“Series1”)。

      假设我们从一个完全空的Chart开始,这里是代码中构建一个简单的Series-Function相关Chart的步骤。

      procedure TForm1.BitBtn5Click(Sender: TObject);

      var tmpBarSeries1,

      tmpBarSeries2 : TBarSeries;

      tmpLineSeries : TLineSeries;

      begin

      //Add 2 data Series

      tmpBarSeries1:=TBarSeries.Create(Self);

      tmpBarSeries2:=TBarSeries.Create(Self);

      AddSeries(tmpBarSeries1);

      AddSeries(tmpBarSeries2);

      //Populate them with data (here random)

      tmpBarSeries1.FillSampleValues(10);

      tmpBarSeries2.FillSampleValues(10);

      //Add a series to be used for an Average Function

      tmpLineSeries:=TLineSeries.Create(Self);

      AddSeries(tmpLineSeries);

      //Define the Function Type for the new Series

      tmpLineSeries.SetFunction(TAverageTeeFunction.Create(Self));

      //Define the Datasource for the new Function Series

      //Datasource accepts the Series titles of the other 2 Series

      tmpLineSeries.DataSources.Clear;

      tmpLineSeries.DataSources.Add( tmpBarSeries1 );

      tmpLineSeries.DataSources.Add( tmpBarSeries2 );

      // *Note - When populating your input Series manually you will need to

      // use the Checkdatasource method

      // - See the section entitled 'Defining a Datasource'

      //Change the Period of the Function so that it groups averages

      //every 2 Points

      tmpLineSeries.FunctionType.Period := 2;

      end;

      我们可以添加另一个函数来告诉我们有关前一个函数的信息

      procedure TForm1.BitBtn6Click(Sender: TObject);

      var tmpHighLine : TLineSeries;

      begin 无锡妇科医院哪家好 http://www.xasgyy.net/

      //Add another Series to be used for a 2nd Function

      tmpHighLine:=TLineSeries.Create(Self);

      AddSeries(tmpHighLine);

      //Define the Function Type for the new Series

      tmpHighLine.SetFunction(THighTeeFunction.Create(self));

      //Define the Datasource for the new Function Series

      //Use the existing Function (tmpLineSeries) as input

      //You should declare tmpLineSeries globally to the module

      //if you wish to use it between procedures

      tmpHighLine.DataSource := tmpLineSeries;

      //Leave the Period at default 0 (No Period set) to draw

      //A line at Highest of all points of the Average Function

      end;

      定义数据源

      上一节中的示例重点介绍了使用Datasource按代码对函数进行内容处理。Series使用Datasource定义Function的输入或定义Series TDataset数据源(请参阅有关访问数据库的教程)。

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

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

      假设我们在图表中有2个数据系列。我们使用图表编辑器添加由2系列的平均值组成的函数:

      我们为2系列添加点数:

      var t : Integer;

      For t := 0 To 10 do

      begin

      Series1.Add(2 * t);

      Series2.Add(3 * t);

      end;

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

      Series3.CheckDataSource; //Read in data for Function

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

      Series3.Setfunction(TMovingAverageFunction.Create(self));

      使用上面的代码行,Setfunction将Series3的Function更改为Moving Moving。

  • 相关阅读:
    php入门到精通(复习笔记)
    MySQL的基础(优化)3
    php之Apache压力测试
    DOS下常用命令
    php连接MySQL分析
    php-memcached详解
    php 四种基本排序算法
    MySQL的基础(优化)2
    SQL入门之集合操作
    SQL入门之多表查询
  • 原文地址:https://www.cnblogs.com/djw12333/p/10958713.html
Copyright © 2011-2022 走看看