利用JFreechart绘制复杂柱状图(二)

阅读更多
web.xml


	
		DisplayChart
		org.jfree.chart.servlet.DisplayChart
	
	
		DisplayChart
		/DisplayChart
	



demo.jsp
<%@ page contentType="text/html;charset=GBK"%>

<%@ page
	import="org.jfree.chart.ChartFactory,org.jfree.chart.JFreeChart,org.jfree.chart.plot.PlotOrientation,org.jfree.chart.servlet.ServletUtilities,org.jfree.data.category.CategoryDataset,org.jfree.data.general.DatasetUtilities"%>

<%
	double[][] data = new double[][] { { 1310, 1220, 1110, 1000 },
			{ 720, 700, 680, 640 }, { 1130, 1020, 980, 800 },
			{ 440, 400, 360, 300 } };
	String[] rowKeys = { "pig", "beef", "chicken", "fish" };

	String[] columnKeys = { "Guangzhou", "Shenzhen", "Dongguan",
			"Foshan" };
	CategoryDataset dataset = DatasetUtilities.createCategoryDataset(
			rowKeys, columnKeys, data);
	JFreeChart chart = ChartFactory.createBarChart3D("JFreeChart Demo",
			"type", "amount", dataset, PlotOrientation.VERTICAL, true,
			false, false);
	String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300,
			null, session);
	String graphURL = request.getContextPath()
			+ "/DisplayChart?filename=" + filename;
%>


你可能感兴趣的:(jfreechart,柱状图)