<% @page contenttype = " text/html; charset=gb2312 " %>
<% @page import = " java.io.filenotfoundexception " %>
<% @page import = " java.io.fileoutputstream " %>
<% @page import = " org.apache.commons.logging.log " %>
<% @page import = " java.io.ioexception " %>
<% @page import = " org.apache.commons.logging.logfactory " %>
<% @page import = " org.jfree.chart.chartfactory " %>
<% @page import = " org.jfree.chart.chartutilities " %>
<% @page import = " org.jfree.chart.jfreechart " %>
<% @page import = " org.jfree.chart.plot.plotorientation " %>
<% @page import = " org.jfree.data.category.categorydataset " %>
<% @page import = " org.jfree.data.category.defaultcategorydataset " %>
<% @page import = " java.awt.color " %>
<% @page import = " org.jfree.chart.renderer.category.barrenderer3d " %>
<% @page import = " org.jfree.chart.labels.standardcategoryitemlabelgenerator " %>
<% @page import = " org.jfree.chart.axis.categoryaxis " %>
<% @page import = " org.jfree.chart.plot.categoryplot " %>
<%
defaultcategorydataset dataset = new defaultcategorydataset();
dataset.addvalue( 150 , " 北京 " , " 苹果 " );
dataset.addvalue( 530 , " 上海 " , " 苹果 " );
dataset.addvalue( 160 , " 广州 " , " 苹果 " );
dataset.addvalue( 120 , " 北京 " , " 梨子 " );
dataset.addvalue( 230 , " 上海 " , " 梨子 " );
dataset.addvalue( 360 , " 广州 " , " 梨子 " );
dataset.addvalue( 600 , " 北京 " , " 葡萄 " );
dataset.addvalue( 430 , " 上海 " , " 葡萄 " );
dataset.addvalue( 560 , " 广州 " , " 葡萄 " );
dataset.addvalue( 400 , " 北京 " , " 香蕉 " );
dataset.addvalue( 530 , " 上海 " , " 香蕉 " );
dataset.addvalue( 660 , " 广州 " , " 香蕉 " );
dataset.addvalue( 500 , " 北京 " , " 荔枝 " );
dataset.addvalue( 630 , " 上海 " , " 荔枝 " );
dataset.addvalue( 430 , " 广州 " , " 荔枝 " );
jfreechart chart = chartfactory.createbarchart3d( " 水果销量图统计-by alpha " , " 水果种类-http://www.blogjava.net/alpha/ " , " 销量 " ,dataset,plotorientation.vertical, true , false , false );
chart.setbackgroundpaint(color.white);
categoryplot plot = chart.getcategoryplot();
categoryaxis domainaxis = plot.getdomainaxis();
// domainaxis.setverticalcategorylabels( false );
plot.setdomainaxis(domainaxis);
barrenderer3d renderer = new barrenderer3d();
renderer.setbaseoutlinepaint(color.black);
// 设置每个地区所包含的平行柱的之间距离
renderer.setitemmargin( 0.1 );
// 显示每个柱的数值,并修改该数值的字体属性
renderer.setitemlabelgenerator( new standardcategoryitemlabelgenerator());
renderer.setitemlabelsvisible( true );
plot.setrenderer(renderer);
// 设置柱的透明度
plot.setforegroundalpha( 0 .8f);
chartutilities.writechartasjpeg(response.getoutputstream(),chart, 640 , 400 );
%>