JFreeChart 3D 2차원 그림 그리기

2382 단어 jfreechart
public String barChart() throws Exception{
		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		dataset.addValue(100, " ", " ");
		dataset.addValue(200, " ", " ");
		dataset.addValue(150, " ", " ");
		dataset.addValue(260, " ", " ");
		dataset.addValue(210, " ", " ");
		dataset.addValue(120, " ", " ");
		dataset.addValue(370, " ", " ");
		dataset.addValue(310, " ", " ");
		dataset.addValue(340, " ", " ");
		dataset.addValue(410, " ", " ");
		dataset.addValue(480, " ", " ");
		dataset.addValue(400, " ", " ");
		dataset.addValue(530, " ", " ");
		dataset.addValue(500, " ", " ");
		dataset.addValue(580, " ", " ");
	    
	    JFreeChart jfree = 
	    	ChartFactory.createBarChart3D(" ", " ", " ", dataset, 
	    			PlotOrientation.VERTICAL, true, true, false);
	    
	    CategoryPlot categoryplot = (CategoryPlot) jfree.getPlot();
		NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();  
		CategoryAxis domainAxis = categoryplot.getDomainAxis();  
		TextTitle textTitle = jfree.getTitle();
		textTitle.setFont(new Font(" ", Font.PLAIN, 20));   
		domainAxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 14));  
		domainAxis.setLabelFont(new Font(" ", Font.PLAIN, 16));  
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 14));  
		numberaxis.setLabelFont(new Font(" ", Font.PLAIN, 16));  
		jfree.getLegend().setItemFont(new Font(" ", Font.PLAIN, 16));
	    
	    //path 
		String path = ServletActionContext.getRequest().getSession().getServletContext().getRealPath("/");
		
		if(imgName==null || "".equals(imgName)){
			imgName = "default";
		}
		
		// 
		ChartUtilities.saveChartAsJPEG(new File(path + "img/" + imgName + "Bar.jpg"), jfree, 535, 400);
	    
		return "success";
	}

효과도는 첨부에 있다
 

좋은 웹페이지 즐겨찾기