- 浏览: 647777 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (213)
- JAVA (53)
- Tomcat (14)
- EXTJS专栏 (2)
- 数据库 (23)
- JavaScript (13)
- jQuery (11)
- 需求分析 (2)
- css (1)
- 手机 (1)
- php (7)
- 生活 (1)
- ssh (11)
- JFReeChart (2)
- Delphi (1)
- junit (0)
- liunx (10)
- 项目管理 (11)
- 文件下载 (1)
- Eclipse (2)
- jsp (2)
- 外挂、游戏 (1)
- 面试题 (8)
- 性能测试 (2)
- apache (1)
- MyBatis (1)
- Webservice (2)
- ant (1)
- IDEA (2)
- log4j (1)
- 小程序 (1)
最新评论
-
hll127:
请问service这个方法里为什么要while(true)啊? ...
jsp页面静态化例子 -
tarena1:
Spring 源码解读 推荐流程 -
konglx:
springaop_springmvc 写道可以参考最新的文档 ...
Web项目添加Maven支持步骤 -
springaop_springmvc:
可以参考最新的文档:如何在eclipse jee中检出项目并转 ...
Web项目添加Maven支持步骤 -
9976:
很好,谢谢
Spring 源码解读 推荐流程
折线图 line.jsp
XY曲线图 xy.jsp
时间曲线图 timeserver.jsp
其他曲线图 MultipleAxisDemo.jsp
折线图 line.jsp :
<%@ page contentType="text/html;charset=GBK"%> <%@ page import = "org.jfree.chart.ChartFactory, org.jfree.chart.ChartPanel, org.jfree.chart.JFreeChart, org.jfree.chart.StandardLegend, org.jfree.chart.axis.NumberAxis, org.jfree.chart.plot.CategoryPlot, org.jfree.chart.plot.PlotOrientation, org.jfree.chart.renderer.LineAndShapeRenderer, org.jfree.data.CategoryDataset, org.jfree.data.DefaultCategoryDataset, org.jfree.chart.servlet.ServletUtilities "%> <% // row keys... String series1 = "First"; String series2 = "Second"; String series3 = "Third"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; // create the dataset... DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, series1, type1); dataset.addValue(4.0, series1, type2); dataset.addValue(3.0, series1, type3); dataset.addValue(5.0, series1, type4); dataset.addValue(5.0, series1, type5); dataset.addValue(7.0, series1, type6); dataset.addValue(7.0, series1, type7); dataset.addValue(8.0, series1, type8); dataset.addValue(5.0, series2, type1); dataset.addValue(7.0, series2, type2); dataset.addValue(6.0, series2, type3); dataset.addValue(8.0, series2, type4); dataset.addValue(4.0, series2, type5); dataset.addValue(4.0, series2, type6); dataset.addValue(2.0, series2, type7); dataset.addValue(1.0, series2, type8); dataset.addValue(4.0, series3, type1); dataset.addValue(3.0, series3, type2); dataset.addValue(2.0, series3, type3); dataset.addValue(3.0, series3, type4); dataset.addValue(6.0, series3, type5); dataset.addValue(3.0, series3, type6); dataset.addValue(4.0, series3, type7); dataset.addValue(3.0, series3, type8); // create the chart... JFreeChart chart = ChartFactory.createLineChart( "血压水平分布图", // chart title "Type", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... StandardLegend legend = (StandardLegend) chart.getLegend(); legend.setDisplaySeriesShapes(true); legend.setShapeScaleX(1.5); legend.setShapeScaleY(1.5); legend.setDisplaySeriesLines(true); CategoryPlot plot = chart.getCategoryPlot(); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setUpperMargin(0.20); rangeAxis.setLabelAngle(Math.PI / 2.0); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setItemLabelsVisible(true); String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, null, session); String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename; %> <img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%= filename %>"> |
XY曲线图 xy.jsp :
<%@ page contentType="text/html;charset=GBK"%> <%@ page import =" java.awt.*"%> <%@ page import = " java.awt.geom.Ellipse2D"%> <%@ page import = " java.io.PrintWriter"%> <%@ page import = " java.text.SimpleDateFormat"%> <%@ page import = " java.util.Date"%> <%@ page import = " java.util.ArrayList"%> <%@ page import = " java.util.Iterator"%> <%@ page import = " java.util.Locale"%> <%@ page import = " java.text.NumberFormat"%> <%@ page import = " javax.servlet.http.HttpSession"%> <%@ page import = " org.jfree.data.*"%> <%@ page import = " org.jfree.chart.*"%> <%@ page import = " org.jfree.chart.axis.*"%> <%@ page import = " org.jfree.chart.renderer.BarRenderer"%> <%@ page import = " org.jfree.chart.renderer.StandardXYItemRenderer"%> <%@ page import = " org.jfree.chart.renderer.StackedXYAreaRenderer"%> <%@ page import = " org.jfree.chart.renderer.XYAreaRenderer"%> <%@ page import = " org.jfree.chart.plot.*"%> <%@ page import = " org.jfree.chart.entity.*"%> <%@ page import = " org.jfree.chart.labels.*"%> <%@ page import = " org.jfree.chart.urls.*"%> <%@ page import ="org.jfree.chart.servlet.*"%> <%@ page import = "java.io.PrintWriter"%> <%@ page import = "java.util.ArrayList"%> <%@ page import = "java.util.Iterator,org.jfree.data.time.*,java.awt.Font"%> <% XYSeries dataSeries = new XYSeries("增长"); for (int i = 0; i <= 10; i++) { int x=(int) (100*Math.random()); int y=(int) (100*Math.random()); dataSeries.add(x,y); } XYSeries dataSeries1 = new XYSeries("趋势"); for (int j = 0; j <= 100; j++) { int x=(int) (100*Math.random()); int y=(int) (100*Math.random()); dataSeries1.add(j,40); } XYSeriesCollection xyDataset = new XYSeriesCollection(); xyDataset.addSeries(dataSeries); xyDataset.addSeries(dataSeries1); String filename = ""; SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.UK); StandardXYToolTipGenerator ttg = new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,sdf,NumberFormat.getInstance()); TimeSeriesURLGenerator urlg = new TimeSeriesURLGenerator(sdf, "pie_chart.jsp", "series", "hitDate"); // Create the chart object ValueAxis xAxis = new NumberAxis("X轴坐标"); //x轴坐标 ValueAxis yAxis = new NumberAxis("Y轴坐标"); //y轴坐标 StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES ,ttg, urlg); renderer.setShapesFilled(true); Font font=new Font("黑体",Font.TRUETYPE_FONT, 12); XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart("测试曲线图", font, plot, true); chart.setBackgroundPaint(java.awt.Color.white); // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, session); String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename;%> <html> <head> </head> <body> <table border=0> <tr> <td> <br> <img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%= filename %>"> </td> </tr> </table> </body> </html> |
时间曲线图 timeserver.jsp :
<%@ page contentType="text/html;charset=GBK"%> <%@ page import = "org.jfree.chart.ChartFactory, org.jfree.chart.ChartPanel, org.jfree.chart.JFreeChart, org.jfree.chart.servlet.ServletUtilities, org.jfree.chart.*, org.jfree.chart.StandardLegend, org.jfree.chart.axis.DateAxis, org.jfree.chart.plot.XYPlot, org.jfree.chart.renderer.StandardXYItemRenderer, org.jfree.chart.renderer.XYItemRenderer, org.jfree.data.XYDataset, org.jfree.data.time.Month, org.jfree.data.time.TimeSeries, org.jfree.data.time.TimeSeriesCollection "%> <% TimeSeries s1 = new TimeSeries("L&G European Index Trust", Month.class); s1.add(new Month(2, 2001), 181.8); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust", Month.class); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); dataset.setDomainIsPointsInTime(true); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", "Date", "Price Per Unit", dataset, true, true, false ); //chart.setBackgroundPaint(Color.white); StandardLegend sl = (StandardLegend) chart.getLegend(); sl.setDisplaySeriesShapes(true); XYPlot plot = chart.getXYPlot(); // plot.setBackgroundPaint(Color.lightGray); //plot.setDomainGridlinePaint(Color.white); //plot.setRangeGridlinePaint(Color.white); //plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); //axis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy")); String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, null, session); String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename; %> <img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%= filename %>"> |
其他曲线图 MultipleAxisDemo.jsp :
<%@ page contentType="text/html;charset=GBK"%> <%@ page import = "org.jfree.chart.ChartFactory, org.jfree.chart.ChartPanel, org.jfree.chart.JFreeChart, org.jfree.chart.servlet.ServletUtilities, org.jfree.chart.axis.AxisLocation, org.jfree.chart.axis.NumberAxis, org.jfree.chart.plot.PlotOrientation, org.jfree.chart.plot.XYPlot, org.jfree.chart.renderer.StandardXYItemRenderer, org.jfree.chart.title.TextTitle, org.jfree.data.XYDataset, org.jfree.data.time.Minute, org.jfree.data.time.RegularTimePeriod, org.jfree.data.time.TimeSeries, org.jfree.data.time.TimeSeriesCollection "%> <% String name="Series 1"; double base=100.0; RegularTimePeriod start=new Minute(); int count=200; TimeSeries series = new TimeSeries(name, start.getClass()); RegularTimePeriod period = start; double value = base; for (int i = 0; i < count; i++) { series.add(period, value); period = period.next(); value = value * (1 + (Math.random() - 0.495) / 10.0); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 1", "Time of Day", "Primary Range Axis", dataset, true, true, false ); //chart.setBackgroundPaint(Color.white); chart.addSubtitle(new TextTitle("Four datasets and four range axes.")); XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); //plot.setBackgroundPaint(Color.lightGray); //plot.setDomainGridlinePaint(Color.white); //plot.setRangeGridlinePaint(Color.white); //plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); //renderer.setPaint(Color.black); /* // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); //axis2.setLabelPaint(Color.red); //axis2.setTickLabelPaint(Color.red); //plot.setSecondaryRangeAxis(0, axis2); //plot.setSecondaryRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setSecondaryDataset(0, dataset2); plot.mapSecondaryDatasetToRangeAxis(0, new Integer(0)); plot.setSecondaryRenderer(0, new StandardXYItemRenderer()); // plot.getSecondaryRenderer(0).setSeriesPaint(0, Color.red); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); //axis3.setLabelPaint(Color.blue); //axis3.setTickLabelPaint(Color.blue); //plot.setSecondaryRangeAxis(1, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setSecondaryDataset(1, dataset3); plot.mapSecondaryDatasetToRangeAxis(1, new Integer(1)); plot.setSecondaryRenderer(1, new StandardXYItemRenderer()); //plot.getSecondaryRenderer(1).setSeriesPaint(0, Color.blue); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); // plot.setSecondaryRangeAxis(2, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setSecondaryDataset(2, dataset4); plot.mapSecondaryDatasetToRangeAxis(2, new Integer(2)); plot.setSecondaryRenderer(2, new StandardXYItemRenderer()); //plot.getSecondaryRenderer(2).setSeriesPaint(0, Color.green); */ String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, null, session); String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename; %> <img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%= filename %>"> |
注意以上代码,均在:jfreechart-0.9.20.jar、jcommon-0.9.5.jar下调试通过!
web.xml配置servlet代码:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>DisplayChart</servlet-name> <servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class> </servlet> <servlet-mapping> <servlet-name>DisplayChart</servlet-name> <url-pattern>/DisplayChart</url-pattern> </servlet-mapping> </web-app> |
相关推荐
public JFreeChart createChart(String Ytitle, String title, CategoryDataset lineData, CategoryDataset barData) { //参考附件 return chart; } //struts 部分 <!--begin 维优特例 --> ...
Flex是一种基于ActionScript的开源框架,主要用于构建富互联网应用程序(RIA),而JFreeChart则是一个Java库,专门用于生成高质量的图表,包括饼状图、柱状图和曲线图等。 在Flex中,我们通常使用MXML和...
java+jfreechart+struts 生成曲线图 java+jfreechart+struts 生成曲线图 java jfreechart 曲线图 java jfreechart 曲线图 java jfreechart 曲线图 谁需要完整项目可以去http://download.csdn.net/source/2665347
JFreeChart双Y轴折线图实例,可以直接运行,实例类为LineChartDemo1.JAVA,有注释。 若想在web工程使用只需如下。 String filename = ServletUtilities.saveChartAsPNG(jfreechart, 600, 400, null, session); ...
jfreechart 堆栈柱状图跟折线图结合拼接 jar包请戳http://download.csdn.net/detail/a156435646/7424707
本教程将详细介绍如何在JSP中利用JFreeChart库来生成折线图。 首先,要使用JFreeChart,你需要在项目中引入相关的依赖。"标签"中提到的JFreeChart是这个过程的关键,它提供了丰富的API来创建图表。通常,你需要下载...
在这个例子中,我们将深入探讨如何使用 JFreeChart 创建一个折线图。 首先,确保你已经正确地在项目中引入了 JFreeChart 的依赖。通常,你可以通过 Maven 或 Gradle 将 JFreeChart 添加到构建文件中。对于 Maven,...
JFreeChart 是一个开源的Java库,用于生成高质量的2D图表,如折线图、饼图、柱状图和堆栈柱状图等。它广泛应用于数据分析、报告和应用程序中,提供丰富的自定义选项来满足各种视觉需求。在本项目中,你将找到能够...
JFreeChart是一款强大的Java图形库,它允许开发者创建多种类型的图表,包括折线图、柱状图、饼图、散点图等。在本主题中,我们将深入探讨如何使用JFreeChart来绘制平面和3D的折线图。 首先,让我们了解折线图的基本...
利用jfreechart绘制的漂亮的折线图,实现双纵坐标,折线点标签还带箭头指示,非常直观,需要提前下载jfreechart.jar文件,否则我的类会报错,也即是要配置运行环境
java JXL导出Excel源码及jfreechart 生成折线图,饼图 java JXL导出Excel源码及jfreechart 生成折线图,饼图 java JXL导出Excel源码及jfreechart 生成折线图,饼图
JFreeChart 是一个功能强大的 Java 图表库,它为开发者提供了创建各种高质量图表的能力,包括折线图、柱状图、饼图、散点图、甘特图等。这个教程将帮助你深入理解和使用 JFreeChart,结合学习笔记、流程图和示例代码...
在Java编程环境中,JFreeChart是一个非常流行的开源库,它为开发者提供了丰富的图表绘制功能,包括折线图、饼图、柱状图等。在这个"JFreeChart画折线实例"中,我们将深入探讨如何利用JFreeChart库来创建折线图,并将...
JFreeChart 是一个开源的Java库,用于生成高质量的、多样的图表,包括折线图、柱形图、饼图、散点图等。在这个特定的案例中,我们关注的是如何利用JFreeChart来创建折线图和柱形图的混合图表,这种图表在数据可视化...
**JFreeChart 折线图 Demo 知识点详解** JFreeChart 是一个用 Java 编写的开源图表库,它提供了丰富的图表类型,包括折线图、柱状图、饼图等,适用于各种数据可视化需求。在这个“jfreechart折线图demo”中,我们将...
JFreeChart是一组功能强大、灵活易用的Java绘图API,使用它可以生成多种通用性的报表,包括柱状图、饼图、曲线图、甘特图等。它能够用在Swing和Web等中制作自定义的图表或报表,并且得到广泛的应用。本文将通过引领...
JFreeChart是一个广泛使用的开源Java库,它提供了丰富的图表类型,如折线图、饼图、柱状图和堆栈柱状图等,用于数据可视化。这个库非常适合那些希望在Java应用程序中集成高质量图表的开发者。 **一、JFreeChart的...
该程序为main 函数,定义了三个方法,分别是jfreechart三种实现折线图的类型,返回的是一个chart 本程序是把图片保存到本地,当然实际应用中,只要在程序和页面中做相关配置即可以使用。 因为图片带点透明,所以...
在Java编程领域,JFreeChart是一个非常流行的图表库,它允许开发者创建各种复杂的数据可视化图形,包括折线图、柱状图、饼图等。在本篇博客中,"JfreeChart画双Y轴折线图"的主题,将探讨如何使用JFreeChart库来创建...