翻譯|使用教程|編輯:況魚杰|2019-08-06 16:25:43.393|閱讀 351 次
概述:本教程將介紹將圖表導(dǎo)出為圖形格式文件并使用TeeChart的T形格式模板的過程。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
TeeChart for PHP包含100%的PHP源代碼。它支持PHP5及更高的版本。它可作為一個(gè)調(diào)色板組件整合到針對(duì)PHP的Delphi編程環(huán)境中,從而讓其他人在運(yùn)行時(shí)以創(chuàng)建組件的方式來引用。第一個(gè)版本提供17種圖表類型(2D和3D的多種組合),11個(gè)數(shù)學(xué)函數(shù)和一些圖表工具組件以擴(kuò)展功能。
本教程是TeeChart for PHP教程中圖表的導(dǎo)出和導(dǎo)入這一節(jié)。本章節(jié)的內(nèi)容主要介紹如何以各種格式導(dǎo)出TeeCharts并導(dǎo)入TeeChart自己的.tee格式圖表模板。
導(dǎo)出圖表
可用格式
導(dǎo)出圖像
JPEG
GIF
PNG
導(dǎo)出數(shù)據(jù)
文本
XML
TeeChart的Tee模板和數(shù)據(jù)導(dǎo)出導(dǎo)入格式
Tee文件
導(dǎo)入
導(dǎo)入Tee格式文件
示例導(dǎo)入Tee文件
導(dǎo)出圖表
可用的導(dǎo)出格式
可以將所有格式復(fù)制到文件或剪貼板或流中。
圖像格式
JPEG:JPEGFormat類
GIF:GIFFormat類
PNG:PNGFormat類
WBMP:WBMPFormat類
數(shù)據(jù)格式
Text:TextFormat類
XML:XMLFormat類
HTML:HTMLFormat類
Excel:ExcelFormat類
其他格式
Tee格式是一種靈活的格式,可存儲(chǔ)圖表屬性信息和(可選)圖表數(shù)據(jù)。它的文件很小(取決于數(shù)據(jù)),非常適合網(wǎng)絡(luò)用于更新基于實(shí)時(shí)客戶端的圖表。
示例導(dǎo)出
可以合理導(dǎo)出到文件,在大多數(shù)情況下,您只需要定義目標(biāo)文件名。
With SaveDialog1 do if Execute then Chart1.SaveToBitmapFile(SaveDialog1.FileName);
JPG
JPEG文件導(dǎo)出具有速度和質(zhì)量的附加參數(shù)。
$tmpResult = fc.showSaveDialog(JpegExportDemo.this); if (tmpResult == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String tmpName = file.getAbsolutePath(); if (!ExportUtils.isExtension(file, ExportUtils.JPG)) { tmpName = ExportUtils.replaceExtension(file, ExportUtils.JPG); } myChart.getExport().getImage().getJPEG().save(tmpName); }
性能,jpegBestQuality和壓縮質(zhì)量百分比(高值減去壓縮)的存在將使文件更大,導(dǎo)出花費(fèi)的時(shí)間會(huì)更長,但是導(dǎo)出的效果會(huì)更好,可以根據(jù)自己的需求來選擇。
GIF
TeeChart提供了創(chuàng)建GIF圖表圖像的方法,但您應(yīng)該使用Unisys檢查您的許可位置,以便使用GIF LZW編碼圖像。替代RLE編碼不受Unisys許可的約束。
int tmpResult = fc.showSaveDialog(GifExportDemo.this); if (tmpResult == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String tmpName = file.getAbsolutePath(); if (!ExportUtils.isExtension(file, ExportUtils.GIF)) { tmpName = ExportUtils.replaceExtension(file, ExportUtils.GIF); } myChart.getExport().getImage().getGIF().save(tmpName); }
PNG
PNG格式保留了GIF格式的許多優(yōu)點(diǎn),但也提供了超出GIF格式的功能。PNG改進(jìn)了GIF逐步顯示圖像的能力,也就是說,當(dāng)圖像通過網(wǎng)絡(luò)連接到達(dá)時(shí),能夠顯示更好的圖像近似值。
int tmpResult = fc.showSaveDialog(PngExportDemo.this); if (tmpResult == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String tmpName = file.getAbsolutePath(); if (!ExportUtils.isExtension(file, ExportUtils.PNG)) { tmpName = ExportUtils.replaceExtension(file, ExportUtils.PNG); } myChart.getExport().getImage().getPNG().save(tmpName); }
導(dǎo)出數(shù)據(jù)
以下示例以Text或XML格式從Chart Series導(dǎo)出的數(shù)據(jù)。它們可以創(chuàng)建并與圖表系列相關(guān)聯(lián),從中可以將數(shù)據(jù)導(dǎo)出為文件,流或剪貼板。
文本文件
try { $myChart->getExport()->getData()->getText()->save($tmpName); }
XML文件
try { $myChart->getExport()->getTemplate()->toXML($tmpName); $showSavedFile(tmpName); }
TeeChart的Tee模板和數(shù)據(jù)導(dǎo)出/導(dǎo)入格式
Tee文件
Tee文件是TeeChart自己的模板格式,用于保存圖表及其數(shù)據(jù),并在Java IDE中具有.tej的擴(kuò)展名。修改的圖表屬性隨模板一起保存,并在將模板導(dǎo)入新圖表時(shí)重現(xiàn)。
好處:
Tep文件的大小非常小,在大多數(shù)情況下,它比純圖形格式(Quicker)更具優(yōu)勢(shì)。
模板的目標(biāo)圖表是實(shí)時(shí),可以進(jìn)行縮放和滾動(dòng),并修改其屬性。
根據(jù)您的喜好,可以選擇是否將數(shù)據(jù)包含在Tee模板中。
try { $tChart1->getExport()->getTemplate()->toFile("/temp/chart1.tep"); } catch (IOException ex1) { ex1.printStackTrace(); }
導(dǎo)入
從URL導(dǎo)入XML,顯示如何從/向xml導(dǎo)出和加載的示例:
Save to xml; try { $myChart->getExport()->getTemplate()->toXML($tmpName); showSavedFile($tmpName); } catch (FileNotFoundException $e) { System.out.println(e); } Load from xml: try { $myChart->setChart($myChart->getImport()->getTemplate()->fromXML($tmpName)); $myChart->repaint(); } catch (FileNotFoundException $e) { System.out.println(e); }
導(dǎo)入Tee格式文件
從本地文件源或http數(shù)據(jù)源導(dǎo)入已保存的文件。導(dǎo)入示例:
import from file $tChart1->getImport()->getTemplate()->fromFile("myFile.tep"); or XML.. $tChart1->getImport()->getTemplate()->fromXML("myFile.xml"); or Stream.. try { //( 1) Save the template into a Stream... ByteArrayOutputStream m = new ByteArrayOutputStream(); $myChart->getExport()->getTemplate()->toStream($m); //( 2) Load the template into other Chart... $copyChart->setChart($copyChart->getImport()->getTemplate()->fromStream( new ByteArrayInputStream(m.toByteArray()) )); //( 3) repaint the Chart $copyChart->repaint(); } catch (IOException $ex) { System.out.println(ex); } catch (ClassNotFoundException $ex) { System.out.println(ex); }
本節(jié)教程就到這里了,下一章我們將會(huì)介紹如何在圖表面板上自定義繪圖。
TeeChart for .NET,TeeChart for JavaScript/HTML5,TeeChart for Xamarin.Android均已加入在線訂購,現(xiàn)在搶購可立享特別優(yōu)惠!!!
關(guān)注慧聚IT微信公眾號(hào)???,了解產(chǎn)品的最新動(dòng)態(tài)及最新資訊。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自: