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); 
	}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值