Page 1 of 1

How to serialize all the teechart

Posted: Thu Dec 20, 2007 2:52 am
by 13047815
Hi actually Im develop with TeeChart, and I need to save to an XML my Chart but when i use:

System.IO.MemoryStream fs = new System.IO.MemoryStream();

Steema.TeeChart.Export.DataExport dataExport = new Steema.TeeChart.Export.DataExport(graphic.Chart);

dataExport.XML.IncludeHeader = true;
dataExport.XML.IncludeIndex = true;
dataExport.XML.IncludeLabels = true;
dataExport.XML.IncludeSeriesTitle = true;

dataExport.XML.Save(fs);
fs.Flush();
XmlDocument xmlPanel = new XmlDocument();
fs.Seek(0, System.IO.SeekOrigin.Begin);
xmlPanel.Load(fs);
fs.Close();

I only save the data, labels, index and headers. So I need to save the colors the position the rotation, and too much information, so How I can save all the information for latter save all this in a XML

Later When I load the information I do the next

XmlDocument xmlMain = new XmlDocument();
XmlNode nodeImp = xmlMain.ImportNode(nodeGraph, true);
xmlMain.AppendChild(nodeImp);

System.IO.MemoryStream ms = new System.IO.MemoryStream();
xmlMain.Save(ms);
string s = xmlMain.InnerXml;
ms.Flush();
ms.Seek(0, System.IO.SeekOrigin.Begin);
ms.Position = 0;

Steema.TeeChart.Import.Imports();
graphic.Chart.Import.Template.Load(ms);

graphic.Import.Template.Load(ms);
graphic.Refresh();

But it send an error to say that couldn't load binary data.

Please What can I do to solve my problem..

Posted: Thu Dec 20, 2007 10:19 am
by narcis
Hi fchio,

The easiest way to achieve what you request is exporting TeeChart to its native template file format which also supports exporting chart's data. For more information please read Tutorial 12 - Exporting and Importing Charts
, specially the TeeChart's 'Ten' template and data export import format section. TeeChart native templates can be either stored in a file or a MemoryStream.