Jfreechart中文乱码解决方法
来源:互联网 发布:基础教育网络教研平台 编辑:程序博客网 时间:2024/04/29 19:10
在制图前,创建主题样式并制定样式中的字体,通过ChartFactory的setChartTheme()方法设置主题样式。
package com.zzs.jfreechart.demo; import java.awt.Font; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.chart.StandardChartTheme; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.title.LegendTitle; import org.jfree.chart.title.TextTitle; import org.jfree.data.category.DefaultCategoryDataset; public class JfreeChartTest { public static void main(String[] args) { // 创建类别图(Category)数据对象 DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(100, "北京", "苹果"); dataset.addValue(100, "上海", "苹果"); dataset.addValue(100, "广州", "苹果"); dataset.addValue(200, "北京", "梨子"); dataset.addValue(200, "上海", "梨子"); dataset.addValue(200, "广州", "梨子"); dataset.addValue(300, "北京", "葡萄"); dataset.addValue(300, "上海", "葡萄"); dataset.addValue(300, "广州", "葡萄"); dataset.addValue(400, "北京", "香蕉"); dataset.addValue(400, "上海", "香蕉"); dataset.addValue(400, "广州", "香蕉"); dataset.addValue(500, "北京", "荔枝"); dataset.addValue(500, "上海", "荔枝"); dataset.addValue(500, "广州", "荔枝"); //创建主题样式 StandardChartTheme standardChartTheme=new StandardChartTheme("CN"); //设置标题字体 standardChartTheme.setExtraLargeFont(new Font("隶书",Font.BOLD,20)); //设置图例的字体 standardChartTheme.setRegularFont(new Font("宋书",Font.PLAIN,15)); //设置轴向的字体 standardChartTheme.setLargeFont(new Font("宋书",Font.PLAIN,15)); //应用主题样式 ChartFactory.setChartTheme(standardChartTheme); JFreeChart chart=ChartFactory.createBarChart3D("水果产量图", "水果", "水果", dataset, PlotOrientation.VERTICAL, true, true, true); // TextTitle textTitle = chart.getTitle(); // textTitle.setFont(new Font("宋体", Font.BOLD, 20)); // LegendTitle legend = chart.getLegend(); // if (legend != null) { // legend.setItemFont(new Font("宋体", Font.BOLD, 20)); // } ChartFrame frame=new ChartFrame ("水果产量图 ",chart,true); frame.pack(); frame.setVisible(true); } }
- JFreeChart中文乱码解决方法
- Jfreechart中文乱码解决方法
- JFreeChart中文乱码解决方法
- JFreechart 中文乱码 解决方法
- JFreeChart中文乱码的解决方法
- JFreeChart笔记-中文乱码解决方法
- jfreechart linux图片中文显示乱码解决方法
- JFreeChart乱码解决方法
- JFreeChart乱码解决方法
- JFreeChart乱码解决方法
- JFreeChart乱码解决方法
- JFreeChart乱码解决方法
- JFreeChart乱码解决方法
- JFreeChart乱码解决方法
- JFreeChart乱码解决方法
- jfreechart中文乱码解决方案
- JFreeChart 中文乱码问题
- JfreeChart中文乱码
- ubuntu12.04安装kde桌面环境
- mongo的常用操作
- png图片的制作方法
- 第十五周 字典的应用
- Linux 用户和用户组配置说明
- Jfreechart中文乱码解决方法
- 使用 JFreeChart 来创建基于 web 的图表
- Struts2----通配符
- java中excel导入各种类型取值
- httpPpost的params抽取
- 两类 计算器
- LCD与LED液晶显示屏
- imageNamed 与 imageWithContentsOfFile的区别
- sql语句总结