<script type="text/javascript"> google_ad_client = "pub-8800625213955058"; /* 336x280, 创建于 07-11-21 */ google_ad_slot = "0989131976"; google_ad_width = 336; google_ad_height = 280; // </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> 最近项目中用到jfreechart,使用的版本是:jfreechart-0.9.8。 如果不进行相关的font的设置,生成的统计图表显示的中文非常模糊。 做了一个例子,可以成功的解决这个问题,拿来与大家共享。 核心代码如下: JFreeChart chart = ChartFactory.createVerticalBarChart3D(title, domain, range, dataset,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); StandardLegend 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中的中文显示问题
最新推荐文章于 2023-03-25 21:40:59 发布