Dundas Chart for ASP.NET
Working with Chart Templates
See Also Send comments on this topic.
Getting Started > Working with Chart Templates

Glossary Item Box

Overview

Dundas Chart for ASP.NET allows you to create and load chart templates. These chart templates allow you to save all of the visual styles of your charts so that you can reuse these appearance settings when creating new charts. In addition to saving your chart's esthetic items, templates allow you to preserve any static data which might be present in your charts. In short, by using these templates you can easily re-create any chart in its entirety, thus allowing you to maintain a consistent look and feel throughout all of your applications.

During design-time you are able to load or create templates using a graphical interface. At run-time, you can load or create a template by calling the  LoadTemplate method of the root Chart object, or the Save method of the root Chart object's ChartSerializer object, respectively. This article discusses how to create and save a chart template.

 

For more information on non-template chart serialization, see the topic on Chart Serialization

Creating a New Template

A template is used to define the appearance properties of a chart. The appearance properties of a chart's data series and areas are saved in the template. These templates can then be applied to a chart by loading the template into the Chart control.

If a template has two data series then the appearance properties of those series are applied sequentially to the chart. This means that when the template contains two data series, then the first data series' appearance properties are assigned to the chart's first series, and the second data series' appearance properties are applied to the chart's second series. Then if required, the first template series is used again for the chart's third series, and so on. The same holds true for chart areas, and any other collections that have appearance properties.

Once a chart has been set up to be saved as a template, then the template can be saved in two ways:

 

At design-time the Chart Save Template Wizard can be used to create a chart template. This wizard is launched by right-clicking the chart control, and selecting the Create Template option from the context menu, or by clicking the Create Template link in the Visual Studio Property Browser.

 


Figure 1: The Chart Save Template Wizard can be used to save a chart template.

 

Using the wizard, shown above in Figure 1, is just a matter of setting a file name, and optionally setting a path for the file. You can also use the ellipse to browse to a folder of your choice. By default, all chart templates are stored in a common folder which is found in the Dundas Chart for ASP.NET installation directory.

 

By default, only the chart appearance properties will be stored in the chart template. However, the complete chart, including all of its static data, can be stored in the template by selecting the Save Complete Chart radio button while in the wizard. Once you click on the Create button, the template will be created and saved in the Templates folder.

 

Loading a Saved Chart Template

Loading a previously saved template is fairly straight forward.

A template can be loaded into the chart control in one of two ways, including:

 

This wizard, like the Chart Save Template Wizard, can be launched at design-time by right-clicking on the chart control, and selecting the Load Template option from the context menu, or by clicking the Load Template link from Visual Studio's Property Browser.

 


Figure 2: The Chart Load Template Wizard is used to load a chart template into the charting control.

 

All chart templates stored in the default Templates folder could also be made available to the user. Selection of one of these templates will display a chart preview of your chart with this template applied. Alternatively, a different template path can be set using the ellipse button to browse to an alternate template file location.

Using the radio buttons, you may opt to load only the chart appearance properties included in the template, or you can load the complete chart.

When you have made your choice select the Ok button to apply the selected template to your charting control.

 

The Chart's LoadTemplate methods will only load the appearance properties of the chart.

 

Resetting the Chart

If after setting the appearance styles or data properties for your chart, you decide that these settings are no longer desired, they can all be quickly reset using the Chart Reset Wizard. This wizard resets all of the chart's properties to their default values, and then clears all data collections.

To launch the Chart Reset Wizard, right-click on the chart control, and choose the Reset option from the context menu. You can also launch the wizard using the Reset link found within the Visual Studio Property Browser. Figure 3 shows the Chart Reset Wizard.

 


Figure 3: The Chart Reset Wizard used to reset all chart properties.

 

Caution
You should be mindful that there is no undo option for this reset wizard. This means that resetting a chart's properties in this manner will result in the complete loss of all previously set chart properties and data.

 

See Also

Copyright © 2001 - 2009 Dundas Data Visualization, Inc. and others.