我是转载别人的,不知道能不能,试一下吧!
最近项目中用到jfreechart,使用的版本是:jfreechart-0.9.8。
如果不进行相关的font的设置,生成的统计图表显示的中文非常模糊。
做了一个例子,可以成功的解决这个问题,拿来与大家共享。核心代码如下:JFreeChart chart = ChartFactory.createVerticalBarChart3Ddataset,true,true,false);chart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 1000F, 0.0F, Color.red));
chart.setTitle(new TextTitle(title, new Font("隶书", Font.ITALIC, 15)));Font font=new Font("黑体",Font.TRUETYPE_FONT, 12);SStandardLegend legend = (StandardLegend) chart.getLegend();
legend.setItemFont(font);CategoryPlot plot = (CategoryPlot)chart.getPlot();
plot.setForegroundAlpha(0.9F);CategoryAxis domain_axis = plot.getDomainAxis();
domain_axis.setTickLabelFont(font);ValueAxis value_axis=plot.getRangeAxis();
value_axis.setTickLabelFont(font);
最近项目中用到jfreechart,使用的版本是:jfreechart-0.9.8。
如果不进行相关的font的设置,生成的统计图表显示的中文非常模糊。
做了一个例子,可以成功的解决这个问题,拿来与大家共享。核心代码如下:JFreeChart chart = ChartFactory.createVerticalBarChart3Ddataset,true,true,false);chart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 1000F, 0.0F, Color.red));
chart.setTitle(new TextTitle(title, new Font("隶书", Font.ITALIC, 15)));Font font=new Font("黑体",Font.TRUETYPE_FONT, 12);SStandardLegend legend = (StandardLegend) chart.getLegend();
legend.setItemFont(font);CategoryPlot plot = (CategoryPlot)chart.getPlot();
plot.setForegroundAlpha(0.9F);CategoryAxis domain_axis = plot.getDomainAxis();
domain_axis.setTickLabelFont(font);ValueAxis value_axis=plot.getRangeAxis();
value_axis.setTickLabelFont(font);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货