package com.test;
import java.awt.Font;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.time.Month;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import com.opensymphony.xwork2.ActionSupport;
public class JfreeChartTest extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private JFreeChart chart;
public JFreeChart getChart() {
TimeSeries t = new TimeSeries("java编程思想",Month.class);
t.add(new Month(1, 2012),1000);
t.add(new Month(2, 2012),300);
t.add(new Month(3, 2012),500);
t.add(new Month(4, 2012),100);
t.add(new Month(5, 2012),70);
t.add(new Month(6, 2012),90);
t.add(new Month(7, 2012),60);
t.add(new Month(8, 2012),30);
t.add(new Month(9, 2012),1000);
t.add(new Month(10, 2012),60);
t.add(new Month(11, 2012),80);
t.add(new Month(12, 2012),100);
TimeSeries t1 = new TimeSeries("c#编程思想",Month.class);
t1.add(new Month(1, 2012),100);
t1.add(new Month(2, 2012),1000);
t1.add(new Month(3, 2012),800);
t1.add(new Month(4, 2012),100);
t1.add(new Month(5, 2012),700);
t1.add(new Month(6, 2012),600);
t1.add(new Month(7, 2012),500);
t1.add(new Month(8, 2012),100);
t1.add(new Month(9, 2012),700);
t1.add(new Month(10, 2012),1000);
t1.add(new Month(11, 2012),100);
t1.add(new Month(12, 2012),100);
TimeSeriesCollection tc=new TimeSeriesCollection();
tc.addSeries(t);
tc.addSeries(t1);
chart=ChartFactory.createTimeSeriesChart("考试成绩分析图","时间","分数", tc, true, false, false);
chart.setTitle(new TextTitle("考试成绩分析图",new Font("黑体",Font.BOLD, 25))); //设置图的上标题字体
LegendTitle lt=chart.getLegend();
lt.setItemFont(new Font("黑体", Font.BOLD,20)); //设置下边标题的字体
XYPlot xy=chart.getXYPlot();
xy.getDomainAxis().setLabelFont(new Font("黑体",Font.BOLD, 20)); //设置横纵坐标的字体
xy.getRangeAxis().setLabelFont(new Font("黑体", Font.BOLD,18));
xy.getDomainAxis().setTickLabelFont(new Font("黑体", Font.BOLD, 18));
return chart;
}
public void setChart(JFreeChart chart) {
this.chart = chart;
}
@Override
public String execute() throws Exception {
//获取结果
return SUCCESS;
}
}
struts2+jfreeChartStruts简单生成折线图
4星 · 超过85%的资源 需积分: 4 163 浏览量
2012-09-21
15:57:47
上传
评论
收藏 39KB RAR 举报
javaaihaozhejiao
- 粉丝: 0
- 资源: 1
最新资源
- DatabaseWatermarkingBasedonTextFormat
- -移动通信-网络课程设计与研究
- 基于Python的PCA人脸识别算法的原理及实现代码+文档详解.zip
- 甘肃移动全业务工程建设项目管理流程优化研究
- 549springboot + vue 民宿管理平台.zip (可运行源码+数据库文件+文档)
- ZArchiver.Pro_0.9.5.apk
- vmware环境配置.mp4
- 548springboot + vue 大学生社团活动平台.zip(可运行源码+数据库文件+文档)
- 微信小程序 辩论倒计时小程序源码 作业设计demo 计算机专业参考
- 深入探究文件IO,嵌入式Linux
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页