分类: java Component2007-05-31 17:01 8408人阅读 评论(11) 收藏 举报

three:创建折线图

//创建折线图(Category)数据对象

String series1 = "First";

String series2 = "Second";

String series3 = "Third";

String type1 = "2001";

String type2 = "2002";

String type3 = "2003";

String type4 = "2004";

String type5 = "2005";

String type6 = "2006";

String type7 = "2007";

String type8 = "2008";

DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();

defaultcategorydataset.addValue(1.0D, series1, type1);

defaultcategorydataset.addValue(4D, series1, type2);

defaultcategorydataset.addValue(3D, series1, type3);

defaultcategorydataset.addValue(5D, series1, type4);

defaultcategorydataset.addValue(5D, series1, type5);

defaultcategorydataset.addValue(7D, series1, type6);

defaultcategorydataset.addValue(7D, series1, type7);

defaultcategorydataset.addValue(8D, series1, type8);

defaultcategorydataset.addValue(5D, series2, type1);

defaultcategorydataset.addValue(7D, series2, type2);

defaultcategorydataset.addValue(6D, series2, type3);

defaultcategorydataset.addValue(8D, series2, type4);

defaultcategorydataset.addValue(4D, series2, type5);

defaultcategorydataset.addValue(4D, series2, type6);

defaultcategorydataset.addValue(2D, series2, type7);

defaultcategorydataset.addValue(1.0D, series2, type8);

defaultcategorydataset.addValue(4D, series3, type1);

defaultcategorydataset.addValue(3D, series3, type2);

defaultcategorydataset.addValue(2D, series3, type3);

defaultcategorydataset.addValue(3D, series3, type4);

defaultcategorydataset.addValue(6D, series3, type5);

defaultcategorydataset.addValue(3D, series3, type6);

defaultcategorydataset.addValue(4D, series3, type7);

defaultcategorydataset.addValue(3D, series3, type8);

JFreeChart jfreechart = ChartFactory.createLineChart("折线图 Demo 1",

"Type","Value",

defaultcategorydataset,PlotOrientation.VERTICAL,

true,true,false);

CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();

categoryplot.setBackgroundPaint(Color.lightGray);

categoryplot.setRangeGridlinePaint(Color.white);

ChartFrame  frame=new ChartFrame ("折线图 ",jfreechart,true);

frame.pack();

frame.setVisible(true);

four:折线图

//  //折线图2

XYSeries xyseries = new XYSeries("First"); //先产生XYSeries 对象

xyseries.add(1.0D, 1.0D);

xyseries.add(2D, 4D);

xyseries.add(3D, 3D);

xyseries.add(4D, 5D);

xyseries.add(5D, 5D);

xyseries.add(6D, 7D);

xyseries.add(7D, 7D);

xyseries.add(8D, 8D);

XYSeries xyseries1 = new XYSeries("Second");

xyseries1.add(1.0D, 5D);

xyseries1.add(2D, 7D);

xyseries1.add(3D, 6D);

xyseries1.add(4D, 8D);

xyseries1.add(5D, 4D);

xyseries1.add(6D, 4D);

xyseries1.add(7D, 2D);

xyseries1.add(8D, 1.0D);

XYSeries xyseries2 = new XYSeries("Third");

xyseries2.add(3D, 4D);

xyseries2.add(4D, 3D);

xyseries2.add(5D, 2D);

xyseries2.add(6D, 3D);

xyseries2.add(7D, 6D);

xyseries2.add(8D, 3D);

xyseries2.add(9D, 4D);

xyseries2.add(10D, 3D);

XYSeriesCollection xyseriescollection = new XYSeriesCollection(); //再用XYSeriesCollection添加入XYSeries 对象

xyseriescollection.addSeries(xyseries);

xyseriescollection.addSeries(xyseries1);

xyseriescollection.addSeries(xyseries2);

JFreeChart jfreechart = ChartFactory.createXYLineChart("Line Chart Demo 2",

"X",

"Y",

xyseriescollection,

PlotOrientation.VERTICAL,

true,

true,

false);

