Download Welcome to TeeChart Pro version 3 - Activex Control

Transcript
20
Compile your project. The project should compile to show you an empty chart. The
random values don’t work at runtime so the next step is to go back to the chart editor
and add a data source or write your own code to add data values.
Edit the Series
Selecting the Series tab allows you to edit your Series. The next step is to add data to
the Series. The steps necessary to include the data for the Series vary slightly
depending on whether you are going to program your data input or if you wish to access
an ODBC datasource directly. See the following 2 sections:
Programmatically adding data to a Series for a description on how to
programmatically add data to a TChart Series.
Configuring an ODBC datasource for a Series describes the actions necessary to
add an ODBC datasource to a TChart Series.
Programmatically adding data to a Series
We have a TChart on the form and have added a Series to it. We are ready to populate
the Series.
Let’s type some code to add points values programmatically.
We'll see later how to create a database-aware Chart with automatic record retrieval.
Example Pie-Series
Suppose the Series we added were a Pie Series. We could populate the Series in the
following way. For the following code to work we should leave the Series name as its
default of Series1.
Visual Basic
Place a CommandButton on your Form and go to the OnClick event .
Copy the following code at the Command1.Click event:
Private Sub Command1_Click()
With TChart1.Series(0)
.Add 40, "Pencil", vbRed
.Add 60, "Paper", vbBlue
.Add 30, "Ribbon", vbGreen
End With
End Sub
A description of the Add method and other available methods and properties is
available at design time via the context sensitive help included with TeeChart. Place
TeeChart© Pro v3 Chart guide