Hide Comments
Hide Comments

Comments (0)

Implements a base chart function class that applies a function to an input SourceChart and adds values to a TargetChart.

The TRSCustomChartFunction class provides basic functions such as average, maximum, and minimum, and allows you to define a custom function. The function is applied over a Period of the SourceChart.

alert_cautionCaution

The TRSCustomChartFunction can accept any type of chart for its SourceChart and TargetChart. However, some combinations may be unpredicatable

ChartFunctionExample

Chart Function Example showing automatic generation of hourly High/Low/Average data from a Source Line chart to a High/Low/Average Target Chart.

Namespace: FMX.RS.ChartFunction

expandingInheritance Hierarchy

TComponent
  FMX.RS.ChartFunction.TRSFMXCustomChartFunction
    FMX.RS.BarCharts.TRSFMXHighLowAverageChartFunction
    FMX.RS.ChartFunction.TRSFMXChartFunction
 

expandingSyntax

Delphi

type
  TRSFMXCustomChartFunction = class(TComponent, IChartPanelListener)
  end;
 

expandingConstructors

 

Name

Description

public constructor

Create(TComponent)

Initializes a new instance of the TRSFMXCustomChartFunction class.

public destructor

Destroy

Represents the destructor of the TRSFMXCustomChartFunction class.

Top

expandingProperties

 

Name

Description

public property

CenterTimePeriod

Represents property CenterTimePeriod.

public property

Enabled

Controls whether the function class should execute. When Enabled is True, the PerformFunction method will be called every time the ValueChanged IChartPanelListener method executes.

public property

FunctionType

Defines the function to apply to the SourceChart to generate the TargetChart values

To define a custom function, set FunctionType to cftCustom and create an OnCustomFunction event handler

protected property

Modified

Represents property Modified.

public property

OnExecutedFunction

Use the OnExecutedFunction event for handling tear down or finalization code for your custom function. The occurs just after the function finishes executing but before the TargetChart's EndUpdate method is called.

noteNote

Unlike the OnCustomFunction, the OnExecutedFunction is only called once.

public property

OnExecutingFunction

Use the OnExecutingFunction event for handling setup or initialization code for your custom function. The occurs just  before the function starts executing but after the TargetChart's old values have been deleted.

noteNote

Unlike the OnCustomFunction, the OnExecutingFunction is only called once.

public property

Period

The Period and PeriodValue properties define the period for a function, i.e., over what time span or value range should the function be called. The Period divides the SourceChart values collection into chunks (usually based on a time span) and calls the FunctionType for every chunk.

The predefined period values (Second, Minute, Hour, ... Year) ignore the PeriodValue property.

noteNote

The predefined Period values (Second, Minute, Hour, ... Year) automatically divide the SourceChart into their time equivalents. Note that the time periods start at the beginning of the time unit until one millisecond before the beginning of the next time unit. For example, Minute divides a time period into 01:00.000 to 01:59.999.

public property

PeriodValue

The Period and PeriodValue properties define the period for a function, i.e., over what time span or value range should the function be called. The Period divides the SourceChart values collection into chunks (usually based on a time span) and calls the FunctionType for every chunk.

The PeriodValue may be a percentage (between 0 and 1) or an Index Range. For example, call the function for 25% (PeriodValue=0.25;Period=cfpPercentageCount) of the SourceChart values, or call the function for every 5 (PeriodValue=5;Period=cfpIndexRange) SourceChart values.
 

public property

SourceChart

Defines the input or source chart for the function. The function uses the SourceChart values to create values for the TargetChart

public property

SourceDim

Defines the input source dimension to apply the function on

public property

TargetChart

Defines the output or target chart for the function. The function transforms the input SourceChart values and adds values to the TargetChart

alert_cautionImportant Note

The old TargetChart values are deleted every time the function executes

public property

TargetDim

Defines the output target dimension to apply the function on

Top

expandingMethods

 

Name

Description

public methodClass member

AddValue(TRSCustomChart,TRSChartValueType,TDateTime,Integer)

Adds the specified TimeStamp and Value to the Chart. The TimeStamp is set to the TRSCustomChart.Values.TimeDimension in the Values property if present and Value to TRSCustomChart.Values.DefaultDimension

