最近做毕设想要在web端显示图表,网上有很多图表的插件,JFreeChart也不错,不过我选择的是ChartDirector。
一、需求:分页显示学生访问对应课程次数的柱状图,(之前我爬取了网站上的一些课程,并记录了用户访问的记录)
二、实现:
(1)ChartDirector自带一个jsp文件,复制到项目中,还有将ChartDirector.jar包引入项目中
(2)要显示图表的jsp界面,其中chart1URL和imageMap1是Action层处理好传递过来的数据,分页的代码可以忽略掉,其实真实的界面代码也就几行。
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@include file="/WEB-INF/jsp/public/list.jspf" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的历史浏览记录</title>
</head>
<body>
<