代码调整
This commit is contained in:
@@ -2,7 +2,9 @@ package com.njcn.echarts.util;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.njcn.echarts.json.BarGenerator;
|
||||
import com.njcn.echarts.json.LineGenerator;
|
||||
import com.njcn.echarts.json.PieGenerator;
|
||||
import com.njcn.web.utils.RestTemplateUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -46,8 +48,8 @@ public class DrawPicUtil {
|
||||
*/
|
||||
private String drawPic(String option, int width, int height) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("width", width == 0 ? 925 : width);
|
||||
jsonObject.set("height", height == 0 ? 300 : height);
|
||||
jsonObject.set("width", width == 0 ? 950 : width);
|
||||
jsonObject.set("height", height == 0 ? 400 : height);
|
||||
jsonObject.set("option", JSONUtil.parseObj(option));
|
||||
ResponseEntity<String> picResult = RestTemplateUtil.post(URL, jsonObject, String.class);
|
||||
return Objects.requireNonNull(picResult.getBody()).indexOf("image/png") > 0 ? picResult.getBody() : "";
|
||||
@@ -160,7 +162,7 @@ public class DrawPicUtil {
|
||||
* @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);
|
||||
String monthJson = BarGenerator.generateMonthOption( xName, times, year, flag);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
@@ -181,7 +183,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawReason(List<String> xname, List<Map<String,Object>> map2, int width, int height) {
|
||||
String monthJson = LineGenerator.generateReasonOption(xname, map2);
|
||||
String monthJson = PieGenerator.generateReasonOption(xname, map2);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
@@ -202,7 +204,29 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawType(List<String> xname, List<Map<String,Object>> map2, int width, int height) {
|
||||
String monthJson = LineGenerator.generateTypeOption(xname, map2);
|
||||
String monthJson = PieGenerator.generateTypeOption(xname, map2);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 绘制生成暂降密度图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventDensity(Number[][] data) {
|
||||
return drawEventDensity(data, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制生成暂降类型图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventDensity(Number[][] data, int width, int height) {
|
||||
String eventDensityJson = BarGenerator.generateEventDensity(data);
|
||||
return drawPic(eventDensityJson, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user