JFreeChar应用

eclipse创建web项目

引入jar包

在web.xml中配置DisplayChart

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>JFreeChartDemo</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <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>

柱状图

(以此为例子,下面各个都一样)

1,edu.hhxy.chart.bar.BarChart1

package edu.hhxy.chart.bar;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.category.DefaultCategoryDataset;

public class BarChart1 {
    public static String genBarChart(HttpSession session) throws Exception {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(510, "深圳", "苹果");
        dataset.addValue(320, "深圳", "香蕉");
        dataset.addValue(580, "深圳", "橘子");
        dataset.addValue(390, "深圳", "梨子");
        JFreeChart chart=ChartFactory.createBarChart3D("水果销售统计图", "水果", "销售", dataset,
                PlotOrientation.VERTICAL, true, true, true);
        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, null,session);
        return fileName;
    }
}

在barChart1.jsp引用

<%@page import="edu.hhxy.chart.bar.BarChart1"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BarChart1</title>
</head>
<body>
    <%
        String fileName = BarChart1.genBarChart(session);//引入的BarChar1其它视情况而定
        System.out.println(fileName);
    %>
    <img src="DisplayChart?filename=<%=fileName%>" width="700"
        height="500" border="0" />
</body>
</html>

结果:

2、

package edu.hhxy.chart.bar;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.category.DefaultCategoryDataset;

public class BarChart2 {

    public static String genBarChart(HttpSession session) throws Exception {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(510, "深圳", "苹果");
        dataset.addValue(320, "深圳", "香蕉");
        dataset.addValue(580, "深圳", "橘子");
        dataset.addValue(390, "深圳", "梨子");
        JFreeChart chart=ChartFactory.createBarChart3D("水果销售统计图", "水果", "销售", dataset,
                PlotOrientation.HORIZONTAL, true, true, true);
        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, null,session);
        return fileName;
    }
}

3、

package edu.hhxy.chart.bar;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;

public class BarChart3 {

    public static String genBarChart(HttpSession session) throws Exception {
        double [][]data=new double[][]{{1320},{720},{830},{400}};
        String []rowKeys={"苹果","香蕉","橘子","梨子"};
        String []columnKeys={"深圳"};
        CategoryDataset dataset=DatasetUtilities.createCategoryDataset(rowKeys,columnKeys ,data);
        JFreeChart chart=ChartFactory.createBarChart3D("水果销售统计图", "水果", "销售", dataset,
                PlotOrientation.VERTICAL, true, true, true);
        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, null,session);
        return fileName;
    }
}

4、

package edu.hhxy.chart.bar;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;

public class BarChart4 {

    public static String genBarChart(HttpSession session) throws Exception {
        double [][]data=new double[][]{{1320,1110,1123,321},{720,210,1423,1321},{830,1310,123,521},{400,1110,623,321}};
        String []rowKeys={"苹果","香蕉","橘子","梨子"};
        String []columnKeys={"深圳","北京","上海","南京"};
        CategoryDataset dataset=DatasetUtilities.createCategoryDataset(rowKeys,columnKeys ,data);
        JFreeChart chart=ChartFactory.createBarChart3D("水果销售统计图", "水果", "销售", dataset,
                PlotOrientation.VERTICAL, true, true, true);
        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, null,session);
        return fileName;
    }
}

5、

package edu.hhxy.chart.bar;

import java.awt.Color;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer3D;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.ui.TextAnchor;

public class BarChart5 {

