【高手进】Jfreechart如何实现如下这种功能 本帖最后由 DreamSea530 于 2012-12-05 23:14:27 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://wenku.baidu.com/view/5d77a7d9ad51f01dc281f117.html例子自己看看就会了。 package lee;import java.io.*;import org.jfree.data.*;import org.jfree.data.category.*;import org.jfree.chart.*;import org.jfree.chart.plot.*;import org.jfree.chart.axis.*;import java.awt.Font;import java.awt.geom.Ellipse2D.Float;import org.jfree.chart.title.TextTitle;import org.jfree.chart.title.LegendTitle;/** * Description: * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a> * <br/>Copyright (C), 2001-2010, Yeeku.H.Lee * <br/>This program is protected by copyright laws. * <br/>Program Name: * <br/>Date: * @author Yeeku.H.Lee [email protected] * @version 1.0 */public class LineChart3DDemo{ public static void main(String[] args) throws IOException { JFreeChart chart = ChartFactory.createLineChart3D( "图书销量统计图", // 图表标题 "图书", // 目录轴的显示标签 "销量", // 数值轴的显示标签 getDataSet(), // 数据集 //PlotOrientation.HORIZONTAL , // 图表方向:水平 PlotOrientation.VERTICAL , // 图表方向:垂直 true, // 是否显示图例(对于简单的柱状图必须是false) false, // 是否生成工具 false // 是否生成URL链接 ); //重新设置图表标题,改变字体 chart.setTitle(new TextTitle("图书销量统计图" , new Font("黑体", Font.ITALIC , 22))); //取得统计图表的第一个图例 LegendTitle legend = chart.getLegend(0); //修改图例的字体 legend.setItemFont(new Font("宋体", Font.BOLD, 14)); CategoryPlot plot = (CategoryPlot)chart.getPlot(); //取得横轴 CategoryAxis categoryAxis = plot.getDomainAxis(); //设置横轴显示标签的字体 categoryAxis.setLabelFont(new Font("宋体" , Font.BOLD , 22)); //分类标签以45度角倾斜 categoryAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45); categoryAxis.setTickLabelFont(new Font("宋体" , Font.BOLD , 18)); //取得纵轴 NumberAxis numberAxis = (NumberAxis)plot.getRangeAxis(); //设置纵轴显示标签的字体 numberAxis.setLabelFont(new Font("宋体" , Font.BOLD , 22)); FileOutputStream fos = null; fos = new FileOutputStream("book.jpg"); //将统计图表输出成JPG文件 ChartUtilities.writeChartAsJPEG( fos, //输出到哪个输出流 1, //JPEG图片的质量,0~1之间 chart, //统计图表对象 800, //宽 600,//宽 null //ChartRenderingInfo 信息 ); fos.close(); } //返回一个CategoryDataset实例 private static CategoryDataset getDataSet() { //创建DefaultCategoryDataset数据集 DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(45000 , "北京" , "疯狂Java讲义"); dataset.addValue(38000 , "北京" , "轻量级Java EE企业实战"); dataset.addValue(24000 , "北京" , "疯狂Ajax讲义"); dataset.addValue(32000 , "北京" , "Struts 2权威指南"); dataset.addValue(21000 , "北京" , "疯狂XML讲义"); dataset.addValue(37000 , "上海" , "疯狂Java讲义"); dataset.addValue(36000 , "上海" , "轻量级Java EE企业实战"); dataset.addValue(34000 , "上海" , "疯狂Ajax讲义"); dataset.addValue(42000 , "上海" , "Struts 2权威指南"); dataset.addValue(12000 , "上海" , "疯狂XML讲义"); dataset.addValue(42000 , "广州" , "疯狂Java讲义"); dataset.addValue(40000 , "广州" , "轻量级Java EE企业实战"); dataset.addValue(34000 , "广州" , "疯狂Ajax讲义"); dataset.addValue(18000 , "广州" , "Struts 2权威指南"); dataset.addValue(26000 , "广州" , "疯狂XML讲义"); return dataset; }}给你这个作为参考吧 struts与hibernate整合 java 定时器,启动就执行 ssh整合 怎么样可以不需要登陆访问权限页面? 用过gSOAP的请进... xml解析 系统经常报An attempt by a client to checkout a Connection has timed out 请救..输入数组中值为1的个数 【求救】ejb的jar包中有.java文件为什么?(使用的是jbuilder) java能操作word吗? xfire 超时重连设置 不起作用 紧急求助,ftp客户端源代码
import org.jfree.data.category.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;import org.jfree.chart.axis.*;import java.awt.Font;
import java.awt.geom.Ellipse2D.Float;
import org.jfree.chart.title.TextTitle;
import org.jfree.chart.title.LegendTitle;/**
* Description:
* <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
* <br/>Copyright (C), 2001-2010, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee [email protected]
* @version 1.0
*/
public class LineChart3DDemo
{
public static void main(String[] args) throws IOException
{
JFreeChart chart = ChartFactory.createLineChart3D(
"图书销量统计图", // 图表标题
"图书", // 目录轴的显示标签
"销量", // 数值轴的显示标签
getDataSet(), // 数据集
//PlotOrientation.HORIZONTAL , // 图表方向:水平
PlotOrientation.VERTICAL , // 图表方向:垂直
true, // 是否显示图例(对于简单的柱状图必须是false)
false, // 是否生成工具
false // 是否生成URL链接
); //重新设置图表标题,改变字体
chart.setTitle(new TextTitle("图书销量统计图"
, new Font("黑体", Font.ITALIC , 22)));
//取得统计图表的第一个图例
LegendTitle legend = chart.getLegend(0);
//修改图例的字体
legend.setItemFont(new Font("宋体", Font.BOLD, 14)); CategoryPlot plot = (CategoryPlot)chart.getPlot();
//取得横轴
CategoryAxis categoryAxis = plot.getDomainAxis();
//设置横轴显示标签的字体
categoryAxis.setLabelFont(new Font("宋体"
, Font.BOLD , 22));
//分类标签以45度角倾斜
categoryAxis.setCategoryLabelPositions(
CategoryLabelPositions.UP_45);
categoryAxis.setTickLabelFont(new Font("宋体"
, Font.BOLD , 18));
//取得纵轴
NumberAxis numberAxis = (NumberAxis)plot.getRangeAxis();
//设置纵轴显示标签的字体
numberAxis.setLabelFont(new Font("宋体"
, Font.BOLD , 22));
FileOutputStream fos = null;
fos = new FileOutputStream("book.jpg");
//将统计图表输出成JPG文件
ChartUtilities.writeChartAsJPEG(
fos, //输出到哪个输出流
1, //JPEG图片的质量,0~1之间
chart, //统计图表对象
800, //宽
600,//宽
null //ChartRenderingInfo 信息
);
fos.close();
}
//返回一个CategoryDataset实例
private static CategoryDataset getDataSet()
{
//创建DefaultCategoryDataset数据集
DefaultCategoryDataset dataset =
new DefaultCategoryDataset();
dataset.addValue(45000 , "北京" , "疯狂Java讲义");
dataset.addValue(38000 , "北京" , "轻量级Java EE企业实战");
dataset.addValue(24000 , "北京" , "疯狂Ajax讲义");
dataset.addValue(32000 , "北京" , "Struts 2权威指南");
dataset.addValue(21000 , "北京" , "疯狂XML讲义");
dataset.addValue(37000 , "上海" , "疯狂Java讲义");
dataset.addValue(36000 , "上海" , "轻量级Java EE企业实战");
dataset.addValue(34000 , "上海" , "疯狂Ajax讲义");
dataset.addValue(42000 , "上海" , "Struts 2权威指南");
dataset.addValue(12000 , "上海" , "疯狂XML讲义");
dataset.addValue(42000 , "广州" , "疯狂Java讲义");
dataset.addValue(40000 , "广州" , "轻量级Java EE企业实战");
dataset.addValue(34000 , "广州" , "疯狂Ajax讲义");
dataset.addValue(18000 , "广州" , "Struts 2权威指南");
dataset.addValue(26000 , "广州" , "疯狂XML讲义");
return dataset;
}
}给你这个作为参考吧