jfreechat的用法解说.docVIP

  • 39
  • 0
  • 约4.06万字
  • 约 21页
  • 2016-10-09 发布于贵州
  • 举报
jfreechat的用法解说

Jfreechart的基础图表用法与在web项目中调用 下面是我自己学习时测试的例子,一天就可以搞定,写的比较简单,基本的功能都有,具体的属性百度,一般的都有解答,希望能够对你们有所帮助 jar包环境 到官网/jfreechart/下载资源包文件 将包文件放到你的项目里面,直接写java类,可以在java类的main方法里面直接生成图片 如例子 public class BarChartDemo { /** * 获取一个演示用的组合数据集对象 * * @return */ private static CategoryDataset getDataSet() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(100, 北京, 苹果); dataset.addValue(120, 上海, 苹果); dataset.addValue(160, 广州, 苹果); dataset.addValue(210, 北京, 梨子); dataset.addValue(220, 上海, 梨子); dataset.addValue(230, 广州, 梨子); dataset.addValue(330, 北京, 葡萄); dataset.addValue(340, 上海, 葡萄); dataset.addValue(340, 广州, 葡萄); dataset.addValue(420, 北京, 香蕉); dataset.addValue(430, 上海, 香蕉); dataset.addValue(400, 广州, 香蕉); dataset.addValue(510, 北京, 荔枝); dataset.addValue(530, 上海, 荔枝); dataset.addValue(510, 广州, 荔枝); return dataset; } /** * 解决图表汉字显示问题 * * @param chart */ private static void processChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis domainAxis = plot.getDomainAxis(); ValueAxis rAxis = plot.getRangeAxis(); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); TextTitle textTitle = chart.getTitle(); textTitle.setFont(new Font(宋体, Font.PLAIN, 20)); domainAxis.setTickLabelFont(new Font(sans-serif, Font.PLAIN, 11)); domainAxis.setLabelFont(new Font(宋体, Font.PLAIN, 12)); rAxis.setTickLabelFont(new Font(sans-serif, Font.PLAIN, 12)); rAxis.setLabelFont(new Font(宋体, Font.PLAIN, 12)); chart.getLegend().setItemFont(new Font(宋体, Font.PLAIN, 12)); //3d时设置 /* BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());//设置柱子上显示文字 renderer.setItemLabelFont(new Font(宋体, Font.PLAIN, 12)); renderer.setItemLabelsVisible(true);*/ //2d BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setBaseItemLabelGenera

文档评论(0)

1亿VIP精品文档

相关文档