Difference between revisions of "NETTutorial12"

From Steema Software Reference Wiki
Jump to: navigation, search
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:AX]]
+
[[Category:NET]]
 
{| width="100%"
 
{| width="100%"
 
|- valign="TOP"
 
|- valign="TOP"
 
|
 
|
[[Image:tchnet.jpg]]
+
[[Image:net.png|200px]]
| align="RIGHT" | <font size="2">  [[NETTutorials|Contents page]]<br />[[NETTutorial11|Previous]] | [[NETTutorial13|Next]]
+
| align="RIGHT" | <font size="2">  [[TeeChart for NET|Contents page]]<br />[[NETTutorial11|Previous]] | [[NETTutorial13|Next]]
  
 
</font>
 
</font>
 
| width="20" |
 
| width="20" |
 
|}
 
|}
 
+
{{DISPLAYTITLE:<span style="position: absolute; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px);">{{FULLPAGENAME}}</span>}}
 +
= Tutorial12 - Exporting and Importing Charts =
 
__TOC__
 
__TOC__
 
<br>
 
<br>
 
= Tutorial12 - Exporting and Importing Charts =
 
 
 
 
This tutorial is overviews exporting TeeCharts in various formats and importing TeeChart's own .ten format Chart templates.  <br /><br />
 
This tutorial is overviews exporting TeeCharts in various formats and importing TeeChart's own .ten format Chart templates.  <br /><br />
  
==== Contents <br /> ====
+
== Exporting Charts ==
  
