将坐标图和饼状图中的中文乱码问题解决了,只要做如下配置:
/**
* 配置字体 解决导出图中的中文乱码问题
*
* @param chart
* JFreeChart 对象
*/
public static void configFont(JFreeChart chart) {
// 配置字体
Font font = new Font("宋体", Font.BOLD, 25);
chart.getTitle().setFont(font);
if (chart.getLegend() != null) {
chart.getLegend().setItemFont(font);
}
if (chart.getPlot() instanceof CategoryPlot) {
chart.getCategoryPlot().getDomainAxis().setLabelFont(font);
chart.getCategoryPlot().getDomainAxis().setTickLabelFont(font);
chart.getCategoryPlot().getRangeAxis().setLabelFont(font);
chart.getCategoryPlot().getRangeAxis().setTickLabelFont(font);
} else if (chart.getPlot() instanceof XYPlot) {
if (chart.getXYPlot().getDomainAxis() != null) {
chart.getXYPlot().getDomainAxis().setLabelFont(font);
chart.getXYPlot().getDomainAxis().setTickLabelFont(font);
}
if (chart.getXYPlot().getRangeAxis() != null) {
chart.getXYPlot().getRangeAxis().setLabelFont(font);
chart.getXYPlot().getRangeAxis().setTickLabelFont(font);
}
} else if (chart.getPlot() instanceof PiePlot) {
((PiePlot3D) chart.getPlot()).setLabelFont(font);
}
// 设置背景色
chart.setBackgroundPaint(Color.WHITE);
}
分享到:
相关推荐
自己将jfreechart常用的、柱状图、折线图、饼状图(二维的和三维的)对官网的dome进行了封装和加强,解决了高版本中文乱码问题,数值显示问题、及怎么显示百分比
支持自定义字体,一般不需修改,本例分别为宋体和黑体 如要修改请打开 org/jfree/chart/LocalizationBundle.properties, ...properties文件请用相关的工具修改,不可直接输入中文,需转为unicode字符
NULL 博文链接:https://xxqn.iteye.com/blog/824617
JFreeChart-1.0.13原文件含jar包。 1、JFreeChart生成图片路径教程 2、JFreeChart使用教程(含下载安装,超详细) 3、JFreeChart使用详细教程 ...5、JFreeChart乱码解决方法 等等 包括许多优秀案例
绝对物超所值! JFreeChart-1.0.13原文件含jar包。 1、JFreeChart生成图片路径教程 2、JFreeChart使用教程(含下载安装,超详细...5、JFreeChart乱码解决方法 等等 包括csdn上得优秀案例 ------20+M的数据不要别后悔哦
0.7版本的代码统计生成...statsvn0.7采用的是jfreechart1.0.13所以乱码问题归结为jfree 由于jfree里字体默认为SansSerif(不支持中文显示),所以要对其进行hack。这里是hack完以后的statsvn.jar(0.7版本)可直接使用
jfreechart1.0.13,因为版本的问题会有中文乱码,但是拿来学习用
jfreechartzh_cn1.0.13.rar 解决了中文乱码问题
使用JFreeChart,必须调用在web-inf目录下导入...使用jfreechart-1.0.13.jar查看图表时中文乱码,降低jfreechart版本ok 显示图表时都可以在获取JfreeChart对象方法中使用3D方式 jfreechart只支持jpg,jpeg,png格式图片