ChartFrame  frame=new ChartFrame ("折线图 ",jfreechart,true);

frame.pack();

frame.setVisible(true);

five:时间序列图

//时间序列图

TimeSeries timeseries = new TimeSeries("L&G European Index Trust",Month.class);

timeseries.add(new Month(2, 2001), 181.8D);//这里用的是Month.class,同样还有Day.class Year.class 等等

timeseries.add(new Month(3, 2001), 167.3D);

timeseries.add(new Month(4, 2001), 153.8D);

timeseries.add(new Month(5, 2001), 167.6D);

timeseries.add(new Month(6, 2001), 158.8D);

timeseries.add(new Month(7, 2001), 148.3D);

timeseries.add(new Month(8, 2001), 153.9D);

timeseries.add(new Month(9, 2001), 142.7D);

timeseries.add(new Month(10, 2001), 123.2D);

timeseries.add(new Month(11, 2001), 131.8D);

timeseries.add(new Month(12, 2001), 139.6D);

timeseries.add(new Month(1, 2002), 142.9D);

timeseries.add(new Month(2, 2002), 138.7D);

timeseries.add(new Month(3, 2002), 137.3D);

timeseries.add(new Month(4, 2002), 143.9D);

timeseries.add(new Month(5, 2002), 139.8D);

timeseries.add(new Month(6, 2002), 137D);

timeseries.add(new Month(7, 2002), 132.8D);

TimeSeries timeseries1 = new TimeSeries("L&G UK Index Trust",Month.class);

timeseries1.add(new Month(2, 2001), 129.6D);

timeseries1.add(new Month(3, 2001), 123.2D);

timeseries1.add(new Month(4, 2001), 117.2D);

timeseries1.add(new Month(5, 2001), 124.1D);

timeseries1.add(new Month(6, 2001), 122.6D);

timeseries1.add(new Month(7, 2001), 119.2D);

timeseries1.add(new Month(8, 2001), 116.5D);

timeseries1.add(new Month(9, 2001), 112.7D);

timeseries1.add(new Month(10, 2001), 101.5D);

timeseries1.add(new Month(11, 2001), 106.1D);

timeseries1.add(new Month(12, 2001), 110.3D);

timeseries1.add(new Month(1, 2002), 111.7D);

timeseries1.add(new Month(2, 2002), 111D);

timeseries1.add(new Month(3, 2002), 109.6D);

timeseries1.add(new Month(4, 2002), 113.2D);

timeseries1.add(new Month(5, 2002), 111.6D);

timeseries1.add(new Month(6, 2002), 108.8D);

timeseries1.add(new Month(7, 2002), 101.6D);

TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();

timeseriescollection.addSeries(timeseries);

timeseriescollection.addSeries(timeseries1);

timeseriescollection.setDomainIsPointsInTime(true); //domain轴上的刻度点代表的是时间点而不是时间段

JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices",

"Date",

"Price Per Unit",

timeseriescollection,

true,

true,

false);

jfreechart.setBackgroundPaint(Color.white);

XYPlot xyplot = (XYPlot)jfreechart.getPlot(); //获得 plot : XYPlot!!

xyplot.setBackgroundPaint(Color.lightGray);

xyplot.setDomainGridlinePaint(Color.white);

xyplot.setRangeGridlinePaint(Color.white);

xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

xyplot.setDomainCrosshairVisible(true);

xyplot.setRangeCrosshairVisible(true);

ChartFrame  frame=new ChartFrame ("折线图 ",jfreechart,true);

frame.pack();

frame.setVisible(true);

@原文引入:http://blog.csdn.net/hapylong/article/details/1633147