    public static String genBarChart(HttpSession session) throws Exception {
        double [][]data=new double[][]{{1320,1110,1123,321},{720,210,1423,1321},{830,1310,123,521},{400,1110,623,321}};
        String []rowKeys={"苹果","香蕉","橘子","梨子"};
        String []columnKeys={"深圳","北京","上海","南京"};
        CategoryDataset dataset=DatasetUtilities.createCategoryDataset(rowKeys,columnKeys ,data);
        JFreeChart chart=ChartFactory.createBarChart3D("水果销售统计图", "水果", "销售", dataset,
                PlotOrientation.VERTICAL, true, true, true);

        CategoryPlot plot=chart.getCategoryPlot();
        // 设置网格背景颜色
        plot.setBackgroundPaint(Color.white);
        // 设置网格竖线颜色
        plot.setDomainGridlinePaint(Color.pink);
        // 设置网格横线颜色
        plot.setRangeGridlinePaint(Color.pink);

        // 显示每个柱的数值,并修改该数值的字体属性
        BarRenderer3D renderer=new BarRenderer3D();
        renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
        renderer.setBaseItemLabelsVisible(true);

        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
        renderer.setItemLabelAnchorOffset(10D);  

        // 设置平行柱的之间距离
        renderer.setItemMargin(0.4);

        plot.setRenderer(renderer);

        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, null,session);
        return fileName;
    }
}

饼状图

1、

package edu.hhxy.chart.pie;

import java.awt.Font;
import java.text.NumberFormat;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;

public class PieChart1 {

    public static String getPieChart(HttpSession session) throws Exception {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("黑心矿难", 1000);
        dataset.setValue("醉酒驾驶", 800);
        dataset.setValue("城管强拆", 400);
        dataset.setValue("医疗事故", 100);
        dataset.setValue("其他", 29);

        JFreeChart chart=ChartFactory.createPieChart("非正常死亡人数分布图", dataset, true, true, true);

        // 副标题
        chart.addSubtitle(new TextTitle("2013年度"));

        PiePlot pieplot=(PiePlot)chart.getPlot();
        pieplot.setLabelFont(new Font("宋体",0,11));
        // 设置饼图是圆的(true),还是椭圆的(false);默认为true
        pieplot.setCircular(true);
        // 没有数据的时候显示的内容
        pieplot.setNoDataMessage("无数据显示");
        StandardPieSectionLabelGenerator standarPieIG = new StandardPieSectionLabelGenerator("{0}:({1}.{2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance());
        pieplot.setLabelGenerator(standarPieIG);  

        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, null, session);

        return fileName;
    }
}

2、

package edu.hhxy.chart.pie;

import java.awt.Font;
import java.text.NumberFormat;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;

public class PieChart2 {

    public static String getPieChart(HttpSession session) throws Exception {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("黑心矿难", 1000);
        dataset.setValue("醉酒驾驶", 800);
        dataset.setValue("城管强拆", 400);
        dataset.setValue("医疗事故", 100);
        dataset.setValue("其他", 29);

        JFreeChart chart=ChartFactory.createPieChart("非正常死亡人数分布图", dataset, true, true, true);

        // 副标题
        chart.addSubtitle(new TextTitle("2013年度"));

        PiePlot pieplot=(PiePlot)chart.getPlot();
        pieplot.setLabelFont(new Font("宋体",0,11));
        // 设置饼图是圆的(true),还是椭圆的(false);默认为true
        pieplot.setCircular(true);
        // 没有数据的时候显示的内容
        pieplot.setNoDataMessage("无数据显示");
        StandardPieSectionLabelGenerator standarPieIG = new StandardPieSectionLabelGenerator("{0}:({1}.{2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance());
        pieplot.setLabelGenerator(standarPieIG);
        pieplot.setExplodePercent("城管强拆",0.23); 

        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, null, session);

        return fileName;
    }
}

3、

package edu.hhxy.chart.pie;

import java.awt.Font;
import java.text.NumberFormat;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.util.Rotation;

public class PieChart3 {

