This class allows for serialization of the Chart control.
ChartSerializer class provides chart serialization API. Depending on the Format property XmlFormatSerializer or BinaryFormatserializer classes will be used internally.
Visual Basic (Declaration) | |
---|---|
Public Class ChartSerializer |
Visual Basic (Usage) | Copy Code |
---|---|
|
C# | |
---|---|
public class ChartSerializer |
This class is exposed as the Serializer property of the root Chart class.
Serialization saves the state of the chart and also provides the ability to load the serialized data into the chart. All chart properties can be persisted, including the chart's data. In addition all chart properties marked for serialization can be reset.
This class can optionally be used when managing user-defined view state. The Load method can be used to load the view state while the Save method can be used when setting the view state. For more information see the State Management topic.
XML or binary formats can be used to store serialized data. XML is used by default, but this can be changed using the Format property.
Chart properties are saved and loaded using the Save and Load methods, respectively. Note that only properties with non-default values will be saved. Data can be saved/loaded using a file, stream, TextWriter/TextReader and XMLWriter/XMLReader objects. When saving/loading data using an object derived from TextReader, TextWriter, XMLReader or XMLWriter the format of the data must be XML.
The following describes three ways to define serializable data (basic to advanced). Note that it is also possible to define non-serializable data, which is described in the next paragraph.
- Serialization of the Chart using the Save and Load methods without specifying any serializable properties. This will result in the serialization of all chart properties with non-default values (this includes chart data).
- Serialization of chart properties specified by the Content property. The Content property groups the chart properties to be serialized into categories (e.g. data, appearance, etc.). Note that the names of ChartArea and Series objects are automatically serialized (the serialized data is then applied to existing chart areas and series when loaded). It is important to know that the Content property is implemented internally by the control as the SerializableContent property.
- Serialization of chart properties specified by the SerializableContent property. This is a comma-separated listing of all chart properties that are serializable. Once this property is set to an explicit value then it is up to the developer to specify all properties to be saved (i.e. unlike the Content property, the names of chart areas and series will not be automatically persisted).
The Content and SerializableContent properties can also be used in conjunction. However, make sure that SerializableContent is concatenated with itself when being set, otherwise the chart properties specified by the Content property will be overridden.
To prohibit certain properties from being serialized use the NonSerializableContent property. When one property is set as serializable and non-serializable (common when wildcards are used) the SerializableContent property has precedence. However, precedence also depends on how many wildcards were used when specifying a property.
By default serializable properties are reset to their defaults before they are loaded. This behavior can be changed using the ResetWhenLoading property. The Reset method can also be used to explicitly reset chart properties to their default values.
System.Object
Dundas.Charting.WebControl.ChartSerializer
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family