All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.wicp.tams.component.tools.HighchartsUtil Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package net.wicp.tams.component.tools;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.ArrayUtils;

import net.wicp.tams.commons.constant.DateFormatCase;
import net.wicp.tams.component.assistbean.HighchartsBean;

public class HighchartsUtil {
	/***
	 * 创建报表用的横坐标标题
	 * 
	 * @param begin
	 *            开始时间
	 * @param end
	 *            结束时间
	 * @return
	 */
	public static String createTitle(Date begin, Date end) {
		StringBuffer buff = new StringBuffer("[");
		Calendar ca = Calendar.getInstance();
		while (end.compareTo(begin) >= 0) {
			buff.append("'"
					+ DateFormatCase.YYYY_MM_DD.getInstanc()
							.format(begin) + "',");
			ca.setTime(begin);
			ca.add(Calendar.DATE, 1);
			begin = ca.getTime();
		}
		buff.delete(buff.length() - 1, buff.length());
		buff.append("]");
		return buff.toString();
	}

	/***
	 * 新建容器集合
	 * @param items
	 * @return
	 */
	public static List> newHighchartsSeries(
			String... items) {
		List> retObj = new ArrayList>();
		if (ArrayUtils.isEmpty(items)) {
			return retObj;
		}
		for (String item : items) {
			HighchartsBean temp = new HighchartsBean(item);
			retObj.add(temp);
		}
		return retObj;
	}

	public static List> newHighchartsSeriesD(
			String... items) {
		List> retObj = new ArrayList>();
		if (ArrayUtils.isEmpty(items)) {
			return retObj;
		}
		for (String item : items) {
			HighchartsBean temp = new HighchartsBean(item);
			retObj.add(temp);
		}
		return retObj;
	}
	
	public static List> newHighchartsSeriesB(
			String... items) {
		List> retObj = new ArrayList>();
		if (ArrayUtils.isEmpty(items)) {
			return retObj;
		}
		for (String item : items) {
			HighchartsBean temp = new HighchartsBean(item);
			retObj.add(temp);
		}
		return retObj;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy