Tutorial 1 - Getting started |
Contents page Next |
Introduction to building Charts and populating Data Series by code or by Dataset access
![]() Everything comes together to make the final Chart, with Chart axes being the interface between Chart and Series. A Series has data and its values will influence the label characteristics of the Chart axes. The axes appearance, colours, grid frequency and label fonts may all be defined for the Chart before adding data Series. TeeChart will make a best estimate of most values to minimise the need for you to manually define Chart and Series properties. |
Add multiple series types with the Chart editor The "Chart distinct from Series" design paradigm of TeeChart allows you to mix a variety of Series types without being limited to a choice of predefined Chart formats. |
![]() |
In addition TeeChart Pro installs 2 more Chart icons:
TDBChart in the Data Controls section TDBChart uses the Borland Database Engine.If you are coding Chart data use TChart. |
TQRChart in the QuickReport section |
For a list of other TeeChart installed components follow this link: Non Chart components
Select the first icon of the three and click and drag out to size TChart on a Form. You will see TChart as a panel with some basic Chart features such as Axis and Title. TeeChart is derived from a Delphi TPanel, you could use the Chart Editor to delete the existing visual features and you would be left with a perfectly servicable 3D panel complete with Border and Bevel properties ! We hope you'll want to use it for more than that though ! Right click on the new TChart and you will see a menu displayed. Select the Properties option to access the Chart Editor. (Double-mouseclicking on the Chart will achieve the same goal).
To add a new Series, mouseclick on the Add.. button and select the Series type from the Series Gallery. If, after selecting a Series type now, you wish to change it later you may do so (with a few exceptions where Series data content may be incompatible) by returning to the first Editor screen and selecting the Change.. button.
Standard Series
Functions
Extended Series
Sample Series
Coding data input with TChart
For programmed input of data you will need to write some code. If you are coding data input the use TChart rather than TDBChart to avoid needing the Borland Database Engine. This section will show you the steps necessary to build a chart with coded input.With Series1 do begin Add (3, 'Pears', clRed); Add (4, 'Apples', clBlue); Add (2, 'Oranges', clGreen); end;
The Series' Add method accepts 3 variables, Value, Label and Colour. The Add method thus assumes equal spacing of values on the Label axis (in this case the X-Axis). If your data contains 2 variables you may use the AddXY Method. Add another Command button to your project and put this code in it. Run the Project and add points using this code:
With Series1 do begin If Count > 0 Then //Increment X Axis value and add a new random point AddXY (XValues.Last+(Round(100)), (YValues.Last/YValues.Last-1)+(Round(100)), '', clBlue) Else //Add a new random point AddXY (1, (Round(100)), '', vbBlue); end;
Series Type |
No. of variables |
Datasource Properties |
Basic |
||
2 |
XValues, YValues, XLabel |
|
2 |
XValues, YValues, XLabel |
|
2 |
XValues, YValues (called Bar), XLabel |
|
2 |
XValues, YValues (called Bar), XLabel |
|
2 |
XValues, YValues, XLabel |
|
2 |
Xvalues, YValues, XLabel |
|
1 |
PieValues, XLabel |
|
4 |
StartXValues, StartYValues, XLabel, EndXValues, EndYValues |
|
3 |
Xvalues, YValues, XLabel, RadiusValues |
|
3 |
StartValues, EndValues, AY (Y axis level), AXLabel (Label optionally shown on Y-axis or as mark) |
|
4 |
X0 (Top), Y0 (Bottom), X1 (Left), Y1 (Right) |
|
Extended |
||
2 |
XValues, YValues, XLabel |
|
5 |
OpenValues, CloseValues, HighValues, LowValues, DateValues |
|
3 |
XValues, YValues, XLabel, ZValues |
|
3 |
XValues, YValues, XLabel, ErrorValues |
|
3 |
XValues, YValues, XLabel, ZValues |
|
2 |
XValues, YValues, Labels (Polar has Angle and Radius) |
|
2 |
XValues, YValues, Labels (Radar has Angle and Radius) |
|
3 |
XValues, YValues, ZValues |
|
2 |
XValues, YValues (VolumeValues), XLabel |
Accessing datasources with TDBChart
If your data is from a Delphi TDataset, TTable, TQuery or TClientDataset then you may map your data directly in the Chart editor. Place any one of these components on your Form. TDBChart does not need a Datasource component to access one of these TDataset components.
Select Datasource from the dropdown listbox on the Data Source page. The Datasource characteristics fields will activate on the page. Select the Dataset: Listbox to add a new Data source for the Series.
You may select an existing datasource (TTable, TQuery, etc) for the Series from Datasource drop-down combo box. When you have selected the datasource TeeChart will automatically populate the Chart with the data it finds in the Dataset.
According to the table above which shows what Series Types require which values, you may add the columns of the Dataset to the 'Labels', X and Y fields. If your data only has Labels and Y values (the X values are index 1, 2 ,3, etc.) you are only required to populate 'Labels' and 'Y' values.
The dataset data will show in design time and when you run the application the data will automatically populate the Chart at runtime.
TeeChart Pro version 4 includes several non-Chart components that may be used to enhance the functionality or appearance of your Charting application. You can find these components in the TeeChart section of the component palette. Select a button from the following list to obtain the helpfile description:
![]() |