![]() |
Contents page Previous | Next |
This tutorial is overviews exporting TeeCharts in various formats and importing TeeChart's own .tee format Chart templates. See the Visual Basic 6 "Import from file" example code in the Examples folder below your TeeChart installation folder.
Available Export formats. All formats may be copied to either a file or Clipboard or to a Stream.
Image formats
BMP | IBMPExport Class |
JPEG | IJPEGExport Class |
WMF & EMF | IMetafileExport Class |
GIF | IGIFExport Class |
PNG | IPNGExport Class |
PCX | IPCXExport Class |
IPDFExport Class | |
PostScript | IEPSExport Class |
Data formats
Text | ITextExport Class |
XML | IXMLExport Class |
HTML | IHTMLExport Class |
Excel | IXLSExport Class |
Other formats
Tee 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.
TEE (TeeChart) | INativeExport Class |
ShowExport
method.Example
Private Sub Command1_Click() TChart1.Export.ShowExport End Sub
Exporting to a file is reasonable straightforward, in most cases you just need to define the destination filename.
Example
With CommonDialog1 .Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|Images(*.emf)|*.emf |Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.pcx)|*.pcx|Images(*.eps)|*.eps|Images(*.pdf)|*.pdf" .ShowSave If .FileName <> "" Then Select Case .FilterIndex Case 1 TChart1.Export.asBMP.SaveToFile (.FileName) Case 2 TChart1.Export.asJPEG.SaveToFile (.FileName) Case 3 TChart1.Export.asMetafile.SaveToFile (.FileName) Case 4 TChart1.Export.asMetafile.Enhanced = True TChart1.Export.asMetafile.SaveToFile (.FileName) Case 5 TChart1.Export.asGIF.SaveToFile (.FileName) Case 6 TChart1.Export.asPNG.SaveToFile (.FileName) Case 7 TChart1.Export.asPCX.SaveToFile (.FileName) Case 8 TChart1.Export.asEPS.SaveToFile (.FileName) Case 9 TChart1.Export.asPDF.SaveToFile (.FileName) End Select End If End With
BMP file export has additional parameters for colours and size.
Example
With TChart1.Export .asBMP.Colors = pfDevice .asBMP.Height = 400 .asBMP.Monochrome = False .asBMP.Width = 500 .asBMP.SaveToFile "C:\TestFiles\MyTeeChart.png" End With
JPEG file export now has parameters for speed and quality for both SaveToFile and SaveToStream.
Example
With TChart1.Export .asJPEG.CompressionQuality = 90 .asJPEG.GrayScale = False .asJPEG.Height = 400 .asJPEG.Width = 500 .asJPEG.SaveToFile "C:\TestFiles\MyTeeChart.png" End With
The CompressionQuality value (from 1 - 100) will make the file larger and thus slower to transmit across a network - quality is better though ! You will need to decide on the best balance to suit your application.
Enhanced Metafiles are simply created by setting "Enhanced" to True.
Example
With TChart1.Export .asMetafile.Enhanced = True .asMetafile.Height = 400 .asMetafile.Width = 500 .asMetafile.SaveToFile "C:\TestFiles\MyTeeChart.emf" End With
GIF support is included with TeeChart courtesy of Anders Melander's Delphi GIFImage classes ((c) 1997-99 Anders Melander). Full documentation for the GIF classes are outside the scope of TeeChart's own documentation. Anders has donated GIFImage to the Jedi project who now co-ordinate documentation and support for it.
*Important Notice
TeeChart provides the means to create GIF Chart images but LZW compression has been disabled until the use and licensing of LZW has been completely clarified with Unisys. Unisys's position on LZW licensing has led us to the interim conclusion (unfortunately) that by not including LZW we protect ourselves and our customers against unexpected licensing battles with Unisys at a later stage. TeeChart continues to support GIF with RLE compression which is not subject to Unisys license. We will be happy to discuss the issue with any customer who feels that they need to use LZW and to make a joint approach to Unisys to clarify the license position.
The image format PNG is superior in many respects to GIF with LZW, particularly in the case of TeeChart where animations are not exported. We recommend the use of PNG where possible.
See Unisys and LZW for more information on use of GIF LZW encoded images.Example
With TChart1.Export .asGIF.ColorReduction = rmWindows256 .asGIF.Compression = gcRLE .asGIF.DitherMode = dmStucki .asGIF.Height = 400 .asGIF.Width = 500 .asGIF.SaveToFile "C:\TestFiles\MyTeeChart.png" End With
PNG provides a compressed image format that is supported by all principle browsers.
Example
With TChart1.Export .asPNG.CompressionLevel = 10 .asPNG.Height = 400 .asPNG.Width = 500 .asPNG.SaveToFile "C:\TestFiles\MyTeeChart.png" End With
IPCXExport uses the PCX unit Copyright Software Matters Inc. 1999. Please see their web www.smatter.com for more information.
Example
With TChart1.Export .asPCX.Height = 400 .asPCX.Width = 500 .asPCX.SaveToFile "C:\TestFiles\MyTeeChart.pcx" End With
Use IPDFExport to generate PDF (Adobe Portable Document Format) files from TChart controls. For more information about PDF format please see http://www.adobe.com/products/acrobat/adobepdf.html. PDF is copyright Adobe Systems Incorporated. All rights reserved.
Example
With TChart1.Export .asPDF.Height = 400 .asPDF.Width = 500 .asPDF.SaveToFile "C:\TestFiles\MyTeeChart.pdf" End With
Use TeeChart's IFlexExport interface to generate Flash Charts. TeeChart's creates Flash (see About Flash at the Adobe Web) Charts via Adobe's Flex compiler (see About Flex at the Adobe Web). The Flex compiler is freely available for download from Adobe.
To use TeeChart with Flex:
Example
Private Sub Command1_Click() Dim tmpFolder Dim FlexBinFolder tmpFolder = "c:\tmp" FlexBinFolder = "c:\Flex3\bin" myWidth = 100 myHeight= 200 ' The following line creates the Flex code and compiles it to Flash ' and then shows the result on a browser page TChart1.Export.asFlex.CompileDeleteShow myWidth, myHeight, tmpFolder, _ TChart1.Name, FlexBinFolder, True, True, True End Sub
Some animations may be included with your Flash Chart. By adding a MarksTip tool to the Chart and activating the Expand animation when moving the mouseover the pointers on the Flash Chart, the pointers will expand and show a MarkToolTip.
Example
With TChart1 .Series(0).FillSampleValues (8) .Legend.Visible = False .Tools.Add tcMarksTip .Tools.Items(0).asMarksTip.Series = TChart1.Series(0) .Animations.Add tcExpand .Animations.Items(0).asExpand.Target = cpSeriesPointer .Animations.Items(0).asExpand.Trigger = atMouseOver End With
TeeChart used for Flash output is ideal to include a small, 'CompactChart' to accompany editorial written content but any size Chart may be produced by this technique.
Flex and Flash are copyrights Adobe Systems Incorporated. All rights reserved.
Use IEPSExport to export TeeCharts to EPS (Encapsulated PostScript) format.
Example
With TChart1.Export .asEPS.Height = 400 .asEPS.Width = 500 .asEPS.SaveToFile "C:\TestFiles\MyTeeChart.eps" End With
There are four Export formats for Series data:
Text | ITextExport Class |
XML | IXMLExport Class |
HTML | IHTMLExport Class |
Excel | IXLSExport Class |
The above components may be associated with a Chart Series from which they can export data as either File, Stream or to the Clipboard. The following example exports the data from a Chart Series to an HTML table:
With TChart1.Export .asHTML.IncludeHeader = True .asHTML.IncludeIndex = True .asHTML.IncludeLabels = True .asHTML.Series = 0 .asHTML.SaveToFile "C:\TestFiles\MyTeeChart.htm" End With
The output of the above with a random dataset is the following:
Index | Text | Series0 |
0 | MyLabel 0 | 1,953125 |
1 | MyLabel 1 | 70,5547511577606 |
2 | MyLabel 2 | 53,3424019813538 |
3 | MyLabel 3 | 57,9518616199493 |
4 | MyLabel 4 | 28,9562463760376 |
5 | MyLabel 5 | 30,1948010921478 |
6 | MyLabel 6 | 77,4740099906921 |
7 | MyLabel 7 | 1,4017641544342 |
8 | MyLabel 8 | 76,072359085083 |
9 | MyLabel 9 | 81,4490020275116 |
10 | MyLabel 10 | 70,9037899971008 |
Tee files are TeeChart's own template format for saving Charts and their data. Modified Chart properties are saved with the template and reproduced when the template is imported to a new Chart.
Advantages:
Tee files are particularly useful in distributed Charting applications and offer the possibility to offer Web browser OLE/ODBC applications where the OLE/ODBC DSN resides only at the server. See the Internet Applications tutorial.
Example
With CommonDialog1 .Filter = "TeeFile (.tee)|*.tee" .ShowSave If .FileName <> "" Then TChart1.Export.asNative.SaveToFile .FileName, True End If End With
Import a saved Tee file from a local file source or http data source.
Example
'import from file With CommonDialog1 .Filter = "Images (.tee)|*.tee" .ShowOpen If .filename <> "" Then TChart2.Import.LoadFromFile (.filename) End If End With 'or 'URL.. TChart2.Import.LoadFromURL "http://mywebserver.domain/myteefile.tee" 'or 'Stream.. Dim MyStream As Variant MyStream = TChart1.Export.asNative.SaveToStream(True) TChart2.Import.LoadFromStream MyStream
As .tee files only save changes to the standard Chart definition, if the destination Chart includes property changes not touched upon with the Chart to be imported, the originals will carry through. An example would be a Chart Footer. If the .tee file has not had the Footer set and the destination Chart does have, then the Footer will show through the Chart after importation. That may be a desirable result. If you expect changes to be made to the importing Chart that could adversely affect the desired result after a Chart has been imported into it, then you can use the ClearChart method before importation.
Example
Dim MyStream As Variant MyStream = TChart1.Export.asNative.SaveToStream(True) TChart2.ClearChart TChart2.Import.LoadFromStream MyStream
Tee files may be imported from remote web sources via the LoadChartFromURL method. CSV data may be imported via the ISeriesTextSource component and XML data may be imported via the SeriesXMLSource component. The CrossTabSource component connects to any dataset and automatically creates series from database data, using Group and Label fields and formula (sum or count values). Please see the TeeChart's Additional palette components for more information.
For information about data import from other database information sources please see the Database Access tutorial.
![]() |
![]() |