高分紧急求救:vml(js)生成二维柱状图,曲线图,饼状图!
紧急求救:vml(js)生成二维柱状图,曲线图,饼状图!的代码!
能够留出数组传递接口◎
问题点数:0、回复次数:4Top
1 楼zhgc2003(神话时代)回复于 2004-11-09 13:34:38 得分 0
ding a!Top
2 楼jimaojian(没有钱,没有房,没有车,没有女人,我只有一台笔记本,可怜的IT人)回复于 2004-11-15 13:47:15 得分 0
WebChart.java
/*
* Created on 2003-9-9
* http://www.sentom.net
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package net.sentom.chart;
import java.awt.Insets;
import java.awt.Color;
import java.awt.Font;
import java.awt.BasicStroke;
import java.io.PrintWriter;
import javax.servlet.http.HttpSession;
import org.jfree.data.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.entity.*;
import org.jfree.chart.urls.*;
import org.jfree.chart.servlet.*;
import org.jfree.chart.labels.StandardPieToolTipGenerator;
/**
* @author sentom
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class WebChart {
private DefaultPieDataset data = new DefaultPieDataset();
public void setValue(String key,double value){
data.setValue(key,value);
}
public String generatePieChart(String title, HttpSession session, PrintWriter pw) {
String filename = null;
try {
JFreeChart chart = ChartFactory.createPieChart("饼型图", // chart title
data, // data
true, // include legend
true,
false
);
//设置图片的背景色
chart.setBackgroundPaint(java.awt.Color.white);
//设置图片标题的字体和大小
Font font = new Font("黑体",Font.CENTER_BASELINE,20);
TextTitle _title = new TextTitle(title);
_title.setFont(font);
chart.setTitle(_title);
//chart.setAntiAlias(false);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setInsets(new Insets(5, 5, 5, 5));
//在统计图片上建连结
plot.setURLGenerator(new StandardPieURLGenerator("link.jsp","section"));
//指定 section 标签的的类型
plot.setSectionLabelType(PiePlot.NAME_AND_VALUE_LABELS);
//指定 section 轮廓线的颜色
plot.setDefaultOutlinePaint(new Color(0x99, 0x99, 0xFF));
//指定 section 轮廓线的厚度
plot.setDefaultOutlineStroke(new BasicStroke(0));
plot.setRadius(0.70);
//抽离一个 section 出来
plot.setExplodePercent(1, 1.00);
//设置第一个 section 的开始位置,默认是12点钟方向
plot.setStartAngle(270);
//指定 section 的色彩
plot.setPaint(1, new Color(0x99, 0x99, 0xFF));
//指定 section 按逆时针方向依次显示,默认是顺时针方向
plot.setDirection(PiePlot.ANTICLOCKWISE);
//指定显示的饼图上圆形还椭圆形
//plot.setCircular(false);
plot.setToolTipGenerator(new StandardPieToolTipGenerator());
//把生成的图片放到临时目录
ChartRenderingInfo info = new ChartRenderingInfo(new
StandardEntityCollection());
//500是图片长度,300是图片高度
filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info,
session);
ChartUtilities.writeImageMap(pw, filename, info);
pw.flush();
} catch (Exception e) {
System.out.println("Exception - " + e.toString());
e.printStackTrace(System.out);
filename = "public_error_500x300.png";
}
return filename;
}
}
pie.jsp <%@ page contentType="text/html;charset=GBK"%>
<%@ page import = "java.io.PrintWriter" %>
<%@ page import="net.sentom.chart.WebChart"%>
<%
WebChart chart = new WebChart();
chart.setValue("六月",500);
chart.setValue("七月",580);
chart.setValue("八月",828);
chart.setValue("九月",928);
chart.setValue("十月",1028);
String filename = chart.generatePieChart("www.SenTom.net 网站日均访问统计表", session, new
PrintWriter(out));
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
<HTML>
<HEAD>
<TITLE>www.sentom.net</TITLE>
</HEAD>
<BODY>
<P ALIGN="CENTER">
<img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%=
filename %>">
</P>
</BODY>
</HTML>
</BODY>
</HTML>
运行结果如下:
二 org.jfree.chart.plot.Pie3DPlot
使用该类指定 3D 饼形图的属性。Pie3DPlot 是上面讲到的 PiePlot 的子类,所以呢,上面介绍的的方法 在 Pie3DPlot 中都适用。这里不在重复,只介绍一个上面没有介绍的 setForegroundAlpha(float alpha) 方 法,设置图片的透明度。
对上面 WebChar.java 程序做一点改动:
/*
* Created on 2003-9-9
* http://www.sentom.net
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package net.sentom.chart;
import java.awt.Insets;
import java.awt.Color;
import java.awt.Font;
import java.awt.BasicStroke;
import java.io.PrintWriter;
import javax.servlet.http.HttpSession;
import org.jfree.data.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.entity.*;
import org.jfree.chart.urls.*;
import org.jfree.chart.servlet.*;
import org.jfree.chart.labels.StandardPieToolTipGenerator;
/**
* @author sentom
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class WebChart {
private DefaultPieDataset data = new DefaultPieDataset();
public void setValue(String key,double value){
data.setValue(key,value);
}
public String generatePieChart(String title, HttpSession session, PrintWriter pw) {
String filename = null;
try {
JFreeChart chart = ChartFactory.createPie3DChart("饼型图", // chart title
data, // data
true, // include legend
true,
false
);
//设置图片的背景色
chart.setBackgroundPaint(java.awt.Color.white);
//设置图片标题的字体和大小
Font font = new Font("黑体",Font.CENTER_BASELINE,20);
TextTitle _title = new TextTitle(title);
_title.setFont(font);
chart.setTitle(_title);
//chart.setAntiAlias(false);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setInsets(new Insets(5, 5, 5, 5));
//在统计图片上建连结
plot.setURLGenerator(new StandardPieURLGenerator("link.jsp","section"));
//指定 section 标签的的类型
plot.setSectionLabelType(PiePlot.NAME_LABELS);
//指定 section 轮廓线的颜色
plot.setDefaultOutlinePaint(null);
//指定 section 轮廓线的厚度
plot.setDefaultOutlineStroke(new BasicStroke(0));
//设置第一个 section 的开始位置,默认是12点钟方向
plot.setStartAngle(270);
//指定 section 的色彩
plot.setPaint(1, new Color(0x99, 0x99, 0xFF));
//指定 section 按逆时针方向依次显示,默认是顺时针方向
plot.setDirection(PiePlot.ANTICLOCKWISE);
//指定显示的饼图上圆形还椭圆形
//plot.setCircular(false);
plot.setToolTipGenerator(new StandardPieToolTipGenerator());
//指定图片的透明度
plot.setForegroundAlpha(0.5f);
//把生成的图片放到临时目录
ChartRenderingInfo info = new ChartRenderingInfo(new
StandardEntityCollection());
//500是图片长度,300是图片高度
filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info,
session);
ChartUtilities.writeImageMap(pw, filename, info);
pw.flush();
} catch (Exception e) {
System.out.println("Exception - " + e.toString());
e.printStackTrace(System.out);
filename = "public_error_500x300.png";
}
return filename;
}
}
Top
3 楼jimaojian(没有钱,没有房,没有车,没有女人,我只有一台笔记本,可怜的IT人)回复于 2004-11-15 13:49:00 得分 0
自己下载一个JFREECHAT包,研究一下,刚开始有点乱,Top
4 楼weidy(笑圣)回复于 2004-11-15 15:08:48 得分 0
晕,人家要vml的代码,怎么给一段java代码Top
相关问题
- 请问那里有根据数据画柱状图或曲线图的列子呀?
- 谁能提供一个好用的图表控件,实现曲线图,柱状图的显示?
- 在asp.net里一般用什么做分析的图(如:曲线图,饼图,柱状图)
- 在asp.net里一般用什么做分析的图(如:曲线图,饼图,柱状图)
- 求助,柱状,饼状图显示。
- Delphi 曲线图
- 高分请教:我要从oracle中提取数据,然后再browser中画出来,饼状图或者曲线图,请问如何画?
- 请教:我要从oracle中提取数据,然后再browser中画出来,饼状图或者曲线图,请问如何画?
- 现在需要在VB开发的系统中加入统计功能,生成曲线图,饼图,柱状图,请问用什么方法?
- ***** asp.net统计图全系列:柱状图,饼状图,折线图 ******




