引入两jar包:
jcommon-1.0.16.jar
jfreechart-1.0.13.jar
直接上代码:
package com.potevio.rnd.tobacco.mine;
import java.awt.Font;
import java.awt.RenderingHints;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.data.time.TimeSeriesCollection;
/**
* @description 构造数据,测试图片生成
* @author Zhou-Jingxian
*/
public class Main {
public static void main(String[] args) {
TimeSeriesChartUtil util = new TimeSeriesChartUtil("month", "服务端失败率变化曲线图", "2013-4-21至2013-4-27", "时间", "失败率");
List datalist = new ArrayList();
Bean bean1 = new Bean();
bean1.setGoods_name("中华");
Map priceindexMap1 = new HashMap();
priceindexMap1.put("2013-04-21", 0.23);
priceindexMap1.put("2013-04-22", 0.24);
priceindexMap1.put("2013-04-23", 0.23);
priceindexMap1.put("2013-04-24", 0.22);
priceindexMap1.put("2013-04-25", 0.23);
priceindexMap1.put("2013-04-26", 0.24);
priceindexMap1.put("2013-04-27", 0.23);
bean1.setPriceindexMap(priceindexMap1);
datalist.add(bean1);
// Bean bean2 = new Bean();
// bean2.setGoods_name("芙蓉王");
// Map priceindexMap2 = new HashMap();
// priceindexMap2.put("200903", 100.12);
// priceindexMap2.put("200904", 100.2);
// priceindexMap2.put("200905", 100.0);
// priceindexMap2.put("200906", 100.08);
// priceindexMap2.put("200907", 100.12);
// priceindexMap2.put("200908", 100.2);
// priceindexMap2.put("200909", 100.0);
// priceindexMap2.put("200910", 100.08);
// bean2.setPriceindexMap(priceindexMap2);
// datalist.add(bean2);
//
// Bean bean3 = new Bean();
// bean3.setGoods_name("云烟");
// Map priceindexMap3 = new HashMap();
// priceindexMap3.put("200903", 99.77);
// priceindexMap3.put("200904", 99.7);
// priceindexMa