public methodClass member

Average(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the average of all values from IndexLow to IndexHigh in the SourceChart and returns the average

public methodClass member

Average(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the average of all values from IndexLow to IndexHigh in the SourceChart and adds the average to the TargetChart. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.

protected method

Changed

Represents method Changed.

public method

ChartAdded(TRSCustomChart)

IChartPanelListener interface method that occurs when a chart is added to a panel. It is ignored by the function class.

public method

ChartChanged(TRSCustomChart)

IChartPanelListener interface method that occurs when the SourceChart changes (e.g., Caption, Align, etc) . It is ignored by the function class.

public method

ChartDeleted(TRSCustomChart)

IChartPanelListener interface method that occurs when a chart is removed from a panel. It is ignored by the function class.

public methodClass member

Copy(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Represents method Copy(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer).

protected method

DoFunction

Represents method DoFunction.

public methodClass member

GetPeriodIndex(TRSCustomChart,Integer,TDateTime)

Returns the Source Chart Index for the end of the period defined by the StopTime from the LowIndex

public methodClass member

GreatestCommonDivisor(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the greatest common divisor (gcd) of the SourceChart Values and returns the value. The SourceChart Values are rounded into integers and the GCD calculated from this array. The GCD of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4.

public methodClass member

GreatestCommonDivisor(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded.  Calculates the greatest common divisor (gcd) of the SourceChart Values and adds the GCD to the TargetChart. The SourceChart Values are rounded into integers and the GCD calculated from this array. The GCD of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4.

If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.

public method

IsModified

Returns true if the SourceChart has been modified since the last time the chart has applied the function

public methodClass member

Maximum(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the maximum of all values from IndexLow to IndexHigh in the SourceChart and returns the maximum

public methodClass member

Maximum(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the maximum of all values from IndexLow to IndexHigh in the SourceChart and adds the maximum to the TargetChart. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.

public methodClass member

Median(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the median of all values from IndexLow to IndexHigh in the SourceChart and returns the median. The function also returns the timestamp of the median value if the SourceChart contains timestamps (SourceChart.Values.IsDateTime=True)

public methodClass member

Median(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the median of all values from IndexLow to IndexHigh in the SourceChart and adds the median to the TargetChart. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.

public methodClass member

Minimum(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the minimum of all values from IndexLow to IndexHigh in the SourceChart and returns the minimum

public methodClass member

Minimum(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the minimum of all values from IndexLow to IndexHigh in the SourceChart and adds the minimum to the TargetChart. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.

public methodClass member

Norm(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the Euclidean 'L-2' norm for the values in the SourceChart over the time period.

public methodClass member

Norm(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the Euclidean 'L-2' norm for the values in the SourceChart over the time period and adds the value to the TargetChart. The 'L-2' norm is the square root of the sum of squares. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.

protected method

Notification(TComponent,TOperation)

Represents method Notification(TComponent,TOperation).

public method

PanelChange

IChartPanelListener interface method that occurs when the panel changes. It is ignored by the function class.

public method

PerformFunction

Executes the function on the SourceChart and adds values to the TargetChart

noteNote

Note that the old TargetChart values are deleted

public methodClass member

PopnStdDev(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the population standard deviation (the square root of the population variance) of all values in the SourceChart over the time period.

public methodClass member

PopnStdDev(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the population standard deviation (the square root of the population variance) of all values in the SourceChart over the time period and adds the value to the TargetChart. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.
 

public methodClass member

PopnVariance(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the population variance of all values in the SourceChart over the time period, using the n method (biased): TotalVariance / n.

public methodClass member

PopnVariance(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the population variance of all values in the SourceChart over the time period and adds the value to the TargetChart, using the n method (biased): TotalVariance / n. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.
 

public method

SelectionChanged(TObject)

IChartPanelListener interface method that occurs when the SourceChart's value is selected or deselected. It is ignored by the function class.

protected method

SetFunction

Represents method SetFunction.

public methodClass member

StdDev(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the sample standard deviation (the square root of the sample variance) of all SourceChart's values over the time period.

public methodClass member

StdDev(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the sample standard deviation (the square root of the sample variance) of all SourceChart's values over the time period and adds the value to the TargetChart. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.

public methodClass member

Sum(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the sum of all values from IndexLow to IndexHigh in the SourceChart and returns the sum

public methodClass member

Sum(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the sum of all values from IndexLow to IndexHigh in the SourceChart and adds the sum to the TargetChart. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.

public methodClass member

SumOfSquares(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the sum of the squares of the SourceChart values over the time period: Data[0]^2 + Data[1]^2 + Data[2]^2....

public methodClass member

SumOfSquares(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the sum of the squares of the SourceChart values over the time period: Data[0]^2 + Data[1]^2 + Data[2]^2...and adds the value to the TargetChart. If the TargetChart
is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.
 

public methodClass member

ToArray(TRSCustomChart,Integer,Integer,Integer)

Creates a TRSChartValueTypeArray of all the Values in the Chart from IndexLow to IndexHigh for the specified dimension

public methodClass member

TotalVariance(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the sum of the squares of the difference between each SourceChart value and the mean of the SourceChart values over the time period.

public methodClass member

TotalVariance(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the sum of the squares of the difference between each SourceChart value and the mean of the SourceChart values over the time period and adds the value to the TargetChart. If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.
 

public method

ValueChanged(TRSCustomChart,TRSChartValue)

IChartPanelListener interface method that occurs when the SourceChart's value is changed. If the function class is Enabled, new values are generated for the TargetChart.

public methodClass member

Variance(TRSCustomChart,Integer,Integer,TDateTime,Integer)

Overloaded. Calculates the sample variance of all values in the SourceChart over the time period, using the n-1 method (unbiased).

public methodClass member

Variance(TRSCustomChart,TRSCustomChart,Integer,Integer,TDateTime,Integer,Integer)

Overloaded. Calculates the sample variance of all values in the SourceChart over the time period and adds the value to the TargetChart, using the n-1 method (unbiased). If the TargetChart is of a type that has more than 2 dimensions, such as a TRSLineChart with X and Y values, the new TargetChart value includes the TimeStamp.
 

public method

VisibleChanged(TObject)

IChartPanelListener interface method that occurs when the SourceChart's or value's visibility is changed. It is ignored by the function class.

Top

expandingEvents

 

Name

Description

protected event

ChartFunction

Represents property ChartFunction.

public event

OnCustomFunction

Create an OnCustomFunction event handler to write your own functions. Note that the OnCustomFunction event handler is called for every Period in the SourceChart.

You only need to write the function itself and for adding value(s) to the TargetChart. The TRSCustomChartFunction class does all the housekeeping necessary for preparing the TargetChart (e.g., calling BeginUpdate/EndUpdate, clearing values)

noteNote

The OnCustomFunction event is only called if the FunctionType is cftCustom.

Top

expandingRemarks

The TRSCustomChartFunction class acts as a IChartPanelListener for the SourceChart. Every time the SourceChart fires a ValueChanged event, the class executes its function (if the Enabled property is true). For efficiency, you can turn off the Enabled property temporarily or make sure that you wrap changes to the SourceChart with BeginUpdate/EndUpdate.

expandingExamples

To set up a function at design-time:

Drop a chart onto your form and set it up as your SourceChart. Write code to populate the SourceChart.

Note that it is recommended you wrap adding values to the chart with Values.BeginUpdate and Values.EndUpdate)

Drop another chart onto your form. This will be your TargetChart
Drop a TRSChartFunction component on your form
Set RSChartFunction1.SourceChart to your first chart above
Set RSChartFunction1.TargetChart to your second chart above
Set TRSChartFunction Period and optionally PeriodValue
Set RSChartFunction1.FunctionType
(Optional) If you wish to create a custom function, set RSChartFunction1.FunctionType to cftCustom and write an OnCustomFunction event handler

To set up a function at run-time:

Delphi

RSChartFunction1 := TRSChartFunction.Create(Self);
 RSChartFunction1.SourceChart := RSLineChart1;
 RSChartFunction1.PeriodValue := 0.25;
 RSChartFunction1.Period := cfpPercentageCount;
 RSChartFunction1.FunctionType := cftMaximum; 

expandingSee Also

Comments (0)

RiverSoftAVG Charting Component Suite (RCCS) © 2005-2015, Thomas G. Grubb