JFreeChart教程(二)(转)的更多相关文章

  1. JFreeChart教程(一)(转)

    JFreeChart教程(一) 分类: java Component2007-05-31 15:53 35268人阅读 评论(30) 收藏 举报 jfreechartimportdataset图形ap ...

  2. (转)JFreeChart教程

    JFreeChart教程 一.jFreeChart产生图形的流程 创建一个数据源(dataset)来包含将要在图形中显示的数据>>创建一个 JFreeChart 对象来代表要显示的图形&g ...

  3. CRL快速开发框架系列教程二(基于Lambda表达式查询)

    本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...

  4. 手把手教从零开始在GitHub上使用Hexo搭建博客教程(二)-Hexo参数设置

    前言 前文手把手教从零开始在GitHub上使用Hexo搭建博客教程(一)-附GitHub注册及配置介绍了github注册.git相关设置以及hexo基本操作. 本文主要介绍一下hexo的常用参数设置. ...

  5. C#微信公众号开发系列教程二(新手接入指南)

    http://www.cnblogs.com/zskbll/p/4093954.html 此系列前面已经更新了两篇博文了,都是微信开发的前期准备工作,现在切入正题,本篇讲解新手接入的步骤与方法,大神可 ...

  6. 无废话ExtJs 入门教程二十一[继承:Extend]

    无废话ExtJs 入门教程二十一[继承:Extend] extjs技术交流,欢迎加群(201926085) 在开发中,我们在使用视图组件时,经常要设置宽度,高度,标题等属性.而这些属性可以通过“继承” ...

  7. 无废话ExtJs 入门教程二十[数据交互:AJAX]

    无废话ExtJs 入门教程二十[数据交互:AJAX] extjs技术交流,欢迎加群(521711109) 1.代码如下: 1 <!DOCTYPE html PUBLIC "-//W3C ...

  8. 无废话ExtJs 入门教程二[Hello World]

    无废话ExtJs 入门教程二[Hello World] extjs技术交流,欢迎加群(201926085) 我们在学校里学习任何一门语言都是从"Hello World"开始,这里我 ...

  9. Android Studio系列教程二--基本设置与运行

    Android Studio系列教程二--基本设置与运行 2014 年 11 月 28 日 DevTools 本文为个人原创,欢迎转载,但请务必在明显位置注明出处! 上面一篇博客,介绍了Studio的 ...

随机推荐

  1. intellij idea2016

    注册server http://idea.imsxm.com

  2. dataTables中固定表头

    dataTables中固定表头 加入  bAutowidth:false, <style> #dayReveiveMoney_payment_list_table_wrapper .dat ...

  3. functools内置装饰器

    def update_wrapper(wrapper, wrapped, assigned = WRAPPER_ASSIGNMENTS, updated = WRAPPER_UPDATES): def ...

  4. sql通配符+sql中查询条件包含下划线等通配符的写法

    一.SQL 通配符 在搜索数据库中的数据时,SQL 通配符可以替代一个或多个字符. SQL 通配符必须与 LIKE 运算符一起使用. 在 SQL 中,可使用以下通配符: 通配符 描述 % 替代一个或多 ...

  5. 使用dd命令快速生成大文件或者小文件的方法

    使用dd命令快速生成大文件或者小文件的方法     转载请说明出处:http://blog.csdn.net/cywosp/article/details/9674757     在程序的测试中有些场 ...

  6. 转载:K-means聚类算法

    转载地址:http://www.cnblogs.com/jerrylead/archive/2011/04/06/2006910.html K-means也是聚类算法中最简单的一种了,但是里面包含的思 ...

  7. linux下库文件的编程

    编程到了一定的时候,总喜欢追求新的东西.将代码尽量模块化就是我的追求之一,原来只是满足于将代码从单文件中分离,通过头文件和实现文件实现模块化,后来发现最好的方法是打包成库文件,使用更加方便.尽管在li ...

  8. Animation显示ListView的每一条记录

    activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout ...

  9. 【Java源码】集合类-ArrayDeque

    一.类继承关系 ArrayDeque和LinkedList一样都实现了双端队列Deque接口,但它们内部的数据结构和使用方法却不一样.根据该类的源码注释翻译可知: ArrayDeque实现了Deque ...

  10. hdu6080(最小环)

    题目 http://acm.hdu.edu.cn/showproblem.php?pid=6080 分析 很妙的思路,将里面的点集当作A,将外面的点集当作B 然后O(n^2)枚举两两B点,设一个是u, ...