以前用JFreeChart的時候每次都需要修改一些顯示樣式和代碼
web
<servlet>
<servlet
<servlet
</servlet>
<servlet
<servlet
<url
</servlet
柱狀圖封裝和設置
public static JFreeChart getLineChart(String title
JFreeChart chart = ChartFactory
LineRenderer
renderer
renderer
renderer
CategoryPlot plot = chart
CategoryAxis domainAxis = plot
plot
ValueAxis rangeAxis = plot
rangeAxis
rangeAxis
plot
plot
plot
plot
chart
chart
return chart;
}
調用代碼
public JFreeChart getSingleChart(String chartType) {
//構造數據
double[][] data = new double[
for(int i =
{ data[
//根據類型顯示不同類型圖表
String[] rowKeys = new String[]{
String[] columnKeys = new String[]{
CategoryDataset dataset = DatasetUtilities
if(chartType
return com
else if(chartType
return com
else //if(chartType
return com
}
頁面代碼
<%@ page contentType=
<%@ page import=
<jsp:useBean scope=
<% String chartType = request
if(chartType == null) chartType =
JFreeChart chart = chartTest
String graphURL =
{
filename = ServletUtilities
graphURL = request
}
%>
<HTML>
<HEAD>
<title></title>
<LINK type=
</HEAD>
<body bottomMargin=
<form name=
<table width=
<tr>
<td valign=
<TABLE class=
cellSpacing=
<TR>
<TD class=
<TABLE id=
<TR>
<TD vAlign=
<TABLE id=
cellSpacing=
<TR>
<TD noWrap align=center noWrap>
圖表類型
</TD>
<TD noWrap>
<select name=
<option value=
<option value=
</select>
</TD>
<TD>
<a #
<img src=
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD class=
<table width=
<tr height=
<td>
<img src=
</td>
</tr>
</table>
</TD>
</TR>
</TABLE>
</td>
</tr>
</table>
</form>
<script>
function chkFrm()
{
document
}
</script> </body> </HTML>
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25744.html