JFreeChart笔记-中文乱码解决方法
2010-09-09 21:14
435 查看
中文乱码解决方法:
原因:JFreeChart默认选用的字体不支持中文解决:通过setFont()手动设置出现乱码部分的字体
饼图(PiePlot):
标题部分:chart.getTitle().setFont(new Font("黑体",Font.BOLD,20));//设置标题字体
图表区域:
PiePlot piePlot= (PiePlot) chart.getPlot();//获取图表区域对象
piePlot.setLabelFont(new Font("黑体",Font.BOLD,10));
Legend部分:
chart.getLegend().setItemFont(new Font("黑体",Font.BOLD,10));
柱状图(CategoryPlot): CategoryPlot plot=chart.getCategoryPlot();//获取图表区域对象 CategoryAxis domainAxis=plot.getDomainAxis(); //水平底部列表 domainAxis.setLabelFont(new Font("黑体",Font.BOLD,14)); //水平底部标题 domainAxis.setTickLabelFont(new Font("宋体",Font.BOLD,12)); //垂直标题 ValueAxis rangeAxis=plot.getRangeAxis();//获取柱状 rangeAxis.setLabelFont(new Font("黑体",Font.BOLD,15)); chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15)); 饼图(PiePlot): JFreeChart chart = ChartFactory.createPieChart3D("IT行业职业分布图", dataset, true, false, false); chart.getTitle().setFont(new Font("黑体",Font.BOLD,20));//设置标题字体 PiePlot piePlot= (PiePlot) chart.getPlot();//获取图表区域对象 piePlot.setLabelFont(new Font("黑体",Font.BOLD,10)); chart.getLegend().setItemFont(new Font("黑体",Font.BOLD,10)); 时序图(TimeSeries) XYPlot plot = (XYPlot) chart.getPlot(); //纵轴字体 plot.getRangeAxis().setLabelFont(new Font("宋体", Font.BOLD, 15)); //横轴框里的标题字体 chart.getLegend().setItemFont(new Font("宋体", Font.ITALIC, 15)); //横轴列表字体 plot.getDomainAxis().setTickLabelFont(new Font("新宋体", 1, 15)); //横轴小标题字体 plot.getDomainAxis().setLabelFont(new Font("新宋体", 1, 12)); 折线图 chart.getTitle().setFont(new Font("宋体", Font.BOLD, 15)); chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15)); CategoryAxis domainAxis = plot.getDomainAxis(); /*------设置X轴坐标上的文字-----------*/ domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 11)); /*------设置X轴的标题文字------------*/ domainAxis.setLabelFont(new Font("宋体", Font.PLAIN, 12)); NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis(); /*------设置Y轴坐标上的文字-----------*/ numberaxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 12)); /*------设置Y轴的标题文字------------*/ numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12))
相关文章推荐
- Jfreechart中文乱码解决方法
- JFreeChart学习笔记--解决中文乱码
- 20160324servlet学习笔记HttpServletRequest对象中文乱码解决方法
- jfreechart linux图片中文显示乱码解决方法
- 笔记:Linux SSH 中文乱码解决方法
- JFreeChart中文乱码的解决方法
- jfreechart linux图片中文显示乱码解决方法
- JFreechart 中文乱码 解决方法
- jfreechart linux图片中文显示乱码解决方法
- JFreeChart 中文乱码 一站式解决 一个方法搞定
- 笔记:Linux SSH 中文乱码解决方法
- JFreeChart中文乱码解决方法
- oracle中文乱码解决方法笔记
- struts2+spring+hibernate+json+jquery+flexigrid开发笔记-中文乱码解决方法
- JFreeChart中文乱码解决方法
- JFreeChart生成折线图(生成图片本地保存,有解决中文乱码的通用方法)
- eclipse_php类和函数提示的中文部分为乱码,成功解决方法
- get请求中的中文乱码问题的解决方法
- qt编写的android程序在android系统中运行,中文显示乱码的解决方法
- 页面间传输中文的乱码解决方法