'''Exporting Charts'''<br />     [[#Formats | Available formats]]<br />     [[#EgExport | Example export]]<br /><br />'''Exporting Images'''<br />     [[#BMP | BMP]]<br />     [[#JPEG | JPEG]]<br />     [[#WMF&EMF | WMF &amp; EMF]]<br />     [[#GIF | GIF]]<br />     [[#PNG | PNG]]<br />     [[#TIFF | TIFF]]<br />     [[#SWF | Flex/Flash/SWF]]<br /><br />'''Exporting data]'''<br />     [[#Exportdat | Text, XML, HTML, XLS]]<br /><br />'''TeeChart's 'Ten' template and data export import format'''<br />     [[#TenExport | Ten files]]<br /><br />'''Import'''<br />     [[#XMLImport | Importing XML into TeeChart]]<br />     [[#TenFormat | Importing Ten format files]]<br />     [[#egImport | Example import Ten file]]<br />     [[#EffectImport | Effect of changes made in importing Chart]]<br />     [[#OtherInput | Other datasources]]<br /><br /><br />
+
=== Available formats ===
 
+
Available Export formats. All formats may be copied to either a file or Clipboard or to a Stream. <br /><br />
==== Exporting Charts<br /> ====
+
 
+
<div id="Formats">'''Available formats'''</div><br />Available Export formats. All formats may be copied to either a file or Clipboard or to a Stream. <br /><br />
+
  
 
Image formats <br />
 
Image formats <br />
Line 42: Line 36:
 
* TEN (TeeChart): TemplateExport Classs<br />
 
* TEN (TeeChart): TemplateExport Classs<br />
 
Ten format is a flexible format that stores Chart property information and, optionally, Chart data. Files are small (data dependent) and ideal for network use to update live client-based Charts. <br />
 
Ten format is a flexible format that stores Chart property information and, optionally, Chart data. Files are small (data dependent) and ideal for network use to update live client-based Charts. <br />
<div id="EgExport">'''Example export'''</div>Exporting to a file is reasonably straightforward, in most cases you just need to define the destination filename. <br />
+
=== Example export ===
  [C#] <br />private void button1_Click(object sender, System.EventArgs e)  <br />            saveFileDialog1.Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|Images(*.emf)|*.emf|Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.tiff)|*.tiff"; <br />            saveFileDialog1.ShowDialog(); <br />            if(saveFileDialog1.FileName != "")  <br />                switch(saveFileDialog1.FilterIndex)  <br />                    case 1: <br />                        tChart1.Export.Image.Bitmap.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 2: <br />                        tChart1.Export.Image.JPEG.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 3: <br />                        tChart1.Export.Image.Metafile.Enhanced = false; <br />                        tChart1.Export.Image.Metafile.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 4: <br />                        tChart1.Export.Image.Metafile.Enhanced = true; <br />                        tChart1.Export.Image.Metafile.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 5: <br />                        tChart1.Export.Image.GIF.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 6: <br />                        tChart1.Export.Image.PNG.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 7: <br />                        tChart1.Export.Image.TIFF.Save(saveFileDialog1.FileName); <br />                        break; <br />                 <br />             <br />         <br /> <br />[VB.Net] <br />Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <br />        SaveFileDialog1.Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|Images(*.emf)|*.emf|Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.tiff)|*.tiff" <br />        SaveFileDialog1.ShowDialog() <br />        If SaveFileDialog1.FileName &lt;&gt; "" Then <br />            Select Case SaveFileDialog1.FilterIndex <br />                Case 1 <br />                    TChart1.Export.Image.Bitmap.Save(SaveFileDialog1.FileName) <br />                Case 2 <br />                    TChart1.Export.Image.JPEG.Save(SaveFileDialog1.FileName) <br />                Case 3 <br />                    TChart1.Export.Image.Metafile.Enhanced = False <br />                    TChart1.Export.Image.Metafile.Save(SaveFileDialog1.FileName) <br />                Case 4 <br />                    TChart1.Export.Image.Metafile.Enhanced = True <br />                    TChart1.Export.Image.Metafile.Save(SaveFileDialog1.FileName) <br />                Case 5 <br />                    TChart1.Export.Image.GIF.Save(SaveFileDialog1.FileName) <br />                Case 6 <br />                    TChart1.Export.Image.PNG.Save(SaveFileDialog1.FileName) <br />                Case 7 <br />                    TChart1.Export.Image.TIFF.Save(SaveFileDialog1.FileName) <br />            End Select <br />        End If <br />End Sub <br />
+
Exporting to a file is reasonably straightforward, in most cases you just need to define the destination filename. <br />
<br />
+
  [C#] <br />private void button1_Click(object sender, System.EventArgs e)  <br />            saveFileDialog1.Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|Images(*.emf)|*.emf|<br />  Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.tiff)|*.tiff"; <br />            saveFileDialog1.ShowDialog(); <br />            if(saveFileDialog1.FileName != "")  <br />                switch(saveFileDialog1.FilterIndex)  <br />                    case 1: <br />                        tChart1.Export.Image.Bitmap.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 2: <br />                        tChart1.Export.Image.JPEG.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 3: <br />                        tChart1.Export.Image.Metafile.Enhanced = false; <br />                        tChart1.Export.Image.Metafile.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 4: <br />                        tChart1.Export.Image.Metafile.Enhanced = true; <br />                        tChart1.Export.Image.Metafile.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 5: <br />                        tChart1.Export.Image.GIF.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 6: <br />                        tChart1.Export.Image.PNG.Save(saveFileDialog1.FileName); <br />                        break; <br />                    case 7: <br />                        tChart1.Export.Image.TIFF.Save(saveFileDialog1.FileName); <br />                        break; <br />[VB.Net] <br />Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <br />        SaveFileDialog1.Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|<br />  Images(*.emf)|*.emf|Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.tiff)|*.tiff" <br />        SaveFileDialog1.ShowDialog() <br />        If SaveFileDialog1.FileName &lt;&gt; "" Then <br />            Select Case SaveFileDialog1.FilterIndex <br />                Case 1 <br />                    TChart1.Export.Image.Bitmap.Save(SaveFileDialog1.FileName) <br />                Case 2 <br />                    TChart1.Export.Image.JPEG.Save(SaveFileDialog1.FileName) <br />                Case 3 <br />                    TChart1.Export.Image.Metafile.Enhanced = False <br />                    TChart1.Export.Image.Metafile.Save(SaveFileDialog1.FileName) <br />                Case 4 <br />                    TChart1.Export.Image.Metafile.Enhanced = True <br />                    TChart1.Export.Image.Metafile.Save(SaveFileDialog1.FileName) <br />                Case 5 <br />                    TChart1.Export.Image.GIF.Save(SaveFileDialog1.FileName) <br />                Case 6 <br />                    TChart1.Export.Image.PNG.Save(SaveFileDialog1.FileName) <br />                Case 7 <br />                    TChart1.Export.Image.TIFF.Save(SaveFileDialog1.FileName) <br />            End Select <br />        End If <br />End Sub <br />
==== Exporting Images<br /> ====
+
 
<div id="BMP">'''BMP'''</div>BMP file export has additional parameters for colours and size.<br />Example<br />
+
== Exporting Images ==
  [C#] <br />case 1: <br />     Steema.TeeChart.Export.BitmapFormat bitMap = tChart1.Export.Image.Bitmap; <br />     bitMap.Height = 500; <br />     bitMap.Width = 700; <br />     bitMap.Monochrome = true; <br />     bitMap.Save(saveFileDialog1.FileName); <br />     break; <br /> <br /> <br />[VB.Net] <br />Case 1 <br />     Dim BitMap As Steema.TeeChart.Export.BitmapFormat = TChart1.Export.Image.Bitmap <br />     BitMap.Height = 500 <br />     BitMap.Width = 700 <br />     BitMap.Monochrome = True <br />     BitMap.Save(SaveFileDialog1.FileName) <br />
+
=== BMP ===
<br /><div id="JPEG">'''JPEG'''</div>JPEG file export now has parameters for speed and quality for both SaveToFile and SaveToStream.<br />Example<br />
+
BMP file export has additional parameters for colours and size.<br />Example<br />
 +
  [C#] <br />case 1: <br />     Steema.TeeChart.Export.BitmapFormat bitMap = tChart1.Export.Image.Bitmap; <br />     bitMap.Height = 500; <br />     bitMap.Width = 700; <br />     bitMap.Monochrome = true; <br />     bitMap.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 1 <br />     Dim BitMap As Steema.TeeChart.Export.BitmapFormat = TChart1.Export.Image.Bitmap <br />     BitMap.Height = 500 <br />     BitMap.Width = 700 <br />     BitMap.Monochrome = True <br />     BitMap.Save(SaveFileDialog1.FileName) <br />
 +
 
 +
=== JPEG ===
 +
JPEG file export now has parameters for speed and quality for both SaveToFile and SaveToStream.<br />Example<br />
 
  [C#] <br />case 2: <br />Steema.TeeChart.Export.JPEGFormat jPEG = tChart1.Export.Image.JPEG; <br />     jPEG.GrayScale = true; <br />     jPEG.Height = 500; <br />     jPEG.Width = 700; <br />     jPEG.Quality = 100; <br />     jPEG.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 2 <br />Dim JPEGf As Steema.TeeChart.Export.JPEGFormat = TChart1.Export.Image.JPEG <br />     JPEGf.Height = 500 <br />     JPEGf.Width = 700 <br />     JPEGf.GrayScale = True <br />     JPEGf.Quality = 100 <br />     JPEGf.Save(SaveFileDialog1.FileName) <br />
 
  [C#] <br />case 2: <br />Steema.TeeChart.Export.JPEGFormat jPEG = tChart1.Export.Image.JPEG; <br />     jPEG.GrayScale = true; <br />     jPEG.Height = 500; <br />     jPEG.Width = 700; <br />     jPEG.Quality = 100; <br />     jPEG.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 2 <br />Dim JPEGf As Steema.TeeChart.Export.JPEGFormat = TChart1.Export.Image.JPEG <br />     JPEGf.Height = 500 <br />     JPEGf.Width = 700 <br />     JPEGf.GrayScale = True <br />     JPEGf.Quality = 100 <br />     JPEGf.Save(SaveFileDialog1.FileName) <br />
<br /><div id="WMF&EMF">'''WMF &amp; EMF'''</div>Enhanced Metafiles are simply created by setting "Enhanced" to True. <br />Example<br />
+
=== WMF &amp; EMF ===
 +
Enhanced Metafiles are simply created by setting "Enhanced" to True. <br />Example<br />
 
  [C#] <br />case 3: <br />     Steema.TeeChart.Export.MetafileFormat metaFile = tChart1.Export.Image.Metafile; <br />     metaFile.Height = 500; <br />     metaFile.Width = 700; <br />     metaFile.Enhanced = false; <br />     metaFile.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 3 <br />     Dim MetaFile As Steema.TeeChart.Export.MetafileFormat = TChart1.Export.Image.Metafile <br />     MetaFile.Height = 500 <br />     MetaFile.Width = 700 <br />     MetaFile.Enhanced = False <br />     MetaFile.Save(SaveFileDialog1.FileName) <br />
 
  [C#] <br />case 3: <br />     Steema.TeeChart.Export.MetafileFormat metaFile = tChart1.Export.Image.Metafile; <br />     metaFile.Height = 500; <br />     metaFile.Width = 700; <br />     metaFile.Enhanced = false; <br />     metaFile.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 3 <br />     Dim MetaFile As Steema.TeeChart.Export.MetafileFormat = TChart1.Export.Image.Metafile <br />     MetaFile.Height = 500 <br />     MetaFile.Width = 700 <br />     MetaFile.Enhanced = False <br />     MetaFile.Save(SaveFileDialog1.FileName) <br />
<br /><div id="GIF">'''GIF'''</div>TeeChart for .Net is able to support the exportation of bitmaps in GIF format thanks to Microsoft's .Net Framework Class Library, specifically those classes contained in the [ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemdrawingimaging.htm System.Drawing.Imaging Namespace]. To this day it remains unclear whether developers who implement these classes in their applications need to license the GIF patent from Unisys or not. Our best suggestion, if in doubt, is to visit the [http://www.unisys.com/ Unisys Website]. <br />Example  
+
=== GIF ===
 +
TeeChart for .Net is able to support the exportation of bitmaps in GIF format thanks to Microsoft's .Net Framework Class Library, specifically those classes contained in the [ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemdrawingimaging.htm System.Drawing.Imaging Namespace]. To this day it remains unclear whether developers who implement these classes in their applications need to license the GIF patent from Unisys or not. Our best suggestion, if in doubt, is to visit the [http://www.unisys.com/ Unisys Website]. <br />Example  
 
<br /><br />
 
<br /><br />
 
  [C#] <br />case 5: <br />     Steema.TeeChart.Export.GIFFormat gIF = tChart1.Export.Image.GIF; <br />     gIF.Height = 500; <br />     gIF.Width = 700; <br />     gIF.ColorReduction = Steema.TeeChart.Export.GIFFormat.GIFColorReduction.GrayScale; <br />     gIF.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 5 <br />     Dim GIF As Steema.TeeChart.Export.GIFFormat = TChart1.Export.Image.GIF <br />     GIF.Height = 500 <br />     GIF.Width = 700 <br />     GIF.ColorReduction = Steema.TeeChart.Export.GIFFormat.GIFColorReduction.GrayScale <br />     GIF.Save(SaveFileDialog1.FileName) <br />
 
  [C#] <br />case 5: <br />     Steema.TeeChart.Export.GIFFormat gIF = tChart1.Export.Image.GIF; <br />     gIF.Height = 500; <br />     gIF.Width = 700; <br />     gIF.ColorReduction = Steema.TeeChart.Export.GIFFormat.GIFColorReduction.GrayScale; <br />     gIF.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 5 <br />     Dim GIF As Steema.TeeChart.Export.GIFFormat = TChart1.Export.Image.GIF <br />     GIF.Height = 500 <br />     GIF.Width = 700 <br />     GIF.ColorReduction = Steema.TeeChart.Export.GIFFormat.GIFColorReduction.GrayScale <br />     GIF.Save(SaveFileDialog1.FileName) <br />
<br /> <div id="PNG">'''PNG'''</div><br /><br /><br />
+
=== PNG ===
 
  [C#] <br />case 6: <br />     Steema.TeeChart.Export.PNGFormat pNG = tChart1.Export.Image.PNG; <br />     pNG.Compression = 100; <br />     pNG.GrayScale = true; <br />     pNG.Height = 500; <br />     pNG.Width = 700; <br />     pNG.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 6 <br />     Dim PNGf As Steema.TeeChart.Export.PNGFormat = TChart1.Export.Image.PNG <br />     PNGf.Compression = 100 <br />     PNGf.GrayScale = True <br />     PNGf.Height = 500 <br />     PNGf.Width = 700 <br />     PNGf.Save(SaveFileDialog1.FileName) <br />
 
  [C#] <br />case 6: <br />     Steema.TeeChart.Export.PNGFormat pNG = tChart1.Export.Image.PNG; <br />     pNG.Compression = 100; <br />     pNG.GrayScale = true; <br />     pNG.Height = 500; <br />     pNG.Width = 700; <br />     pNG.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 6 <br />     Dim PNGf As Steema.TeeChart.Export.PNGFormat = TChart1.Export.Image.PNG <br />     PNGf.Compression = 100 <br />     PNGf.GrayScale = True <br />     PNGf.Height = 500 <br />     PNGf.Width = 700 <br />     PNGf.Save(SaveFileDialog1.FileName) <br />
<br /><div id="TIFF">'''TIFF'''</div><br /><br /><br />
+
=== TIFF ===
 
  [C#] <br />case 7: <br />     Steema.TeeChart.Export.TIFFFormat tIFF = tChart1.Export.Image.TIFF; <br />     tIFF.Compression = Steema.TeeChart.Export.TIFFFormat.TIFFCompression.LZW; <br />     tIFF.Height = 500; <br />     tIFF.Width = 700; <br />     tIFF.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 7 <br />     Dim TIFF As Steema.TeeChart.Export.TIFFFormat = TChart1.Export.Image.TIFF <br />     TIFF.Compression = Steema.TeeChart.Export.TIFFFormat.TIFFCompression.LZW <br />     TIFF.Height = 500 <br />     TIFF.Width = 700 <br />     TIFF.Save(SaveFileDialog1.FileName) <br />
 
  [C#] <br />case 7: <br />     Steema.TeeChart.Export.TIFFFormat tIFF = tChart1.Export.Image.TIFF; <br />     tIFF.Compression = Steema.TeeChart.Export.TIFFFormat.TIFFCompression.LZW; <br />     tIFF.Height = 500; <br />     tIFF.Width = 700; <br />     tIFF.Save(saveFileDialog1.FileName); <br />     break; <br /> <br />[VB.Net] <br />Case 7 <br />     Dim TIFF As Steema.TeeChart.Export.TIFFFormat = TChart1.Export.Image.TIFF <br />     TIFF.Compression = Steema.TeeChart.Export.TIFFFormat.TIFFCompression.LZW <br />     TIFF.Height = 500 <br />     TIFF.Width = 700 <br />     TIFF.Save(SaveFileDialog1.FileName) <br />
<br /><div id="SWF">'''Adobe Flex/Flash/SWF<br />'''</div><br /><br />
+
=== Adobe Flex/Flash/SWF ===
==== Exporting data<br /> ====  
+
 
<br /><div id="Exportdat">Formats</div>
+
== Exporting data ==  
<br />
+
=== Formats ===
 
* Text: TextFormat Class<br />
 
* Text: TextFormat Class<br />
 
* XML: XMLFormat Class<br />
 
* XML: XMLFormat Class<br />
 
* HTML: HTMLFormat Class<br />
 
* HTML: HTMLFormat Class<br />
* Excel: ExcelFormat Class<br /><br /><br /><br />
+
* Excel: ExcelFormat Class
 
  [C#] <br />private void Form1_Load(object sender, System.EventArgs e)  <br />            Random rnd = new Random(); <br />            char c = new char(); <br /> <br />            for(int i = 0; i &lt; 10;  i)  <br />                c = Convert.ToChar(65  i); <br />                bar1.Add(Convert.ToDouble(i),rnd.Next(100),c.ToString(),Color.Red); <br />             <br />            Steema.TeeChart.Export.DataExport dataExport = new Steema.TeeChart.Export.DataExport(tChart1.Chart); <br />            dataExport.HTML.IncludeHeader = true; <br />            dataExport.HTML.IncludeIndex = true; <br />            dataExport.HTML.IncludeLabels = true; <br />            dataExport.HTML.Series = bar1; <br />            dataExport.HTML.Save(@"C:.htm"); <br />         <br /> <br />[VB.Net] <br />Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load <br />            Dim C As New Char() <br />            Dim i As New Integer() <br /> <br />            For i = 0 To 10 <br />                C = Convert.ToChar(65  i) <br />                Bar1.Add(Convert.ToDouble(i), Rnd() * 100, C.ToString(), Color.Red) <br />            Next <br />            Dim DataExport As New Steema.TeeChart.Export.DataExport(TChart1.Chart) <br />            DataExport.HTML.IncludeHeader = True <br />            DataExport.HTML.IncludeIndex = True <br />            DataExport.HTML.IncludeLabels = True <br />            DataExport.HTML.Series = Bar1 <br />            DataExport.HTML.Save("C:.htm") <br />End Sub <br />
 
  [C#] <br />private void Form1_Load(object sender, System.EventArgs e)  <br />            Random rnd = new Random(); <br />            char c = new char(); <br /> <br />            for(int i = 0; i &lt; 10;  i)  <br />                c = Convert.ToChar(65  i); <br />                bar1.Add(Convert.ToDouble(i),rnd.Next(100),c.ToString(),Color.Red); <br />             <br />            Steema.TeeChart.Export.DataExport dataExport = new Steema.TeeChart.Export.DataExport(tChart1.Chart); <br />            dataExport.HTML.IncludeHeader = true; <br />            dataExport.HTML.IncludeIndex = true; <br />            dataExport.HTML.IncludeLabels = true; <br />            dataExport.HTML.Series = bar1; <br />            dataExport.HTML.Save(@"C:.htm"); <br />         <br /> <br />[VB.Net] <br />Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load <br />            Dim C As New Char() <br />            Dim i As New Integer() <br /> <br />            For i = 0 To 10 <br />                C = Convert.ToChar(65  i) <br />                Bar1.Add(Convert.ToDouble(i), Rnd() * 100, C.ToString(), Color.Red) <br />            Next <br />            Dim DataExport As New Steema.TeeChart.Export.DataExport(TChart1.Chart) <br />            DataExport.HTML.IncludeHeader = True <br />            DataExport.HTML.IncludeIndex = True <br />            DataExport.HTML.IncludeLabels = True <br />            DataExport.HTML.Series = Bar1 <br />            DataExport.HTML.Save("C:.htm") <br />End Sub <br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
+
<br />
==== TeeChart's 'Ten' template and </div>data export/import format<br /> ====
+
 
<div id="TenExport">'''Ten files'''<br /><br /><br /><br />
+
== TeeChart's 'Ten' template and data export/import format ==
 +
=== Ten files ===
 
* Ten files are very small in size, in most cases that offers an advantage <br />    over pure graphic formats (qicker).<br />
 
* Ten files are very small in size, in most cases that offers an advantage <br />    over pure graphic formats (qicker).<br />
 
* The destination Chart for the template is 'live', it can be zoomed and scrolled and have <br />  its properties modified.<br />
 
* The destination Chart for the template is 'live', it can be zoomed and scrolled and have <br />  its properties modified.<br />
* Data may optionally be included with the ten template according to your preference.<br /><br /><br />
+
* Data may optionally be included with the ten template according to your preference.
 
  [C#] <br />private void button1_Click(object sender, System.EventArgs e)  <br />            saveFileDialog1.Filter = "TenFile (.ten)|*.ten"; <br />            saveFileDialog1.ShowDialog(); <br />            if(saveFileDialog1.FileName != "")  <br />                tChart1.Export.Template.IncludeData = true; <br />                tChart1.Export.Template.Save(saveFileDialog1.FileName); <br />             <br />         <br />[VB.Net] <br />Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <br />        SaveFileDialog1.Filter = "TenFile (.ten)|*.ten" <br />        SaveFileDialog1.ShowDialog() <br />        If SaveFileDialog1.FileName &lt;&gt; "" Then <br />            TChart1.Export.Template.IncludeData = True <br />            TChart1.Export.Template.Save(SaveFileDialog1.FileName) <br />        End If <br />End Sub <br />
 
  [C#] <br />private void button1_Click(object sender, System.EventArgs e)  <br />            saveFileDialog1.Filter = "TenFile (.ten)|*.ten"; <br />            saveFileDialog1.ShowDialog(); <br />            if(saveFileDialog1.FileName != "")  <br />                tChart1.Export.Template.IncludeData = true; <br />                tChart1.Export.Template.Save(saveFileDialog1.FileName); <br />             <br />         <br />[VB.Net] <br />Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <br />        SaveFileDialog1.Filter = "TenFile (.ten)|*.ten" <br />        SaveFileDialog1.ShowDialog() <br />        If SaveFileDialog1.FileName &lt;&gt; "" Then <br />            TChart1.Export.Template.IncludeData = True <br />            TChart1.Export.Template.Save(SaveFileDialog1.FileName) <br />        End If <br />End Sub <br />
 
<br />
 
<br />
==== Import<br /> ====
+
 
<div id="XMLImport">'''Importing XML into TeeChart'''</div><br /><br />
+
== Import<br /> ==
  Example <br />[C#] <br />protected override void button1_Click(object sender, System.EventArgs e)  <br />            tChart1.Series.RemoveAllSeries(); <br />            Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart); <br />            points1.Title = "Points Series"; <br />            xmlSource1.Series = points1; <br />            xmlSource1.SeriesNode = "Points Series"; <br />            xmlSource1.Load(textBox2.Text); <br /> <br /> <br />            tChart1.Refresh(); <br />         <br /><br />
+
=== Importing XML into TeeChart ===
<br />
+
  Example <br />[C#] <br />protected override void button1_Click(object sender, System.EventArgs e)  <br />            tChart1.Series.RemoveAllSeries(); <br />            Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart); <br />            points1.Title = "Points Series"; <br />            xmlSource1.Series = points1; <br />            xmlSource1.SeriesNode = "Points Series"; <br />            xmlSource1.Load(textBox2.Text); <br /><br />          tChart1.Refresh(); <br />
Example <br />[C#] <br />protected override void button2_Click(object sender, System.EventArgs e)  <br />            tChart1.Series.RemoveAllSeries(); <br />            xmlSource1.Chart = tChart1.Chart; <br />            xmlSource1.Load("http://www.steema.com/SampleNETData.xml"); <br /> <br />            tChart1.Refresh(); <br />         <br />
+
<br /><div id="TenFormat">'''Importing Ten format files'''</div><br /><br /><br />
+
<div id="egImport">'''Example Imports'''</div><br />
+
Example <br />
+
 
<br />
 
<br />
 +
Example <br />[C#] <br />protected override void button2_Click(object sender, System.EventArgs e)  <br />            tChart1.Series.RemoveAllSeries(); <br />            xmlSource1.Chart = tChart1.Chart; <br />            xmlSource1.Load("http://www.steema.com/SampleNETData.xml"); <br /> <br />            tChart1.Refresh(); <br />        
 +
 +
=== Importing Ten format files ===
 +
 +
=== Example Imports ===
 +
Example
 
  [C#] <br />tChart1.Import.Template.LoadFileDialog(); <br />[VB.Net] <br />TChart1.Import.Template.LoadFileDialog() <br />
 
  [C#] <br />tChart1.Import.Template.LoadFileDialog(); <br />[VB.Net] <br />TChart1.Import.Template.LoadFileDialog() <br />
<br /><br /><br />
+
 
 
  [C#] <br />tChart1.Import.Template.FromURL("http://www.berneda.com/demo.ten"); <br />[VB.Net] <br />TChart1.Import.Template.FromURL("http://www.berneda.com/demo.ten") <br />
 
  [C#] <br />tChart1.Import.Template.FromURL("http://www.berneda.com/demo.ten"); <br />[VB.Net] <br />TChart1.Import.Template.FromURL("http://www.berneda.com/demo.ten") <br />
<br /><br /><br />
+
 
 
  [C#] <br />System.IO.MemoryStream tenStream = new System.IO.MemoryStream(); <br />tChart1.Export.Template.Save(tenStream); <br />tChart2.Import.Template.Load(tenStream); <br />[VB.Net] <br />Dim TenStream As New System.IO.MemoryStream() <br />TChart1.Export.Template.Save(TenStream) <br />TChart2.Import.Template.Load(TenStream) <br />
 
  [C#] <br />System.IO.MemoryStream tenStream = new System.IO.MemoryStream(); <br />tChart1.Export.Template.Save(tenStream); <br />tChart2.Import.Template.Load(tenStream); <br />[VB.Net] <br />Dim TenStream As New System.IO.MemoryStream() <br />TChart1.Export.Template.Save(TenStream) <br />TChart2.Import.Template.Load(TenStream) <br />
<br /><div id="EffectImport">'''Effect of changes made in importing Chart'''</div><br /><br /><br />
+
 
 +
=== Effect of changes made in importing Chart ===
 
  [C#] <br />private void Form1_Load(object sender, System.EventArgs e)  <br />        Bar bar1 = new Bar(tChart1.Chart); <br />        bar1.FillSampleValues(20); <br /> <br />private void button1_Click(object sender, System.EventArgs e)  <br />        saveFileDialog1.Filter = "TenFile (.ten)|*.ten"; <br />        saveFileDialog1.ShowDialog(); <br />        if(saveFileDialog1.FileName != "")  <br />            tChart1.Export.Template.IncludeData = true; <br />            tChart1.Export.Template.Save(saveFileDialog1.FileName); <br />         <br /> <br />private void button2_Click(object sender, System.EventArgs e)  <br />        tChart1.Dispose(); <br />        tChart1 = new Steema.TeeChart.TChart(); <br />        ini_Chart(); <br /> <br />private void ini_Chart()  <br />        this.tChart1.Header.Lines = new string[] "TeeChart"; <br />        this.tChart1.Location = new System.Drawing.Point(24, 24); <br />        this.tChart1.Name = "tChart1"; <br />        this.tChart1.Size = new System.Drawing.Size(400, 240); <br />        this.tChart1.TabIndex = 5; <br />        this.Controls.AddRange(new System.Windows.Forms.Control[] this.tChart1); <br /> <br />private void button3_Click(object sender, System.EventArgs e)  <br />        tChart1.Import.Template.LoadFileDialog(); <br /> <br /> <br />[VB.Net] <br />Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load <br />        Dim Bar1 As New Steema.TeeChart.Styles.Bar(TChart1.Chart) <br />        Bar1.FillSampleValues(20) <br />End Sub <br />Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <br />        SaveFileDialog1.Filter = "TenFile (.ten)|*.ten" <br />        SaveFileDialog1.ShowDialog() <br />        If Not SaveFileDialog1.FileName = "" Then <br />            TChart1.Export.Template.IncludeData = True <br />            TChart1.Export.Template.Save(SaveFileDialog1.FileName) <br />        End If <br />End Sub <br />Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click <br />        TChart1.Dispose() <br />        TChart1 = New Steema.TeeChart.TChart() <br />        Ini_Chart() <br />End Sub <br />Private Sub Ini_Chart() <br />        Me.TChart1.Header.Lines = New String() "TeeChart" <br />        Me.TChart1.Location = New System.Drawing.Point(16, 16) <br />        Me.TChart1.Name = "TChart1" <br />        Me.TChart1.Size = New System.Drawing.Size(400, 296) <br />        Me.TChart1.TabIndex = 3 <br />        Me.Controls.AddRange(New System.Windows.Forms.Control() Me.TChart1) <br />End Sub <br />Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click <br />        TChart1.Import.Template.LoadFileDialog() <br />End Sub <br /> <br />
 
  [C#] <br />private void Form1_Load(object sender, System.EventArgs e)  <br />        Bar bar1 = new Bar(tChart1.Chart); <br />        bar1.FillSampleValues(20); <br /> <br />private void button1_Click(object sender, System.EventArgs e)  <br />        saveFileDialog1.Filter = "TenFile (.ten)|*.ten"; <br />        saveFileDialog1.ShowDialog(); <br />        if(saveFileDialog1.FileName != "")  <br />            tChart1.Export.Template.IncludeData = true; <br />            tChart1.Export.Template.Save(saveFileDialog1.FileName); <br />         <br /> <br />private void button2_Click(object sender, System.EventArgs e)  <br />        tChart1.Dispose(); <br />        tChart1 = new Steema.TeeChart.TChart(); <br />        ini_Chart(); <br /> <br />private void ini_Chart()  <br />        this.tChart1.Header.Lines = new string[] "TeeChart"; <br />        this.tChart1.Location = new System.Drawing.Point(24, 24); <br />        this.tChart1.Name = "tChart1"; <br />        this.tChart1.Size = new System.Drawing.Size(400, 240); <br />        this.tChart1.TabIndex = 5; <br />        this.Controls.AddRange(new System.Windows.Forms.Control[] this.tChart1); <br /> <br />private void button3_Click(object sender, System.EventArgs e)  <br />        tChart1.Import.Template.LoadFileDialog(); <br /> <br /> <br />[VB.Net] <br />Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load <br />        Dim Bar1 As New Steema.TeeChart.Styles.Bar(TChart1.Chart) <br />        Bar1.FillSampleValues(20) <br />End Sub <br />Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <br />        SaveFileDialog1.Filter = "TenFile (.ten)|*.ten" <br />        SaveFileDialog1.ShowDialog() <br />        If Not SaveFileDialog1.FileName = "" Then <br />            TChart1.Export.Template.IncludeData = True <br />            TChart1.Export.Template.Save(SaveFileDialog1.FileName) <br />        End If <br />End Sub <br />Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click <br />        TChart1.Dispose() <br />        TChart1 = New Steema.TeeChart.TChart() <br />        Ini_Chart() <br />End Sub <br />Private Sub Ini_Chart() <br />        Me.TChart1.Header.Lines = New String() "TeeChart" <br />        Me.TChart1.Location = New System.Drawing.Point(16, 16) <br />        Me.TChart1.Name = "TChart1" <br />        Me.TChart1.Size = New System.Drawing.Size(400, 296) <br />        Me.TChart1.TabIndex = 3 <br />        Me.Controls.AddRange(New System.Windows.Forms.Control() Me.TChart1) <br />End Sub <br />Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click <br />        TChart1.Import.Template.LoadFileDialog() <br />End Sub <br /> <br />
<div id="OtherInput">'''Other datasources'''</div><br />[[NETTutorial8|NETTutorial8-Database Access tutorial]]<br /><br />
+
=== Other datasources ===
 +
[[NETTutorial8|NETTutorial8-Database Access tutorial]]<br /><br />
 
----
 
----
  
Line 110: Line 115:
 
</center>
 
</center>
 
----
 
----
© 1998-2013 Steema Software SL. All rights reserved.
+
© 1998-{{CURRENTYEAR}} Steema Software SL. All rights reserved.

Latest revision as of 12:15, 22 April 2016

Net.png

Contents page
Previous | Next

Tutorial12 - Exporting and Importing Charts


This tutorial is overviews exporting TeeCharts in various formats and importing TeeChart's own .ten format Chart templates.  

Exporting Charts

Available formats

Available Export formats. All formats may be copied to either a file or Clipboard or to a Stream.

Image formats

  • BMP: BitmapFormat Class
  • JPEG: JPEGFormat Class
  • WMF & EMF: MetafileFormat Class
  • GIF: GIFFormat Class
  • PNG: PNGFormat Class
  • TIFF: TIFFFormat Class

Data formats

  • Text: TextFormat Class
  • XML: XMLFormat Class
  • HTML: HTMLFormat Class
  • Excel: ExcelFormat Class

Other formats

  • TEN (TeeChart): TemplateExport Classs

Ten format is a flexible format that stores Chart property information and, optionally, Chart data. Files are small (data dependent) and ideal for network use to update live client-based Charts.

Example export

Exporting to a file is reasonably straightforward, in most cases you just need to define the destination filename.

[C#] 
private void button1_Click(object sender, System.EventArgs e)
            saveFileDialog1.Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|Images(*.emf)|*.emf|
Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.tiff)|*.tiff";
            saveFileDialog1.ShowDialog();
            if(saveFileDialog1.FileName != "")
                switch(saveFileDialog1.FilterIndex)
                    case 1:
                        tChart1.Export.Image.Bitmap.Save(saveFileDialog1.FileName);
                        break;
                    case 2:
                        tChart1.Export.Image.JPEG.Save(saveFileDialog1.FileName);
                        break;
                    case 3:
                        tChart1.Export.Image.Metafile.Enhanced = false;
                        tChart1.Export.Image.Metafile.Save(saveFileDialog1.FileName);
                        break;
                    case 4:
                        tChart1.Export.Image.Metafile.Enhanced = true;
                        tChart1.Export.Image.Metafile.Save(saveFileDialog1.FileName);
                        break;
                    case 5:
                        tChart1.Export.Image.GIF.Save(saveFileDialog1.FileName);
                        break;
                    case 6:
                        tChart1.Export.Image.PNG.Save(saveFileDialog1.FileName);
                        break;
                    case 7:
                        tChart1.Export.Image.TIFF.Save(saveFileDialog1.FileName);
                        break;
[VB.Net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SaveFileDialog1.Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|
Images(*.emf)|*.emf|Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.tiff)|*.tiff"
        SaveFileDialog1.ShowDialog()
        If SaveFileDialog1.FileName <> "" Then
            Select Case SaveFileDialog1.FilterIndex
                Case 1
                    TChart1.Export.Image.Bitmap.Save(SaveFileDialog1.FileName)
                Case 2
                    TChart1.Export.Image.JPEG.Save(SaveFileDialog1.FileName)
                Case 3
                    TChart1.Export.Image.Metafile.Enhanced = False
                    TChart1.Export.Image.Metafile.Save(SaveFileDialog1.FileName)
                Case 4
                    TChart1.Export.Image.Metafile.Enhanced = True
                    TChart1.Export.Image.Metafile.Save(SaveFileDialog1.FileName)
                Case 5
                    TChart1.Export.Image.GIF.Save(SaveFileDialog1.FileName)
                Case 6
                    TChart1.Export.Image.PNG.Save(SaveFileDialog1.FileName)
                Case 7
                    TChart1.Export.Image.TIFF.Save(SaveFileDialog1.FileName)
            End Select
        End If
End Sub

Exporting Images

BMP

BMP file export has additional parameters for colours and size.
Example

[C#] 
case 1:
     Steema.TeeChart.Export.BitmapFormat bitMap = tChart1.Export.Image.Bitmap;
     bitMap.Height = 500;
     bitMap.Width = 700;
     bitMap.Monochrome = true;
     bitMap.Save(saveFileDialog1.FileName);
     break;

[VB.Net]
Case 1
     Dim BitMap As Steema.TeeChart.Export.BitmapFormat = TChart1.Export.Image.Bitmap
     BitMap.Height = 500
     BitMap.Width = 700
     BitMap.Monochrome = True
     BitMap.Save(SaveFileDialog1.FileName)

JPEG

JPEG file export now has parameters for speed and quality for both SaveToFile and SaveToStream.
Example

[C#] 
case 2:
Steema.TeeChart.Export.JPEGFormat jPEG = tChart1.Export.Image.JPEG;
     jPEG.GrayScale = true;
     jPEG.Height = 500;
     jPEG.Width = 700;
     jPEG.Quality = 100;
     jPEG.Save(saveFileDialog1.FileName);
     break;

[VB.Net]
Case 2
Dim JPEGf As Steema.TeeChart.Export.JPEGFormat = TChart1.Export.Image.JPEG
     JPEGf.Height = 500
     JPEGf.Width = 700
     JPEGf.GrayScale = True
     JPEGf.Quality = 100
     JPEGf.Save(SaveFileDialog1.FileName)

WMF & EMF

Enhanced Metafiles are simply created by setting "Enhanced" to True.
Example

[C#] 
case 3:
     Steema.TeeChart.Export.MetafileFormat metaFile = tChart1.Export.Image.Metafile;
     metaFile.Height = 500;
     metaFile.Width = 700;
     metaFile.Enhanced = false;
     metaFile.Save(saveFileDialog1.FileName);
     break;

[VB.Net]
Case 3
     Dim MetaFile As Steema.TeeChart.Export.MetafileFormat = TChart1.Export.Image.Metafile
     MetaFile.Height = 500
     MetaFile.Width = 700
     MetaFile.Enhanced = False
     MetaFile.Save(SaveFileDialog1.FileName)

GIF

TeeChart for .Net is able to support the exportation of bitmaps in GIF format thanks to Microsoft's .Net Framework Class Library, specifically those classes contained in the [ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemdrawingimaging.htm System.Drawing.Imaging Namespace]. To this day it remains unclear whether developers who implement these classes in their applications need to license the GIF patent from Unisys or not. Our best suggestion, if in doubt, is to visit the Unisys Website.
Example

[C#] 
case 5:
     Steema.TeeChart.Export.GIFFormat gIF = tChart1.Export.Image.GIF;
     gIF.Height = 500;
     gIF.Width = 700;
     gIF.ColorReduction = Steema.TeeChart.Export.GIFFormat.GIFColorReduction.GrayScale;
     gIF.Save(saveFileDialog1.FileName);
     break;

[VB.Net]
Case 5
     Dim GIF As Steema.TeeChart.Export.GIFFormat = TChart1.Export.Image.GIF
     GIF.Height = 500
     GIF.Width = 700
     GIF.ColorReduction = Steema.TeeChart.Export.GIFFormat.GIFColorReduction.GrayScale
     GIF.Save(SaveFileDialog1.FileName)

PNG

[C#] 
case 6:
     Steema.TeeChart.Export.PNGFormat pNG = tChart1.Export.Image.PNG;
     pNG.Compression = 100;
     pNG.GrayScale = true;
     pNG.Height = 500;
     pNG.Width = 700;
     pNG.Save(saveFileDialog1.FileName);
     break;

[VB.Net]
Case 6
     Dim PNGf As Steema.TeeChart.Export.PNGFormat = TChart1.Export.Image.PNG
     PNGf.Compression = 100
     PNGf.GrayScale = True
     PNGf.Height = 500
     PNGf.Width = 700
     PNGf.Save(SaveFileDialog1.FileName)

TIFF

[C#] 
case 7:
     Steema.TeeChart.Export.TIFFFormat tIFF = tChart1.Export.Image.TIFF;
     tIFF.Compression = Steema.TeeChart.Export.TIFFFormat.TIFFCompression.LZW;
     tIFF.Height = 500;
     tIFF.Width = 700;
     tIFF.Save(saveFileDialog1.FileName);
     break;

[VB.Net]
Case 7
     Dim TIFF As Steema.TeeChart.Export.TIFFFormat = TChart1.Export.Image.TIFF
     TIFF.Compression = Steema.TeeChart.Export.TIFFFormat.TIFFCompression.LZW
     TIFF.Height = 500
     TIFF.Width = 700
     TIFF.Save(SaveFileDialog1.FileName)

Adobe Flex/Flash/SWF

Exporting data

Formats

  • Text: TextFormat Class
  • XML: XMLFormat Class
  • HTML: HTMLFormat Class
  • Excel: ExcelFormat Class
[C#] 
private void Form1_Load(object sender, System.EventArgs e)
            Random rnd = new Random();
            char c = new char();

            for(int i = 0; i < 10; i)
                c = Convert.ToChar(65 i);
                bar1.Add(Convert.ToDouble(i),rnd.Next(100),c.ToString(),Color.Red);
            
            Steema.TeeChart.Export.DataExport dataExport = new Steema.TeeChart.Export.DataExport(tChart1.Chart);
            dataExport.HTML.IncludeHeader = true;
            dataExport.HTML.IncludeIndex = true;
            dataExport.HTML.IncludeLabels = true;
            dataExport.HTML.Series = bar1;
            dataExport.HTML.Save(@"C:.htm");
        

[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim C As New Char()
            Dim i As New Integer()

            For i = 0 To 10
                C = Convert.ToChar(65 i)
                Bar1.Add(Convert.ToDouble(i), Rnd() * 100, C.ToString(), Color.Red)
            Next
            Dim DataExport As New Steema.TeeChart.Export.DataExport(TChart1.Chart)
            DataExport.HTML.IncludeHeader = True
            DataExport.HTML.IncludeIndex = True
            DataExport.HTML.IncludeLabels = True
            DataExport.HTML.Series = Bar1
            DataExport.HTML.Save("C:.htm")
End Sub


TeeChart's 'Ten' template and data export/import format

Ten files

  • Ten files are very small in size, in most cases that offers an advantage
        over pure graphic formats (qicker).
  • The destination Chart for the template is 'live', it can be zoomed and scrolled and have
      its properties modified.
  • Data may optionally be included with the ten template according to your preference.
[C#] 
private void button1_Click(object sender, System.EventArgs e)
            saveFileDialog1.Filter = "TenFile (.ten)|*.ten";
            saveFileDialog1.ShowDialog();
            if(saveFileDialog1.FileName != "")
                tChart1.Export.Template.IncludeData = true;
                tChart1.Export.Template.Save(saveFileDialog1.FileName);
            
        
[VB.Net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SaveFileDialog1.Filter = "TenFile (.ten)|*.ten"
        SaveFileDialog1.ShowDialog()
        If SaveFileDialog1.FileName <> "" Then
            TChart1.Export.Template.IncludeData = True
            TChart1.Export.Template.Save(SaveFileDialog1.FileName)
        End If
End Sub


Import

Importing XML into TeeChart

Example 
[C#]
protected override void button1_Click(object sender, System.EventArgs e)
            tChart1.Series.RemoveAllSeries();
            Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
            points1.Title = "Points Series";
            xmlSource1.Series = points1;
            xmlSource1.SeriesNode = "Points Series";
            xmlSource1.Load(textBox2.Text);

          tChart1.Refresh();


Example 
[C#]
protected override void button2_Click(object sender, System.EventArgs e)
            tChart1.Series.RemoveAllSeries();
            xmlSource1.Chart = tChart1.Chart;
            xmlSource1.Load("http://www.steema.com/SampleNETData.xml");

            tChart1.Refresh();
        

Importing Ten format files

Example Imports

Example

[C#] 
tChart1.Import.Template.LoadFileDialog();
[VB.Net]
TChart1.Import.Template.LoadFileDialog()
[C#] 
tChart1.Import.Template.FromURL("http://www.berneda.com/demo.ten");
[VB.Net]
TChart1.Import.Template.FromURL("http://www.berneda.com/demo.ten")
[C#] 
System.IO.MemoryStream tenStream = new System.IO.MemoryStream();
tChart1.Export.Template.Save(tenStream);
tChart2.Import.Template.Load(tenStream);
[VB.Net]
Dim TenStream As New System.IO.MemoryStream()
TChart1.Export.Template.Save(TenStream)
TChart2.Import.Template.Load(TenStream)

Effect of changes made in importing Chart

[C#] 
private void Form1_Load(object sender, System.EventArgs e)
        Bar bar1 = new Bar(tChart1.Chart);
        bar1.FillSampleValues(20);

private void button1_Click(object sender, System.EventArgs e)
        saveFileDialog1.Filter = "TenFile (.ten)|*.ten";
        saveFileDialog1.ShowDialog();
        if(saveFileDialog1.FileName != "")
            tChart1.Export.Template.IncludeData = true;
            tChart1.Export.Template.Save(saveFileDialog1.FileName);
        

private void button2_Click(object sender, System.EventArgs e)
        tChart1.Dispose();
        tChart1 = new Steema.TeeChart.TChart();
        ini_Chart();

private void ini_Chart()
        this.tChart1.Header.Lines = new string[] "TeeChart";
        this.tChart1.Location = new System.Drawing.Point(24, 24);
        this.tChart1.Name = "tChart1";
        this.tChart1.Size = new System.Drawing.Size(400, 240);
        this.tChart1.TabIndex = 5;
        this.Controls.AddRange(new System.Windows.Forms.Control[] this.tChart1);

private void button3_Click(object sender, System.EventArgs e)
        tChart1.Import.Template.LoadFileDialog();


[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Bar1 As New Steema.TeeChart.Styles.Bar(TChart1.Chart)
        Bar1.FillSampleValues(20)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SaveFileDialog1.Filter = "TenFile (.ten)|*.ten"
        SaveFileDialog1.ShowDialog()
        If Not SaveFileDialog1.FileName = "" Then
            TChart1.Export.Template.IncludeData = True
            TChart1.Export.Template.Save(SaveFileDialog1.FileName)
        End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TChart1.Dispose()
        TChart1 = New Steema.TeeChart.TChart()
        Ini_Chart()
End Sub
Private Sub Ini_Chart()
        Me.TChart1.Header.Lines = New String() "TeeChart"
        Me.TChart1.Location = New System.Drawing.Point(16, 16)
        Me.TChart1.Name = "TChart1"
        Me.TChart1.Size = New System.Drawing.Size(400, 296)
        Me.TChart1.TabIndex = 3
        Me.Controls.AddRange(New System.Windows.Forms.Control() Me.TChart1)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TChart1.Import.Template.LoadFileDialog()
End Sub

Other datasources

NETTutorial8-Database Access tutorial


PREVIOUS

NEXT


© 1998-2019 Steema Software SL. All rights reserved.