JFreeChart问题,在线等,谢谢!

05-09-19 mhbjava
下面的程序为什么找不到类TimeSeriesDataPair类和MathUtil类呢?

我用的是jfreechart-0.9.11.jar和jcommon-0.8.6.jar

如果是因为版本问题,请问一下哪个版本才有这个类,如果用这个版本来做,改换成什么类?非常感谢!在线等!谢谢!

package com.mhb;

import java.io.*;

import org.jfree.chart.*;

import java.awt.*;

import org.jfree.data.time.*;

public class DrawPic

{

public DrawPic(){

}

public static void main(String[] args){

//曲线图标题

String title = "趋势分析";

//曲线图X轴提示

String domain = "月份走势";

//曲线图Y轴提示

String range = "应收余额";

//曲线图自标题

String subtitleStr = "2003财年分析";

//创建时间数据源

//每一个TimeSeries在图上是一条曲线

TimeSeries ca = new TimeSeries("用友");

for (int i = 1999; i < 2005; i++) {

for (int mon = 0; mon < 12; mon++) {

//ca.add(new Month(mon + 1, i), new Double(500 + Math.random() * 100));

//TimeSeriesDataPair是一个时间点的数值体现

ca.add(new TimeSeriesDataPair(new Day(1, mon + 1, i), new Double(500 + Math.random() * 100)));

}

}

TimeSeries ibm = new TimeSeries("金碟");

for (int i = 1999; i < 2005; i++) {

for (int mon = 0; mon < 12; mon++) {

//ibm.add(new Month(mon+1,i),new Double(400-Math.random()*100));

ibm.add(new TimeSeriesDataPair(new Day(1, mon + 1, i), new Double(400 - Math.random() * 100)));

}

}

TimeSeries king = new TimeSeries("东软");

for (int i = 1999; i < 2005; i++) {

for (int mon = 0; mon < 12; mon++) {

//ibm.add(new Month(mon+1,i),new Double(400-Math.random()*100));

king.add(new TimeSeriesDataPair(new Day(1, mon + 1, i), new Double(300 - Math.random() * 100)));

}

}

//时间曲线数据集合

TimeSeriesCollection dataset = new TimeSeriesCollection();

dataset.addSeries(ca);

dataset.addSeries(ibm);

dataset.addSeries(king);

//dataset.addSeries(jpy);

//dataset.addSeries(mav);

//时间曲线元素

JFreeChart chart = ChartFactory.createTimeSeriesChart(

title,

domain,

range,

dataset,

true,

true,

false);

// then customise it a little...

TextTitle subtitle =

new TextTitle(subtitleStr, new Font("黑体", Font.BOLD, 12));

chart.addSubtitle(subtitle);

chart.setTitle(new TextTitle(title, new Font("隶书", Font.ITALIC, 15)));

//pie.setSeriesLabelFont(new Font("黑体", Font.BOLD, 15));

chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000,

Color.blue));

//输出文件到指定目录

String rfname = MathUtil.getRoundCode(22) + ".jpeg";

String fileName = "d:/test/" + rfname;

try {

ChartUtilities.saveChartAsJPEG(new File(fileName), 100, chart, 600,

600);

} catch (IOException exz) {

System.out.print("....Cant't Create image File");

}

}

}

猜你喜欢