    public static String getPieChart(HttpSession session) throws Exception {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("黑心矿难", 1000);
        dataset.setValue("醉酒驾驶", 800);
        dataset.setValue("城管强拆", 400);
        dataset.setValue("医疗事故", 100);
        dataset.setValue("其他", 29);

        JFreeChart chart=ChartFactory.createPieChart3D("非正常死亡人数分布图", dataset, true, true, true);

        // 副标题
        chart.addSubtitle(new TextTitle("2013年度"));

        PiePlot pieplot=(PiePlot)chart.getPlot();
        pieplot.setLabelFont(new Font("宋体",0,11));
        // 设置饼图是圆的(true),还是椭圆的(false);默认为true
        pieplot.setCircular(true);
        // 没有数据的时候显示的内容
        pieplot.setNoDataMessage("无数据显示");
        StandardPieSectionLabelGenerator standarPieIG = new StandardPieSectionLabelGenerator("{0}:({1}.{2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance());
        pieplot.setLabelGenerator(standarPieIG);  

        PiePlot3D pieplot3d = (PiePlot3D)chart.getPlot(); 

        //设置开始角度
        pieplot3d.setStartAngle(120D);
        //设置方向为”顺时针方向“
        pieplot3d.setDirection(Rotation.CLOCKWISE);
        //设置透明度,0.5F为半透明,1为不透明,0为全透明
        pieplot3d.setForegroundAlpha(0.7F); 

        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, null, session);

        return fileName;
    }
}

线状图

1、

package edu.hhxy.chart.line;

import java.awt.Font;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.DateTickUnit;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardXYItemLabelGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.servlet.ServletUtilities;
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 org.jfree.ui.TextAnchor;

public class LineChart1 {

    public static String genLineChart(HttpSession session)throws Exception{

        // 访问量统计
        TimeSeries timeSeries=new TimeSeries("某网站访问量统计", Month.class);
        // 添加数据
        timeSeries.add(new Month(1,2013), 100);
        timeSeries.add(new Month(2,2013), 200);
        timeSeries.add(new Month(3,2013), 300);
        timeSeries.add(new Month(4,2013), 400);
        timeSeries.add(new Month(5,2013), 560);
        timeSeries.add(new Month(6,2013), 600);
        timeSeries.add(new Month(7,2013), 750);
        timeSeries.add(new Month(8,2013), 890);
        timeSeries.add(new Month(9,2013), 120);
        timeSeries.add(new Month(10,2013), 400);
        timeSeries.add(new Month(11,2013), 1200);
        timeSeries.add(new Month(12,2013), 1600);

        // 定义时间序列的集合
        TimeSeriesCollection lineDataset=new TimeSeriesCollection();
        lineDataset.addSeries(timeSeries);

        JFreeChart chart=ChartFactory.createTimeSeriesChart("访问量统计时间折线图", "月份", "访问量", lineDataset, true, true, true);

        //设置主标题
        chart.setTitle(new TextTitle("某网站访问量统计", new Font("隶书", Font.ITALIC, 15)));
        //设置子标题
        TextTitle subtitle = new TextTitle("2013年度", new Font("黑体", Font.BOLD, 12));
        chart.addSubtitle(subtitle);
        chart.setAntiAlias(true); 

        //设置时间轴的范围。
        XYPlot plot = (XYPlot) chart.getPlot();
        DateAxis dateaxis = (DateAxis)plot.getDomainAxis();
        dateaxis.setDateFormatOverride(new java.text.SimpleDateFormat("M月"));
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH,1)); 

        //设置曲线是否显示数据点
        XYLineAndShapeRenderer xylinerenderer = (XYLineAndShapeRenderer)plot.getRenderer();
        xylinerenderer.setBaseShapesVisible(true); 

        //设置曲线显示各数据点的值
        XYItemRenderer xyitem = plot.getRenderer();
        xyitem.setBaseItemLabelsVisible(true);
        xyitem.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
        xyitem.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
        xyitem.setBaseItemLabelFont(new Font("Dialog", 1, 12));
        plot.setRenderer(xyitem);

        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, session);

        return fileName;
    }
}

2、

package edu.hhxy.chart.line;

import java.awt.Font;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.DateTickUnit;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardXYItemLabelGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.servlet.ServletUtilities;
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 org.jfree.ui.TextAnchor;

