Creating a template that contains chart objects

This first step shows how to insert chart objects into a document. Like TextFields, a ChartFrame has a unique name or ID that can be used to identify the chart object.

Choose Chart from the Insert main menu in order to add a chart object to your document. It is filled with default values to visualize formatting and style changes you may apply.

In the right panel, you can change the name of the ChartFrame that should match the DataTable name in step 2 of this sample series. Use the PropertyGrid to make changes to the chart object. These changes are maintained when saving the template.

The following code is used to insert the chart object:

[C#]
Chart chart = new Chart();
chart.Series.Add("series1");
chart.ChartAreas.Add("area1");

chart.DataSource = dt;

// set series members names for the X and Y values
chart.Series[0].XValueMember = "Country";
chart.Series[0].YValueMembers = "Value";

// data bind to the selected data source
chart.DataBind(); 

// create new ChartFrame and add it to TX Text Control
ChartFrame chartFrame = new ChartFrame(chart);
chartFrame.Name = "points";
chartNameID++;

textControl1.Charts.Add(chartFrame, -1);
[Visual Basic]
Dim chart As New Chart
chart.Series.Add("series1")
chart.ChartAreas.Add("area1")

chart.DataSource = dt

' set series members names for the X and Y values
chart.Series(0).XValueMember = "Country"
chart.Series(0).YValueMembers = "Value"

' data bind to the selected data source
chart.DataBind()

' create new ChartFrame and add it to TX Text Control
Dim chartFrame As New ChartFrame(chart)
chartFrame.Name = "points"
chartNameID += 1

textControl1.Charts.Add(chartFrame, -1)

Merging the chart objects with data >>