ISeries.DataSource
ISeries
property DataSource: OleVariant;
Type Library
TeeChartx
Description
Any Series can be optionally connected to a "point provider" (or DataSource). The "point provider" (or DataSource) can be:
1) Another Chart Series.
2) Any OLE DB or ODBC Table or Query (via ADO).
Points must be manually added by coding if no DataSource class is specified.
Please refer to Line, Bar, Point, Area, Bubble, Gantt,
DataSource property Example
This example shows how to connect a Series to an OLE DB or ODBC Table using the DataSource property. All that is demonstrated here by code can be done VISUALLY, using the Chart Editor Dialog.
By code, to add an OLE DB or ODBC datasource to a Series:
1) Have a DSN defined.
2) Add a Bar Series to TChart.
Visual Basic
With TChart1.Series (0)
.DataSource = "DSN=SQLSource; TABLE=DOLLAR"
.YValues.ValueSource = "WEIGHT"
' -- Where WEIGHT is the Field for Bar Values
.LabelsSource:="NAME" '--Where NAME is the Field for Bar Labels }
End with
This example shows how to connect a Series to another Series using the DataSource property.
TChart1.Series(2).DataSource = "Series1"
'-- Where "Series1" is the name of another Series in your Form
Note
Don't confuse Series1 with Series(1). Series0 is the default name given to the first Series on a form and would be accessible by index (0) eg. TChart1.Series(0) but you may change the names of Series by using the Series.Title property, Thus Series(0) could be entitled "MySeries" which is the name that should be used for the Datasource if it should be included as datasource for another Series.
More than one Series at a time may be accessed by the Datasource property:
TChart1.Series(1).DataSource = "Series0, Series2, Series3"
To allow definition of multiple Series input Function for Series(1).
Points must be manually added by coding if no DataSource class is specified. See Series.Add(), AddXY(), AddNull() and AddNullXY().
Refreshing Recordset data
In this case, when datasourcing to a Recordset you'll need to reset the Datasource property when modifying the Recordset.
eg.
Code (Visual Basic):
Private Sub AddPoint(DT As Date, Value As Double)
rs.AddNew
rs(DField) = DT
rs(VField) = Value
rs.Update
TChart1.Series(0).DataSource = rs
End Sub