public class LineChart2 {

    public static String genLineChart(HttpSession session)throws Exception{

        // 访问量统计
        TimeSeries timeSeries=new TimeSeries("A网站访问量统计", Month.class);
        // 添加数据
        timeSeries.add(new Month(1,2013), 100);
        timeSeries.add(new Month(2,2013), 200);
        timeSeries.add(new Month(3,2013), 300);
        timeSeries.add(new Month(4,2013), 400);
        timeSeries.add(new Month(5,2013), 560);
        timeSeries.add(new Month(6,2013), 600);
        timeSeries.add(new Month(7,2013), 750);
        timeSeries.add(new Month(8,2013), 890);
        timeSeries.add(new Month(9,2013), 120);
        timeSeries.add(new Month(10,2013), 400);
        timeSeries.add(new Month(11,2013), 1200);
        timeSeries.add(new Month(12,2013), 1600);

        // 访问量统计
        TimeSeries timeSeries2=new TimeSeries("B网站访问量统计", Month.class);
        // 添加数据
        timeSeries2.add(new Month(1,2013), 50);
        timeSeries2.add(new Month(2,2013), 100);
        timeSeries2.add(new Month(3,2013), 150);
        timeSeries2.add(new Month(4,2013), 200);
        timeSeries2.add(new Month(5,2013), 220);
        timeSeries2.add(new Month(6,2013), 300);
        timeSeries2.add(new Month(7,2013), 340);
        timeSeries2.add(new Month(8,2013), 400);
        timeSeries2.add(new Month(9,2013), 450);
        timeSeries2.add(new Month(10,2013), 500);
        timeSeries2.add(new Month(11,2013), 70);
        timeSeries2.add(new Month(12,2013), 800);

        // 定义时间序列的集合
        TimeSeriesCollection lineDataset=new TimeSeriesCollection();
        lineDataset.addSeries(timeSeries);
        lineDataset.addSeries(timeSeries2);

        JFreeChart chart=ChartFactory.createTimeSeriesChart("访问量统计时间折线图", "月份", "访问量", lineDataset, true, true, true);

        //设置主标题
        chart.setTitle(new TextTitle("A,B网站访问量统计对比图", new Font("隶书", Font.ITALIC, 15)));
        //设置子标题
        TextTitle subtitle = new TextTitle("2013年度", new Font("黑体", Font.BOLD, 12));
        chart.addSubtitle(subtitle);
        chart.setAntiAlias(true); 

        //设置时间轴的范围。
        XYPlot plot = (XYPlot) chart.getPlot();
        DateAxis dateaxis = (DateAxis)plot.getDomainAxis();
        dateaxis.setDateFormatOverride(new java.text.SimpleDateFormat("M月"));
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH,1)); 

        //设置曲线是否显示数据点
        XYLineAndShapeRenderer xylinerenderer = (XYLineAndShapeRenderer)plot.getRenderer();
        xylinerenderer.setBaseShapesVisible(true); 

        //设置曲线显示各数据点的值
        XYItemRenderer xyitem = plot.getRenderer();
        xyitem.setBaseItemLabelsVisible(true);
        xyitem.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
        xyitem.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
        xyitem.setBaseItemLabelFont(new Font("Dialog", 1, 12));
        plot.setRenderer(xyitem);

        String fileName=ServletUtilities.saveChartAsPNG(chart, 700, 500, session);

        return fileName;
    }
}

JFreeChar应用,布布扣,bubuko.com

时间: 2024-08-10 21:30:32

JFreeChar应用的相关文章

Struts2整合JFreeChar

1,导入struts2开发的jar包和struts2-jfreechart-plugin-2.3.16.3.jar 2,web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javae

spring mvc jfreechar注解配置及数据库访问

