首页>代码>SSM框架开发智夫子在线考试系统>/OnlineExam_taohan/src/com/taohan/online/exam/charts/StudentCount.java
package com.taohan.online.exam.charts;

import java.util.Map;
import java.util.Set;

import org.springframework.stereotype.Repository;

import com.github.abel533.echarts.axis.CategoryAxis;
import com.github.abel533.echarts.axis.ValueAxis;
import com.github.abel533.echarts.code.Magic;
import com.github.abel533.echarts.code.Tool;
import com.github.abel533.echarts.code.Trigger;
import com.github.abel533.echarts.code.X;
import com.github.abel533.echarts.code.Y;
import com.github.abel533.echarts.feature.MagicType;
import com.github.abel533.echarts.json.GsonOption;
import com.github.abel533.echarts.series.Line;
import com.taohan.online.exam.po.ClassInfo;

/**
  *
  * <p>Title: StudentCount</p>
  * <p>Description: (年级下/所有)班级的学生总量 相关图表Json数据生成</p>
  * @author: taohan
  * @date: 2018-9-17
  * @time: 下午7:03:13
  * @version: 1.0
  */

@Repository
public class StudentCount {

	/**
	 * 班级对应学生人数折线图
	 * @param data
	 * @return
	 */
	public static String createBarJson(Map<String, Object> data) {
		Set<String> set = data.keySet();
		
		GsonOption option = new GsonOption();
		option.title().text("班级学生数量统计").x(X.center).y(Y.top).borderWidth(1).textStyle().color("#438EB9");
		option.toolbox().show(true).feature(Tool.mark, Tool.restore, new MagicType(Magic.bar, Magic.line), Tool.saveAsImage).x(X.right).y(Y.top);
		//数据默认触发, 鼠标移入显示竖线  trigger(Trigger.axis)
		option.tooltip().formatter("{b} {c}人").trigger(Trigger.axis);

		option.legend().data("班级总人数").x(X.center).y(Y.bottom).borderWidth(1);
		
		Line line = new Line("班级总人数");
		
		//值轴
		ValueAxis valueAxis = new ValueAxis();
		valueAxis.axisLabel().formatter("{value}人").textStyle().color("#438EB9");
		//valueAxis.min(0);
		option.yAxis(valueAxis);
		
		//类目轴
		CategoryAxis categoryAxis = new CategoryAxis();
		//interval(0):设置横轴信息全部显示
		//rotate(-30):设置 -30 度角倾斜显示
		categoryAxis.axisLabel().interval(0).rotate(-30).textStyle().color("#438EB9");
		
		for (String className : set) {
			categoryAxis.data(className);
			ClassInfo classInfo = (ClassInfo)data.get(className);
			line.data(classInfo.getClassId());
		}
		
		option.xAxis(categoryAxis);
		line.smooth(true);
		option.series(line);
		option.grid().x(100);
		System.out.println(option.toString());
		return option.toString();
	}
}
最近下载更多
矿泉水  LV30 6月3日
林守汐  LV2 2024年6月20日
pokerf  LV5 2024年4月6日
帅潇潇  LV12 2024年1月29日
敏哥gege  LV43 2023年12月31日
shuangfu  LV25 2023年12月2日
186092  LV4 2023年9月20日
woodsugar  LV4 2023年6月2日
akittyboy  LV9 2023年5月12日
wubinbin  LV11 2023年2月11日
最近浏览更多
矿泉水  LV30 6月3日
ldzhouyong 4月27日
暂无贡献等级
Lxmzdm123  LV3 3月13日
jackwong  LV7 2月24日
暂无贡献等级
ma406805131  LV19 2024年12月9日
微信网友_7206713294606336 2024年10月12日
暂无贡献等级
微信网友_7151914139078656  LV2 2024年9月4日
plusangel 2024年8月29日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友