jfreeChart折线图参数设置

package com.iman.nrms.nrmwns.wrm.analyse.domain.util;

import java.awt.Color;
import java.awt.Font;
import java.text.DecimalFormat;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;

/**
 * 格式化 JFreeChart 输出图片使用
 * 
 *   
 * Author : 
 * Date   : Nov 26, 2009
 * Time   : 11:50:41 AM 
 * Version: 1.0
 */
public class FormatPic {
	/**
	 * 格式化折线图使用
	 * 
	 * @param chart
	 * @returnType: void
	 * @author: 
	 * @data: Nov 26, 2009
	 * @time: 11:51:26 AM
	 */
	public static void setView(JFreeChart chart){
				 chart.setTextAntiAlias(false); 
				   chart.setBackgroundPaint(Color.WHITE); 
				   CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); 
				   // x轴 // 分类轴网格是否可见 
				   categoryplot.setDomainGridlinesVisible(true); 
				   // y轴 //数据轴网格是否可见 
				   categoryplot.setRangeGridlinesVisible(true); 
				   
				   this.configFont(chart); 
				   categoryplot.setRangeGridlinePaint(Color.WHITE);// 虚线色彩 
				   categoryplot.setDomainGridlinePaint(Color.WHITE);// 虚线色彩 
				   categoryplot.setBackgroundPaint(Color.lightGray); 
				   // 设置轴和面板之间的距离 
				   // categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); 
				   CategoryAxis domainAxis = categoryplot.getDomainAxis(); 
				   domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 横轴上的 
				   // Lable 
				   // 45度倾斜 
				   // 设置距离图片左端距离 
				   domainAxis.setLowerMargin(0.0); 
				   // 设置距离图片右端距离 
				   domainAxis.setUpperMargin(0.0); 
				   NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); 
				   numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 
				   numberaxis.setAutoRangeIncludesZero(true); 
				   // 获得renderer 注意这里是下嗍造型到lineandshaperenderer!! 
				   LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot 
					 .getRenderer(); 
				   lineandshaperenderer.setBaseShapesVisible(true); // series 点(即数据点)可见 
				   lineandshaperenderer.setBaseLinesVisible(true); // series 点(即数据点)间有连线可见 
				   // 显示折点数据 
				   // lineandshaperenderer.setBaseItemLabelGenerator(new 
				   // StandardCategoryItemLabelGenerator()); 
				   // lineandshaperenderer.setBaseItemLabelsVisible(true); 
	}
}

 

你可能感兴趣的:(jfreechart,UP)