JSP与jfreechart集成 柱状图

配置信息参考饼装图

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.data.general.*" %>
<%@ page import="java.awt.*" %>
<%@ page import="org.jfree.chart.servlet.*" %>
<%@ page import="org.jfree.data.category.*" %>
<%@ page import="org.jfree.chart.plot.*" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%

DefaultCategoryDataset category = new DefaultCategoryDataset();

category.setValue(30, "", "管理人员");
category.setValue(40, "", "市场人员");
category.setValue(35, "", "软件开发人员");
category.setValue(30, "", "服务人员");


StandardChartTheme standardChartTheme = new StandardChartTheme("name");
standardChartTheme.setLargeFont(new Font("楷体",Font.BOLD, 12));//可以改变轴向的字体
standardChartTheme.setRegularFont(new Font("宋体",Font.BOLD, 12));//可以改变图例的字体
standardChartTheme.setExtraLargeFont(new Font("隶书",Font.BOLD, 12));//可以改变图标的标题字体
ChartFactory.setChartTheme(standardChartTheme);//设置主题

JFreeChart freeChart = ChartFactory.createBarChart("某公司人员机构", "人员分布", "人员数量",category, PlotOrientation.VERTICAL, true, false, false);


String fileName = ServletUtilities.saveChartAsJPEG(freeChart,800,600,session);
String url = request.getContextPath() + "/DisplayChart?filename=" + fileName;

%>
<img src="<%= url %>" width="800" height="600">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值