m_Chart1.Series(0).SetFunction(tfMovavg);
m_Chart1.Series(0).GetFunctionType().SetPeriod(4.0);
m_Chart1.Series(0).SetDataSource(COleVariant("YValues"));
OK that compiles.
How is it used ?
Once every second this is called to update the chart, but where/when is the
moving average implemented ?
m_Chart1.Series(0).AddArray( 4096, YValues, XValues); // update
Everything I've tried to date and no moving average !
The help files(tutorial) imply it all just happens ! But it does not...
Moving Average Function does not appear to work !
Hi Hans,
have you read the TeeChart Pro Tutorials ( 7 .- Working with functions ) ?
(From the Tutorial ) :
Assuming we start with a completely empty Chart here are the steps in code to build a simple Series-Function related Chart.
One example could be :
With TChart1
'Add 2 data Series
.AddSeries scBar
.AddSeries scBar
' Populate them with data (here random)
.Series(0).FillSampleValues 10
.Series(1).FillSampleValues 10
' Add a series to be used for an Average Function
.AddSeries scLine
'Define the Function Type for the new Series
.Series(2).SetFunction tfAverage
'Define the Datasource for the new Function Series
'Datasource accepts the Series titles of the other 2 Series
.Series(2).DataSource = "Series0,Series1"
' *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
.Series(2).FunctionType.Period = 2
End With
> Once every second this is called to update the chart, but where/when is the> moving average implemented ?
(From Tutorial) :
Notice that the Function doesn't display. You need to use the Series.CheckDatasource method to read in values for the Function.TChart1.Series(2).CheckDataSource
So, in your case you should create first a Series and populate it with the data and then add one more series, set it as as Function, set the DataSource, Period,.. and then call the CheckDataSource method.
Josep Lluis Jorge
http://support.steema.com
have you read the TeeChart Pro Tutorials ( 7 .- Working with functions ) ?
(From the Tutorial ) :
Assuming we start with a completely empty Chart here are the steps in code to build a simple Series-Function related Chart.
One example could be :
With TChart1
'Add 2 data Series
.AddSeries scBar
.AddSeries scBar
' Populate them with data (here random)
.Series(0).FillSampleValues 10
.Series(1).FillSampleValues 10
' Add a series to be used for an Average Function
.AddSeries scLine
'Define the Function Type for the new Series
.Series(2).SetFunction tfAverage
'Define the Datasource for the new Function Series
'Datasource accepts the Series titles of the other 2 Series
.Series(2).DataSource = "Series0,Series1"
' *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
.Series(2).FunctionType.Period = 2
End With
> Once every second this is called to update the chart, but where/when is the> moving average implemented ?
(From Tutorial) :
Notice that the Function doesn't display. You need to use the Series.CheckDatasource method to read in values for the Function.TChart1.Series(2).CheckDataSource
So, in your case you should create first a Series and populate it with the data and then add one more series, set it as as Function, set the DataSource, Period,.. and then call the CheckDataSource method.
Josep Lluis Jorge
http://support.steema.com