日期:2014-05-16 浏览次数:20691 次
width:800,
height:600,
El:'tb',
title:'图表',
closable:true,
plain:false,
buttonAlign:'center',
collapsible:true,
html : '<iframe name="main" scrolling="auto" frameborder="0" width="100%" height="100%" src="./jfreecharDemo/testJfreeCharDemo.jsp"></iframe>'
for(int i=0;i<list.size();i++){
				monthdata = (MonthData) list.get(i);
				dataset.addValue(monthdata.getRainfall(), "dd", String.valueOf(monthdata.getMonth()));
			}
			JFreeChart chart = ChartFactory.createBarChart3D("雨量统计图", 
	                  "监测点",
	                  "雨量",
	                  dataset,
	                  PlotOrientation.VERTICAL,
	                  false,
	                  false,
	                  false);
			CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象
			   // 设置图表的纵轴和横轴org.jfree.chart.axis.CategoryAxis
			   CategoryAxis domainAxis = plot.getDomainAxis();
			   NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
			  
			   //解决中文乱码问题
			   TextTitle textTitle = chart.getTitle();
			   textTitle.setFont(new Font("黑体", Font.PLAIN, 42));
			   domainAxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 11));
			   domainAxis.setLabelFont(new Font("宋体", Font.PLAIN, 24));
			   numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
			   numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 24));
			//   chart.getLegend().setItemFont(new Font("宋体", Font.PLAIN, 12));
			//   domainAxis.setLowerMargin(0.1);// 设置距离图片左端距离此时为10%
			//   domainAxis.setUpperMargin(0.1);// 设置距离图片右端距离此时为百分之10
			//   domainAxis.setCategoryLabelPositionOffset(10);// 图表横轴与标签的距离(10像素)
			//   domainAxis.setCategoryMargin(0.2);// 横轴标签之间的距离20%
			   // domainAxis.setMaximumCategoryLabelLines(1);
			   // domainAxis.setMaximumCategoryLabelWidthRatio(0);
			String filename;
			try {
				filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, null, reques