TChartSeries.DataSource
TChartSeries
property DataSource: TComponent;
Unit
TeEngine
Description
A TChartSeries can be optionally connected to a "point data provider" (or DataSource).
The "point provider" (or DataSource) component can be:
1) Another Chart Series (single or TChartSeries.DataSources).
2) Any TTable, TQuery, TClientDataset or Delphi/C++Builder database derived dataset class.
3) A TTeeSeriesSource derived class, like TTeeXMLSource component.
Points must be TChartSeries.Add by coding if no DataSource component is specified.
Example:
This example shows how to connect a Series to a Table database component using DataSource property
procedure TForm1.Button1Click(Sender: TObject);
begin
// All of this can be done VISUALLY, using the Chart Editor Dialog:
// Do these 4 steps before:
// 1) Place a TDBChart component and a TTable on the Form.
// 2) Add a TBarSeries to DBChart1.
// 3) Set Table1 to point to DBDEMOS database and ANIMALS table.
// 4) Open Table1, setting Table1.Active to True.
Series1.DataSource:=Table1; // <-- the Table component
Series1.YValues.ValueSource:='WEIGHT'; // <-- the Field for Bar Values
Series1.XLabelsSource:='NAME'; // <-- the Field for Bar Labels
end;
Points must be manually added by coding if no DataSource component is specified.
Example of manual point adding:
begin
Series1.Clear;
for t := 1 to 12 do
Series1.Add( Random(1000), LongMonthNames[t]);
end;