从网上下载最新的JFreeChart版本
如图:进行调试的时候出现乱码
源代码如下:package test;import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;public class TestJFreeChart { public static void main(String[] args) {
DefaultPieDataset dpd = new DefaultPieDataset();
dpd.setValue( "管理人员" , 30 );
dpd.setValue( "开发人员" , 50 );
dpd.setValue( "销售人员" , 42 );
dpd.setValue( "策划人员" , 15 );
JFreeChart chart = ChartFactory.createPieChart( "公司人员分布图" , dpd , true , true , true );
ChartFrame cf = new ChartFrame( "某公司人员分布图" , chart );
cf.pack();
cf.setVisible( true ); }}运行效果如图:
如图:进行调试的时候出现乱码
源代码如下:package test;import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;public class TestJFreeChart { public static void main(String[] args) {
DefaultPieDataset dpd = new DefaultPieDataset();
dpd.setValue( "管理人员" , 30 );
dpd.setValue( "开发人员" , 50 );
dpd.setValue( "销售人员" , 42 );
dpd.setValue( "策划人员" , 15 );
JFreeChart chart = ChartFactory.createPieChart( "公司人员分布图" , dpd , true , true , true );
ChartFrame cf = new ChartFrame( "某公司人员分布图" , chart );
cf.pack();
cf.setVisible( true ); }}运行效果如图:
但是JFreeChart不能够显示中文
当鼠标放到饼图上面的时候
却可以显示中文的提示信息
请高手指教
1、该版本JFreeChar的问题(我用的是1.0.10)
2、其它原因……
如果确定不是版本的问题,再进一步寻找其它原因。另外,是不是某些包未导入的原因?
楼主可以参考一下我导入的jar文件列表:gnujaxp.jar
iText-2.1.1.jar
jcommon-1.0.13.jar
jfreechart-1.0.10-experimental.jar
jfreechart-1.0.10-swt.jar
jfreechart-1.0.10.jar
swtgraphics2d.jar
比如源码中有
setFont(new Font(xxx, Font.PLAIN, 18));
把xxx改为宋体改源码不好,但是只改了字体不改逻辑,无所谓了,总比显示不出来字强。
具体在哪ge包中的哪个Java文件中
请指明
查考如下吧http://www.chinaitpower.com/A200507/2005-07-27/172324.html
http://topic.csdn.net/u/20080924/14/dfca3ea4-d61f-4b68-98d0-ea15200a169c.html
但是用JFreeChart1.0.11的修改源代码后依旧不能正常显示中文
不知道为什么
Font font12 = new Font("宋体",Font.BOLD,12);chart.getTitle().setFont(font20);
PiePlot plot = (PiePlot)chart.getPlot();
plot.setLabelFont(font12);
plot.getDomainAxis().setTickLabelFont(font); //x轴刻度字体
plot.getRangeAxis().setLabelFont(font); //y轴外围字体
plot.getRangeAxis().setTickLabelFont(font); //y轴刻度字体
jfreechart.getTitle().setFont(new Font("宋体", Font.CENTER_BASELINE, 20)); //标题字体
jfreechart.getLegend().setItemFont(font); //设置最底下方框内的字体
txtTitle = jf.getTitle();
txtTitle.setFont(font);
PiePlot pieplot = (PiePlot)jf.getPlot();
pieplot.setLabelFont(font);
jf.getLegend().setItemFont(font);