TeeChart Pro VCL / FMX tutorial (VII): Using the function (a)

Download TeeChart Pro VCL / FMX latest version

    Has joined the online ordering, buying now can stand to enjoy special offers! ! !

Function Type

Function Features

    TeeChart Pro function is a series, the series can be almost any type of algebraic functions, the data source is a graph of another series.

    All functions are derived from TTeeFunction components and inherit property TeeFunction the Period.

    TeeChart Pro includes the following predefined list of features. For a complete list of all types of functions, see TeeChart Editor Gallery and Helpfile:

Function category

Import Quantity

description

Add unlimited The sum of the drawing input
Average unlimited The averaging function calculates the average of each point Period
Bollinger 1 Bollinger using simple function or exponential moving average trading range constructed Bollinger
Copy 1 Direct copy of the input series
Curve Fitting 1 Use TypeFitting formula drawing data input by polynomial fitting
Divide unlimited

 

The partition function of drawing input stroke contained in descending order

Exponential Average 1 Weight-based index average
Exponential Moving Average 1 Weighted moving average based index
Exponential Trend 1

Draw the best exponential trend by entering a series of points

High unlimited High-performance rendering high input points
Low unlimited Low input function draw low point
MACD 1 Moving average convergence divergence
Momentum 1 Each value is the current Y Y Y minus the value of the point value of the last point of a Period
Momentum Division 1 Each Y value is divided by the Y value of the current point of Period YValue last point, expressed as a percentage
Moving Average 1 Moving average calculating function simple or weighted average of each point period
Multiply unlimited

Multiplication product of the input value is plotted as a function

Root Mean Square unlimited Plotted as a function of input RMS value RMS
Relative Strength Index 1 RSI function calculates a percentage value based on the financial data. The TRSISyle type, using a different formula to calculate the value of RSI
Standard Deviation 1 Period standard deviation mapping each point (or completely standard deviation)
Stochastic 1
Subtract unlimited Mapping the input values ​​in descending order comprises subtracting
Trend 1 Best trend line drawn through the series input point

    Multiple function type supports only one input series. However, you can link link function, for example, will create a chart in the average number of series for the average family of functions, then use the average function to identify trends in the average trend as an input function.

Add Function

    Use the diagram editor, in & ldquo; the first chart & rdquo; page, select & ldquo; Add & rdquo; button, just add a new series to chart the same. In TeeChart Gallery, select the Functions tab to select the desired function. Each function is shown as a series, you can select the Change button on the first page later to change the chart type series associated with the function. After that, the family of functions of & ldquo; data source & rdquo; you can easily change the function definition page. Here, just as easily, you can have added to the definition of normal Series of Chart Change Function definition (Function is actually defined data source, rather than defining the Series Type).

The following figure shows the time of editing function & ldquo; data source & rdquo; page. Series line (name & ldquo; Series2 & rdquo ;, the title & ldquo; average & rdquo;) is defined. Box at the bottom left of the list page displays the data sources can be used to chart the other series input (here, the & ldquo; Series1 & rdquo;).

Teechart

Suppose we Chart from the start of a completely empty, where the code is constructed in a simple Series-Function Chart related steps.

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
   //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;

定义数据源

    Focus on an example of use described by Datasource content processing function code. Series use Datasource defined Function input or definitions Series TDataset data source (see Tutorial on accessing the database).

    Use diagram editor, after adding function, the function of the series of "Data Source" page included in the list of available series function definition. Here, you can change the function of the type of series you want to apply, and "available" in select series and add them to the right list box "Selected" from the left list box;.

    Series.Datasource attribute data used by the source code.

    Suppose we have two data series in the chart. We use the chart editor to add a function by the average of the two series consisting of:

    We add 2 Series Points:

var t : Integer;

For t := 0 To 10 do
begin
  Series1.Add(2 * t);  
  Series2.Add(3 * t);
end;

Please note that this feature will not be displayed. You need to use Series.CheckDatasource method to read the value of Function.

Series3.CheckDataSource; //Read in data for Function

You can change the function definition at runtime using Setfunction method to assign a new function for the Series.

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

Using the above line of code, Setfunction Series3 will change the Function to Moving Moving.

To be continued ...

Buy TeeChart Pro VCL / FMX genuine authority, please click on " contact customer service online " yo!


Guess you like

Origin blog.51cto.com/14257124/2402049