jfreechart时序图 demo
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.time.Month;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class TimeSeriesDemo1 extends ApplicationFrame {
public TimeSeriesDemo1(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
localJPanel.setPreferredSize(new Dimension(500, 270));
setContentPane(localJPanel);
}
private static JFreeChart createChart(XYDataset paramXYDataset) {
//**************************************************************************************
//解决中文乱码
StandardChartTheme standardChartTheme = new StandardChartTheme("JFree"); //或者为Legacy
standardChartTheme.setRegularFont(new Font("宋体", Font.BOLD, 12));
standardChartTheme.setExtraLargeFont(new Font("宋体", Font.BOLD, 12));
standardChartTheme.setSmallFont(new Font("宋体", Font.BOLD, 12));
standardChartTheme.setLargeFont(new Font("宋体", Font.BOLD, 12));
ChartFactory.setChartTheme(standardChartTheme);
//**************************************************************************************
JFreeChart localJFreeChart = ChartFactory.createTimeSeriesChart(
"价格走势图", "", "单价",
paramXYDataset, false, false, false);
XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot();
localXYPlot.setBackgroundPaint(Color.WHITE);
localXYPlot.setDomainGridlinePaint(Color.BLACK);
localXYPlot.setRangeGridlinePaint(Color.BLACK);
return (JFreeChart) localJFreeChart;
}
private static XYDataset createDataset() {
TimeSeries localTimeSeries1 = new TimeSeries("L&G European Index Trust");
localTimeSeries1.add(new Month(2, 2001), 181.80000000000001D);
localTimeSeries1.add(new Month(3, 2001), 167.30000000000001D);
localTimeSeries1.add(new Month(4, 2001), 153.80000000000001D);
localTimeSeries1.add(new Month(5, 2001), 167.59999999999999D);
localTimeSeries1.add(new Month(6, 2001), 158.80000000000001D);
localTimeSeries1.add(new Month(7, 2001), 148.30000000000001D);
localTimeSeries1.add(new Month(8, 2001), 153.90000000000001D);
localTimeSeries1.add(new Month(9, 2001), 142.69999999999999D);
localTimeSeries1.add(new Month(10, 2001), 123.2D);
localTimeSeries1.add(new Month(11, 2001), 131.80000000000001D);
localTimeSeries1.add(new Month(12, 2001), 139.59999999999999D);
localTimeSeries1.add(new Month(1, 2002), 142.90000000000001D);
localTimeSeries1.add(new Month(2, 2002), 138.69999999999999D);
localTimeSeries1.add(new Month(3, 2002), 137.30000000000001D);
localTimeSeries1.add(new Month(4, 2002), 143.90000000000001D);
localTimeSeries1.add(new Month(5, 2002), 139.80000000000001D);
localTimeSeries1.add(new Month(6, 2002), 137.0D);
localTimeSeries1.add(new Month(7, 2002), 132.80000000000001D);
localTimeSeries1.add(new Month(8, 2002), 110.3D);
localTimeSeries1.add(new Month(9, 2002), 110.5D);
localTimeSeries1.add(new Month(10, 2002), 94.109999999999999D);
localTimeSeries1.add(new Month(11, 2002), 102.5D);
localTimeSeries1.add(new Month(12, 2002), 112.3D);
localTimeSeries1.add(new Month(1, 2003), 104.0D);
localTimeSeries1.add(new Month(2, 2003), 98.530000000000001D);
localTimeSeries1.add(new Month(3, 2003), 97.150000000000006D);
localTimeSeries1.add(new Month(4, 2003), 94.900000000000006D);
localTimeSeries1.add(new Month(5, 2003), 107.8D);
localTimeSeries1.add(new Month(6, 2003), 113.7D);
localTimeSeries1.add(new Month(7, 2003), 112.5D);
localTimeSeries1.add(new Month(8, 2003), 118.59999999999999D);
localTimeSeries1.add(new Month(9, 2003), 123.8D);
localTimeSeries1.add(new Month(10, 2003), 117.2D);
localTimeSeries1.add(new Month(11, 2003), 123.0D);
localTimeSeries1.add(new Month(12, 2003), 127.0D);
localTimeSeries1.add(new Month(1, 2004), 132.69999999999999D);
localTimeSeries1.add(new Month(2, 2004), 132.40000000000001D);
localTimeSeries1.add(new Month(3, 2004), 131.69999999999999D);
localTimeSeries1.add(new Month(4, 2004), 128.0D);
localTimeSeries1.add(new Month(5, 2004), 131.80000000000001D);
localTimeSeries1.add(new Month(6, 2004), 127.40000000000001D);
localTimeSeries1.add(new Month(7, 2004), 133.5D);
localTimeSeries1.add(new Month(8, 2004), 126.0D);
localTimeSeries1.add(new Month(9, 2004), 129.5D);
localTimeSeries1.add(new Month(10, 2004), 135.30000000000001D);
localTimeSeries1.add(new Month(11, 2004), 138.0D);
localTimeSeries1.add(new Month(12, 2004), 141.30000000000001D);
localTimeSeries1.add(new Month(1, 2005), 148.80000000000001D);
localTimeSeries1.add(new Month(2, 2005), 147.09999999999999D);
localTimeSeries1.add(new Month(3, 2005), 150.69999999999999D);
localTimeSeries1.add(new Month(4, 2005), 150.0D);
localTimeSeries1.add(new Month(5, 2005), 145.69999999999999D);
localTimeSeries1.add(new Month(6, 2005), 152.0D);
localTimeSeries1.add(new Month(7, 2005), 157.19999999999999D);
localTimeSeries1.add(new Month(8, 2005), 167.0D);
localTimeSeries1.add(new Month(9, 2005), 165.0D);
localTimeSeries1.add(new Month(10, 2005), 171.59999999999999D);
localTimeSeries1.add(new Month(11, 2005), 166.19999999999999D);
localTimeSeries1.add(new Month(12, 2005), 174.30000000000001D);
localTimeSeries1.add(new Month(1, 2006), 183.80000000000001D);
localTimeSeries1.add(new Month(2, 2006), 187.0D);
localTimeSeries1.add(new Month(3, 2006), 191.30000000000001D);
localTimeSeries1.add(new Month(4, 2006), 202.5D);
localTimeSeries1.add(new Month(5, 2006), 200.59999999999999D);
localTimeSeries1.add(new Month(6, 2006), 187.30000000000001D);
localTimeSeries1.add(new Month(7, 2006), 192.19999999999999D);
localTimeSeries1.add(new Month(8, 2006), 190.80000000000001D);
localTimeSeries1.add(new Month(9, 2006), 194.69999999999999D);
localTimeSeries1.add(new Month(10, 2006), 201.30000000000001D);
localTimeSeries1.add(new Month(11, 2006), 205.09999999999999D);
localTimeSeries1.add(new Month(12, 2006), 206.69999999999999D);
localTimeSeries1.add(new Month(1, 2007), 216.80000000000001D);
localTimeSeries1.add(new Month(2, 2007), 218.0D);
localTimeSeries1.add(new Month(3, 2007), 215.40000000000001D);
localTimeSeries1.add(new Month(4, 2007), 223.0D);
localTimeSeries1.add(new Month(5, 2007), 235.09999999999999D);
localTimeSeries1.add(new Month(6, 2007), 242.0D);
localTimeSeries1.add(new Month(7, 2007), 237.80000000000001D);
TimeSeries localTimeSeries2 = new TimeSeries("L&G UK Index Trust");
localTimeSeries2.add(new Month(2, 2001), 129.59999999999999D);
localTimeSeries2.add(new Month(3, 2001), 0);
localTimeSeries2.add(new Month(4, 2001), 117.2D);
localTimeSeries2.add(new Month(5, 2001), 124.09999999999999D);
localTimeSeries2.add(new Month(6, 2001), 122.59999999999999D);
localTimeSeries2.add(new Month(7, 2001), 119.2D);
localTimeSeries2.add(new Month(8, 2001), 116.5D);
localTimeSeries2.add(new Month(9, 2001), 112.7D);
localTimeSeries2.add(new Month(10, 2001), 101.5D);
localTimeSeries2.add(new Month(11, 2001), 106.09999999999999D);
localTimeSeries2.add(new Month(12, 2001), 110.3D);
localTimeSeries2.add(new Month(1, 2002), 111.7D);
localTimeSeries2.add(new Month(2, 2002), 111.0D);
localTimeSeries2.add(new Month(3, 2002), 109.59999999999999D);
localTimeSeries2.add(new Month(4, 2002), 113.2D);
localTimeSeries2.add(new Month(5, 2002), 111.59999999999999D);
localTimeSeries2.add(new Month(6, 2002), 108.8D);
localTimeSeries2.add(new Month(7, 2002), 101.59999999999999D);
localTimeSeries2.add(new Month(8, 2002), 90.950000000000003D);
localTimeSeries2.add(new Month(9, 2002), 91.019999999999996D);
localTimeSeries2.add(new Month(10, 2002), 82.370000000000005D);
localTimeSeries2.add(new Month(11, 2002), 86.319999999999993D);
localTimeSeries2.add(new Month(12, 2002), 91.0D);
localTimeSeries2.add(new Month(1, 2003), 86.0D);
localTimeSeries2.add(new Month(2, 2003), 80.040000000000006D);
localTimeSeries2.add(new Month(3, 2003), 80.400000000000006D);
localTimeSeries2.add(new Month(4, 2003), 80.280000000000001D);
localTimeSeries2.add(new Month(5, 2003), 86.420000000000002D);
localTimeSeries2.add(new Month(6, 2003), 91.400000000000006D);
localTimeSeries2.add(new Month(7, 2003), 90.519999999999996D);
localTimeSeries2.add(new Month(8, 2003), 93.109999999999999D);
localTimeSeries2.add(new Month(9, 2003), 96.799999999999997D);
localTimeSeries2.add(new Month(10, 2003), 94.780000000000001D);
localTimeSeries2.add(new Month(11, 2003), 99.560000000000002D);
localTimeSeries2.add(new Month(12, 2003), 100.8D);
localTimeSeries2.add(new Month(1, 2004), 103.40000000000001D);
localTimeSeries2.add(new Month(2, 2004), 102.09999999999999D);
localTimeSeries2.add(new Month(3, 2004), 105.3D);
localTimeSeries2.add(new Month(4, 2004), 103.7D);
localTimeSeries2.add(new Month(5, 2004), 105.2D);
localTimeSeries2.add(new Month(6, 2004), 103.7D);
localTimeSeries2.add(new Month(7, 2004), 105.7D);
localTimeSeries2.add(new Month(8, 2004), 103.59999999999999D);
localTimeSeries2.add(new Month(9, 2004), 106.09999999999999D);
localTimeSeries2.add(new Month(10, 2004), 109.3D);
localTimeSeries2.add(new Month(11, 2004), 110.3D);
localTimeSeries2.add(new Month(12, 2004), 112.59999999999999D);
localTimeSeries2.add(new Month(1, 2005), 116.0D);
localTimeSeries2.add(new Month(2, 2005), 117.3D);
localTimeSeries2.add(new Month(3, 2005), 120.09999999999999D);
localTimeSeries2.add(new Month(4, 2005), 119.3D);
localTimeSeries2.add(new Month(5, 2005), 116.2D);
localTimeSeries2.add(new Month(6, 2005), 120.8D);
localTimeSeries2.add(new Month(7, 2005), 125.2D);
localTimeSeries2.add(new Month(8, 2005), 127.7D);
localTimeSeries2.add(new Month(9, 2005), 130.80000000000001D);
localTimeSeries2.add(new Month(10, 2005), 131.0D);
localTimeSeries2.add(new Month(11, 2005), 135.30000000000001D);
localTimeSeries2.add(new Month(12, 2005), 141.19999999999999D);
localTimeSeries2.add(new Month(1, 2006), 144.69999999999999D);
localTimeSeries2.add(new Month(2, 2006), 146.40000000000001D);
localTimeSeries2.add(new Month(3, 2006), 151.90000000000001D);
localTimeSeries2.add(new Month(4, 2006), 153.5D);
localTimeSeries2.add(new Month(5, 2006), 144.5D);
localTimeSeries2.add(new Month(6, 2006), 150.09999999999999D);
localTimeSeries2.add(new Month(7, 2006), 148.69999999999999D);
localTimeSeries2.add(new Month(8, 2006), 150.09999999999999D);
localTimeSeries2.add(new Month(9, 2006), 151.59999999999999D);
localTimeSeries2.add(new Month(10, 2006), 153.40000000000001D);
localTimeSeries2.add(new Month(11, 2006), 158.30000000000001D);
localTimeSeries2.add(new Month(12, 2006), 157.59999999999999D);
localTimeSeries2.add(new Month(1, 2007), 163.90000000000001D);
localTimeSeries2.add(new Month(2, 2007), 163.80000000000001D);
localTimeSeries2.add(new Month(3, 2007), 162.0D);
localTimeSeries2.add(new Month(4, 2007), 167.09999999999999D);
localTimeSeries2.add(new Month(5, 2007), 170.0D);
localTimeSeries2.add(new Month(6, 2007), 175.69999999999999D);
localTimeSeries2.add(new Month(7, 2007), 171.90000000000001D);
TimeSeriesCollection localTimeSeriesCollection = new TimeSeriesCollection();
localTimeSeriesCollection.addSeries(localTimeSeries1);
localTimeSeriesCollection.addSeries(localTimeSeries2);
return localTimeSeriesCollection;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
/**
* try 里面是生成图片的代码,只需要传入一个chart
*/
try {
OutputStream os = new FileOutputStream("company22222.jpeg");
try {
// 由ChartUtilities生成文件到一个体outputStream中去
ChartUtilities.writeChartAsJPEG(os, localJFreeChart, 500, 300);
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString) {
TimeSeriesDemo1 localTimeSeriesDemo1 = new TimeSeriesDemo1(
"Time Series Demo 1");
localTimeSeriesDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localTimeSeriesDemo1);
localTimeSeriesDemo1.setVisible(true);
}
}
jfreechart时序图 demo的更多相关文章
- jfreechart折线图 demo
public class ChartUtil { public static ChartUtil chartUtil; private RoomViewsDataService roomViewsDa ...
- JFreeChart 图表生成实例(饼图、柱状图、折线图、时序图)
import java.awt.BasicStroke; import java.awt.Color; import java.io.FileOutputStream; import java.io. ...
- 利用JFreeChart生成时序图(6) (转自 JSP开发技术大全)
利用JFreeChart生成时序图(6) (转自 JSP开发技术大全) 14.6 利用JFreeChart生成时序图 通过JFreeChart插件只能生成普通效果的时序图,利用工厂类ChartFact ...
- 一秒钟教会你如何 使用jfreechart制作图表,扇形图,柱形图,线型图,时序图,附上详细代码,直接看效果
今天有小伙伴问到我怎么使用jfreeChat生成图标,去年就有一个这方便的的总结,今天再遇到,就总结出来,供大家参考: 第一个: 创建柱状图,效果图如下: 柱状图代码如下: package cn.xf ...
- [UML]UML系列——时序图(顺序图)sequence diagram
系列文章 [UML]UML系列——用例图Use Case [UML]UML系列——用例图中的各种关系(include.extend) [UML]UML系列——类图Class [UML]UML系列——类 ...
- 使用Astah制作UML时序图
Astah制作UML图--详解 时序图的制作 开篇语: 本文为光荣之路原创文章,欢迎转载,但请注明出处. 做测试的难免看到开发画出各种设计图,都很羡慕,比如: 帅么,漂亮么,其实我们测试人员也可以轻松 ...
- SPI总线协议及SPI时序图详解
SPI,是英语Serial Peripheral Interface的缩写,顾名思义就是串行外围设备接口.SPI,是一种高速的,全双工,同步的通信总线,并且在芯片的管脚上只占用四根线,节约了芯片的管脚 ...
- GIT FLOW 时序图
git flow sequence md link: git branching model master->master branch: use default branch Note rig ...
- [转载]UML时序图总结
前言 在我的工作中,用的最多的就是时序图了.可能由于工作的原因,我也是最喜欢画时序图了,很清楚,很明了,什么时候发送什么消息,到达什么状态,一下子就展示在你的脑海里,对于消息驱动的程序来说,是再好不过 ...
随机推荐
- 宠物收养所 (SBT)
宠物收养所 最近,阿Q开了一间宠物收养所.收养所提供两种服务:收养被主人遗弃的宠物和让新的主人领养这些宠物.每个领养者都希望领养到自己满意的宠物,阿Q根据领养者的要求通过他自己发明的一个特殊的公式,得 ...
- kibana- Pie
1. Visualize 新建图形 2. 选择图形类型 3. 选择索引 4. 设置Pie参数 5. 保存图形
- 图论常用算法之一 POJ图论题集【转载】
POJ图论分类[转] 一个很不错的图论分类,非常感谢原版的作者!!!在这里分享给大家,爱好图论的ACMer不寂寞了... (很抱歉没有找到此题集整理的原创作者,感谢知情的朋友给个原创链接) POJ:h ...
- hdu 1512 Monkey King 左偏树
题目链接:HDU - 1512 Once in a forest, there lived N aggressive monkeys. At the beginning, they each does ...
- 高并发下的Node.js与负载均衡
新兴的Node.js已经吸引了很多开发人员的眼光,它提供给我们一个快速构建高性能的网络应用的平台.我也开始逐步投入node.js的怀抱,在学习和使用的过程中,遇到了一些问题,也有一些经验,我觉得有必要 ...
- GPU hang
最近做新项目 初期一直遇到个gpu hang的问题 就是command 提交过去gpu 就一直在那里 直到time out 也没什么别的错误提示 gpu debugger还抓不了 解决方案是 缩小之后 ...
- 关于container_of和list_for_each_entry 及其相关函数的分析
Linux代码看的比较多了,经常会遇到container_of和list_for_each_entry,特别是 list_for_each_entry比较多,因为Linux经常用到链表,虽然知道这些函 ...
- zabbix_sender高效模式
1.zabbix_sender介绍 zabbix获取key值有超时时间,如果自定义的key脚本一般需要执行很长时间,这根本没法去做监控,获取数据有超时时间,如果一些数据需要执行比较长的时间才能获取的话 ...
- Java程序猿的JavaScript学习笔记(12——jQuery-扩展选择器)
计划按例如以下顺序完毕这篇笔记: Java程序猿的JavaScript学习笔记(1--理念) Java程序猿的JavaScript学习笔记(2--属性复制和继承) Java程序猿的JavaScript ...
- CocoaPods安装及相关命令
具体安装参考: http://www.jianshu.com/p/dfe970588f95 http://www.jianshu.com/p/9e4e36ba8574 我就说一个,安装cocoapod ...