首页>代码>SSM框架开发智夫子在线考试系统>/OnlineExam_taohan/src/com/taohan/online/exam/charts/StudentExamInfoCharts.java
package com.taohan.online.exam.charts; import java.util.List; 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.PointerType; 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.Bar; import com.github.abel533.echarts.series.Line; import com.taohan.online.exam.po.StudentExamInfo; /** * * <p>Title: StudentExamInfoCharts</p> * <p>Description: 学生考试信息 图表 Json 数据 生成</p> * @author: taohan * @date: 2018-9-19 * @time: 上午10:26:55 * @version: 1.0 */ public class StudentExamInfoCharts { public static String createExamCountBarJson(List<StudentExamInfo> examInfos) { 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); option.tooltip().show(true).formatter("{b} {c}次"); option.legend().data("学生考试次数统计").x(X.center).y(Y.bottom); Bar bar = new Bar(); //值轴 ValueAxis valueAxis = new ValueAxis(); //设置y轴不出现小数值 valueAxis.interval(1); valueAxis.axisLabel().formatter("{value} 次"); option.yAxis(valueAxis); //类目轴 CategoryAxis categoryAxis = new CategoryAxis(); categoryAxis.axisLabel().interval(0); for (StudentExamInfo studentExamInfo : examInfos) { bar.data(studentExamInfo.getExamSum()); categoryAxis.data(studentExamInfo.getStudentName()); } bar.barCategoryGap("20"); option.xAxis(categoryAxis); option.series(bar); return option.toString(); } public static String createAvgCountLineJson(List<StudentExamInfo> examInfos) { 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); option.tooltip().show(true).trigger(Trigger.axis).axisPointer().type(PointerType.cross).crossStyle().color("#999"); option.legend().data("考试次数", "平均分").x(X.center).y(Y.bottom); Line line = new Line("考试次数").smooth(true); Bar bar = new Bar("平均分"); //值轴 ValueAxis valueAxis = new ValueAxis(); //设置y轴不出现小数值 valueAxis.interval(1); valueAxis.axisLabel().formatter("{value} 次"); //option.yAxis(valueAxis); ValueAxis valueAxis1 = new ValueAxis(); valueAxis1.interval(1); valueAxis1.axisLabel().formatter("{value} 分"); option.yAxis(valueAxis, valueAxis1); //类目轴 CategoryAxis categoryAxis = new CategoryAxis(); categoryAxis.axisLabel().interval(0); for (StudentExamInfo studentExamInfo : examInfos) { if (studentExamInfo.getAvgScore() != null || studentExamInfo.getExamSum() != 0) { bar.data(studentExamInfo.getAvgScore()/studentExamInfo.getExamSum()); } else { bar.data("暂无记录"); } line.data(studentExamInfo.getExamSum()); categoryAxis.data(studentExamInfo.getStudentName()); } //实现双 y 轴,使用 yAxisIndex() 指定应用到哪个 y 轴 bar.barCategoryGap("20").yAxisIndex(1); option.xAxis(categoryAxis); option.series(bar, line); return option.toString(); } public static String createStudentExamLineJson(List<StudentExamInfo> examInfos) { 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); option.tooltip().show(true).formatter("{b} {c}分").trigger(Trigger.axis); option.legend().data("得分").x(X.center).y(Y.bottom); Line line = new Line("试卷得分"); //值轴 ValueAxis valueAxis = new ValueAxis(); //设置y轴不出现小数值 valueAxis.interval(1); valueAxis.axisLabel().formatter("{value} 分"); option.yAxis(valueAxis); //类目轴 CategoryAxis categoryAxis = new CategoryAxis(); categoryAxis.axisLabel().interval(0).rotate(-30); for (StudentExamInfo studentExamInfo : examInfos) { line.data(studentExamInfo.getExamScore()); categoryAxis.data(studentExamInfo.getExamPaperName()); } option.xAxis(categoryAxis); option.series(line); System.out.println(option.toString()); return option.toString(); } }
最近下载更多
最近浏览更多
微信网友_7206713294606336
10月12日
暂无贡献等级
微信网友_7151914139078656 LV2
9月4日
plusangel
8月29日
暂无贡献等级
傲世彩云之南 LV5
6月27日
3334004690 LV10
6月22日
lxzlxzl LV1
6月21日
林守汐 LV2
6月20日
xzg123456 LV6
6月19日
865581316LLL LV6
6月12日
chirsbey2
5月10日
暂无贡献等级