1.action类,使用注解配置的: package com.t5.manage.action;import java.awt.Font;import java.io.FileOutputStream;import java.io.IOException;import java.util.ArrayList;import java.util.List;import java.util.Map; import javax.annotation.Resource;import javax.servl

JFreeChar 讲解

-------------------转载http://my.oschina.net/u/265431/blog/86045 一.JFreeChart获取.          JFreeChart是JFreeChart公司在开源网站SourceForge.net上的一个项目,该公司的主要产品有如下:          1.JFreeReport:报表解决工具          2.JFreeChart:Java图形解决方案(Application/Applet/Servlet/Jsp)     

JFreeChart之堆叠柱形图(StackedBar)

JFreeChart之堆叠柱形图(StackedBar) JAVA JFreeChart 最近的项目使用有个功能需要使用到堆叠柱形图,看了项目以前的代码实现没有想要的结果.所以自己就先到官网下载了 Demo,Demo里有个打包好的Jar包,直接运行看到效果,但是坑爹的是貌似没有对应的源码,所以只能根据class名称直接google了,所幸在github里找到对应的源码. 点我下载 访问密码 f62b 这是运行Demo找到想要实现的效果的大致图: 我最终想要实现的效果是这样的: 如果想要实现这个效

jfreechart和springMVC+maven整合

高校的项目中一个功能是对统计的成绩进行图表分析,查找了一些资料之后感觉jfreechar上手挺快的,简单的做了几个demo也都很好实现,也能够满足项目中的需求,所以就决定使用这个工具.这里就将学习到的一些关于jfreechar的知识整理一下. 1.    引入jar包 使用这个工具一定要将他的包引入的到项目,在高校的项目中使采用maven管理这些外部文件的,所以对于引入jar包这一步就变得特别简单了,只要在maven项目的pom.xml文件中添加jfreechar的依赖就可以(maven会自动在

Struts2支持的结果类型

Struts2支持的结果类型 Struts2默认提供了一系列的结果类型,下面是struts-default.xml配置文件的配置片段:  <!-- 配置系统支持的结果类型 -->   <result-types>             <!-- Action链式处理的结果类型 -->             <result-type name="chain" class="com.opensymphony.xwork2.Action

JFreeChart与AJAX+JSON+ECharts两种处理方式生成热词统计可视化图表

本篇的思想:对HDFS获取的数据进行两种不同的可视化图表处理方式.第一种JFreeChar可视化处理生成图片文件查看.第二种AJAX+JSON+ECharts实现可视化图表,并呈现于浏览器上.   对此,给出代码示例,通过网络爬虫技术,将上传到HDFS的新浪网新闻信息实现热词统计功能,通过图表的柱状图来显示出来. ------> 目录: 1.JFreeChart可视化处理(生成本地图片) [1]HDFS文件读取 [2]JDFreeChart库应用 2.AJAX+JSON+EChart生成可视化图

Android制作曲线、柱状图、饼形等图表——使用AChartEngine

之前在java开发中实现图表使用JFreeChar组件,最近有个小项目要求在Android端进行数据分析,如何实现图表呢?查了一下google提供了一个开源组件Achartengine非常好用,可实现绘制各种图形,完全满足了开发的需要,下面就说说如何使用. 一.准备工作 下载jar包 官网地址:http://code.google.com/p/achartengine/ 网盘地址:http://pan.baidu.com/s/1EYhUe(含API文档,代码) 二.关键点说明——AchartEn

使用ECharts实现数据图表分析

  一.ECharts介绍 实现对统计数据的图形分析之前用过JFreeChar,但它是用纯java实现编码繁琐且效果不佳,后来又使用过Fusioncharts 报表工具,它是基于Flash的图表组件.以XML为数据.提供丰富的Flash动画作为图标模板,实现简单效果不错但flash是老东西了且浏览器需要flash插件的支持,更关键的是手机端浏览器基本上不支持.最近看到百度提供一套ECharts(Enterprise Charts)商业产品图表库,它是基于ZReader(一个全新的轻量级canva