没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:王香|2018-09-20 16:23:45.000|阅读 451 次
概述:本文详细介绍了在TeeChart for Java使用代码导出和导入图表。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
【下载TeeChart for Java最新版本】
可以将所有格式复制到文件或剪贴板或Stream。
Tej格式是一种灵活的格式,可存储图表属性信息以及(可选)图表数据。文件很小(取决于数据),非常适合网络用于更新基于实时客户端的图表。
导出到文件是合理的,在大多数情况下,您只需要定义目标文件名,例:
try {
tChart1.getExport().getImage().getBMP().save(fileName);
} catch (IOException ex) {
System.out.println(ex);
}
JPEG文件导出具有速度和质量的附加参数,例:
int 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);
}
代码示例:
int tmpResult = fc.showSaveDialog(BmpExportDemo.this);
if (tmpResult == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
String tmpName = file.getAbsolutePath();
if (!ExportUtils.isExtension(file, ExportUtils.BMP)) {
tmpName = ExportUtils.replaceExtension(file, ExportUtils.BMP);
}
myChart.getExport().getImage().getBMP().save(tmpName);
}
PNG格式保留了GIF格式的许多优点,但也提供了超出GIF格式的功能。PNG改进了GIF逐步显示图像的能力; 也就是说,当图像通过网络连接到达时,显示更好和更好的图像近似值,例:
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);
}
以下示例以Text或XML格式从Chart Series导出数据。它们可以创建并与图表系列相关联,从中可以将数据导出为文件,流或剪贴板。
try {
myChart.getExport().getData().getText().save(tmpName);
}
try {
myChart.getExport().getTemplate().toXML(tmpName);
showSavedFile(tmpName);
}
Tej文件是TeeChart自己的模板格式,用于保存图表及其数据,并在Java IDE中具有.tej扩展名。修改的图表属性随模板一起保存,并在模板导入新图表时重现,优点:
try {
tChart1.getExport().getTemplate().toFile("/temp/chart1.tej");
} catch (IOException ex1) {
ex1.printStackTrace();
}
显示如何从xml导出和加载的示例:
保存到xml
try {
myChart.getExport().getTemplate().toXML(tmpName);
showSavedFile(tmpName);
} catch (FileNotFoundException e) {
System.out.println(e);
}
从XML加载
try {
myChart.setChart(myChart.getImport().getTemplate().fromXML(tmpName));
myChart.repaint();
}
catch (FileNotFoundException e) {
System.out.println(e);
}
从本地文件源或http数据源导入已保存的Tej文件。
文件导入
tChart1.getImport().getTemplate().fromFile("myFile.tej");
XML
tChart1.getImport().getTemplate().fromXML("myFile.xml");
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);
}
购买TeeChart for Java正版授权,请点击“”哟!
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn




本文将为大家介绍一些MyEclipse开发过程中能用到的EJB开发工具,欢迎下载最新版体验!
本文主要介绍如何在MVVM应用程序中使用虚拟源,欢迎下载最新版组件体验!
Parasoft C/C++test是一款功能强大的代码测试与分析工具,专为提升代码质量、确保软件安全与可靠性而设计。要在 Ubuntu 桌面环境中使用这一强大的工具,第一步就是完成其安装与许可证配置。
注意: Cogent DataHub 软件 v11 包含一些新功能,您的目标操作系统可能不支持这些功能。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@ke049m.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
半岛外围网上直营 