代码提交
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package com.njcn.echarts.json;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.njcn.echarts.pojo.bo.TolerateData;
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import org.icepear.echarts.Option;
|
||||
import org.icepear.echarts.charts.bar.BarLabel;
|
||||
import org.icepear.echarts.charts.bar.BarSeries;
|
||||
import org.icepear.echarts.charts.line.LineSeries;
|
||||
import org.icepear.echarts.charts.pie.PieLabel;
|
||||
import org.icepear.echarts.charts.pie.PieSeries;
|
||||
import org.icepear.echarts.charts.scatter.ScatterSeries;
|
||||
import org.icepear.echarts.components.coord.AxisNameTextStyle;
|
||||
import org.icepear.echarts.components.coord.SplitLine;
|
||||
@@ -19,7 +23,9 @@ import org.icepear.echarts.components.tooltip.Tooltip;
|
||||
import org.icepear.echarts.origin.util.SeriesOption;
|
||||
import org.icepear.echarts.render.Engine;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -215,5 +221,110 @@ public class LineGenerator {
|
||||
return ENGINE.renderJsonOption(iticOption);
|
||||
}
|
||||
|
||||
/***
|
||||
* 生成月份统计
|
||||
* @author wr
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateMonthOption(List<String> xName, List<Integer> times, String year, Integer flag) {
|
||||
xName.set(0, xName.get(0) + "\n" + "(" + year + ")");
|
||||
String name = "";
|
||||
Option iticOption = new Option();
|
||||
//取消渲染动画
|
||||
iticOption.setAnimation(false);
|
||||
//背景色
|
||||
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
if (flag == 0) {
|
||||
iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("月份统计"));
|
||||
name = "月份";
|
||||
} else {
|
||||
iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("天数统计"));
|
||||
name = "天数";
|
||||
}
|
||||
//上下左右的图内间距
|
||||
iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||
//设置图例
|
||||
iticOption.setLegend(new Legend().setData(new String[]{"暂降次数"}).setTop("26px").setLeft(10).setBottom("94%").setShow(true));
|
||||
//设置图例对应的颜色
|
||||
iticOption.setColor(new String[]{"#FF8C00"});
|
||||
//横坐标
|
||||
iticOption.setXAxis(new CategoryAxis()
|
||||
.setBoundaryGap(true)
|
||||
.setName(name)
|
||||
.setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
|
||||
.setData(xName.toArray())
|
||||
);
|
||||
//纵坐标
|
||||
iticOption.setYAxis(new ValueAxis[]{
|
||||
new ValueAxis()
|
||||
.setName("次")
|
||||
.setType("value")
|
||||
});
|
||||
|
||||
//配置暂降次数
|
||||
BarSeries probability = new BarSeries()
|
||||
.setName("暂降次数")
|
||||
.setLabel(new BarLabel().setShow(true).setColor("#8B008B"))
|
||||
.setData(times);
|
||||
iticOption.setSeries(new SeriesOption[]{probability});
|
||||
return ENGINE.renderJsonOption(iticOption);
|
||||
}
|
||||
|
||||
/***
|
||||
* 生成暂降原因
|
||||
* @author wr
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateReasonOption(List<String> xName, List<Map<String,Object>> map2) {
|
||||
|
||||
Option iticOption = new Option();
|
||||
//取消渲染动画
|
||||
iticOption.setAnimation(false);
|
||||
//背景色
|
||||
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
iticOption.setTitle(new Title().setRight("10%").setText("暂降原因"));
|
||||
//上下左右的图内间距
|
||||
iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||
//设置图例
|
||||
iticOption.setLegend(new Legend().setOrient("vertical").setData(xName.toArray()).setTop("26px").setLeft(10).setBottom("94%").setShow(true));
|
||||
String s = map2.toString();
|
||||
//配置暂降次数
|
||||
PieSeries probability = new PieSeries()
|
||||
.setType("pie")
|
||||
.setName("暂降原因")
|
||||
.setLabel(new PieLabel().setFormatter("{b}:{d}%"))
|
||||
.setData(map2);
|
||||
iticOption.setSeries(new SeriesOption[]{probability});
|
||||
return ENGINE.renderJsonOption(iticOption);
|
||||
}
|
||||
|
||||
/***
|
||||
* 生成暂降类型
|
||||
* @author wr
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateTypeOption(List<String> xName, List<Map<String,Object>> map) {
|
||||
|
||||
Option iticOption = new Option();
|
||||
//取消渲染动画
|
||||
iticOption.setAnimation(false);
|
||||
//背景色
|
||||
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
iticOption.setTitle(new Title().setRight("10%").setText("暂降类型"));
|
||||
//上下左右的图内间距
|
||||
iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||
//设置图例
|
||||
iticOption.setLegend(new Legend().setOrient("vertical").setData(xName.toArray()).setTop("26px").setLeft(10).setBottom("94%").setShow(true));
|
||||
//配置暂降次数
|
||||
PieSeries probability = new PieSeries()
|
||||
.setType("pie")
|
||||
.setName("暂降类型")
|
||||
.setLabel(new PieLabel().setFormatter("{b}:{d}%"))
|
||||
.setData(map);
|
||||
iticOption.setSeries(new SeriesOption[]{probability});
|
||||
return ENGINE.renderJsonOption(iticOption);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -137,10 +138,71 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawPersistentTime(List<String> ylinedata, List<String> ybardata, int width, int height) {
|
||||
String persistentTimeJson = LineGenerator.generateEventAmplitudeOption(ylinedata, ybardata);
|
||||
String persistentTimeJson = LineGenerator.generatePersistentTimeOption(ylinedata, ybardata);
|
||||
return drawPic(persistentTimeJson, width, height);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 绘制生成月份统计图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawMonth(List<String> xName, List<Integer> times, String year, Integer flag) {
|
||||
return drawMonth(xName, times, year, flag, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制生成月份统计图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawMonth(List<String> xName, List<Integer> times, String year, Integer flag, int width, int height) {
|
||||
String monthJson = LineGenerator.generateMonthOption( xName, times, year, flag);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制生成暂降原因图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawReason(List<String> xname, List<Map<String,Object>> map2) {
|
||||
return drawReason(xname, map2, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制生成暂降原因图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawReason(List<String> xname, List<Map<String,Object>> map2, int width, int height) {
|
||||
String monthJson = LineGenerator.generateReasonOption(xname, map2);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制生成暂降类型图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawType(List<String> xname, List<Map<String,Object>> map2) {
|
||||
return drawType(xname, map2, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制生成暂降类型图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawType(List<String> xname, List<Map<String,Object>> map2, int width, int height) {
|
||||
String monthJson = LineGenerator.generateTypeOption(xname, map2);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user