SpringBoot纯后台生成Echarts图片(一)
紧接 SpringBoot纯后台生成Echarts图片(一),在这篇的基础上,来生成折线图
一. 项目工程结构
二.项目依赖说明
项目的pom.xml配置,属性配置 见第一篇
三.项目代码说明
(1)echarts-pojo模块(数据模型)LinesData.java
package com.lhf.springboot.echarts.pojo;
public class LinesData {
private String title;
private LineParam lineParam;
private boolean isHorizontal = true;
//省略get/set方法
}
(2)echarts-pojo模块(数据模型)LineParam.java
package com.lhf.springboot.echarts.pojo;
import java.util.List;
public class LineParam {
private String legendName;
private String[] ydatas;
private List(3)echarts-option模块(组装图表option)-EchartLine.java(组装折线图option)(核心)
package com.lhf.springboot.echarts.option;
import com.github.abel533.echarts.Legend;
import com.github.abel533.echarts.axis.AxisLabel;
import com.github.abel533.echarts.axis.AxisLine;
import com.github.abel533.echarts.axis.CategoryAxis;
import com.github.abel533.echarts.axis.ValueAxis;
import com.github.abel533.echarts.code.Position;
import com.github.abel533.echarts.code.Trigger;
import com.github.abel533.echarts.json.GsonOption;
import com.github.abel533.echarts.series.Line;
import com.github.abel533.echarts.style.LineStyle;
import com.github.abel533.echarts.style.TextStyle;
import com.github.abel533.echarts.style.itemstyle.Normal;
import com.lhf.springboot.echarts.EnhancedOption;
import com.lhf.springboot.echarts.pojo.LinesData;
import java.util.List;
public class EchartLine {
public static GsonOption createLine(LinesData linesData){
//String[] types = { "邮件营销", "联盟广告", "视频广告" };
//int[][] datas = { { 120, 132, 101, 134, 90, 230, 210 }, { 220, 182, 191, 234, 290, 330, 310 }, { 150, 232, 201, 154, 190, 330, 410 } };
//String title = "广告数据";
String title = linesData.getTitle();
String legendName = linesData.getLineParam().getLegendName();
String[] ydatas = linesData.getLineParam().getYdatas();
boolean isHorizontal = linesData.isHorizontal();
//String[] types = legendName;
String[] types = {title};
//int[][] xdatas = { { 120, 132, 101, 134, 90, 230, 210 }, { 220, 182, 191, 234, 290, 330, 310 }, { 150, 232, 201, 154, 190, 330, 410 } };
List