提交地图修改内容
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.njcn.echarts.line;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.github.abel533.echarts.Grid;
|
||||
import com.github.abel533.echarts.axis.AxisLabel;
|
||||
import com.github.abel533.echarts.axis.CategoryAxis;
|
||||
import com.github.abel533.echarts.axis.SplitLine;
|
||||
import com.github.abel533.echarts.axis.ValueAxis;
|
||||
import com.github.abel533.echarts.code.AxisType;
|
||||
import com.github.abel533.echarts.code.NameLocation;
|
||||
import com.github.abel533.echarts.code.SeriesType;
|
||||
import com.github.abel533.echarts.json.GsonOption;
|
||||
import com.github.abel533.echarts.series.Bar;
|
||||
import com.github.abel533.echarts.series.Line;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年08月18日 14:39
|
||||
*/
|
||||
public class LineOptionUtil {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
JSONObject optionJson = testEchart();
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<HttpResult> forEntity = restTemplate.getForEntity("http://192.168.1.13:8910?opt={1}&width={2}&height={3}", HttpResult.class, optionJson.toString(), 714, 300);
|
||||
//返回图片对应的base64
|
||||
System.out.println(forEntity.getBody().getData());
|
||||
System.out.println(1);
|
||||
|
||||
}
|
||||
|
||||
public static JSONObject testEchart() {
|
||||
List<String> xName = Stream.of("0", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%").collect(Collectors.toList());
|
||||
GsonOption option = new GsonOption();
|
||||
option.backgroundColor("#F9F9F9");
|
||||
// 大标题、位置
|
||||
String title = "暂降幅值的概率分布函数";
|
||||
option.title().text(title).x("center");
|
||||
// 提示工具
|
||||
// 在轴上触发提示数据
|
||||
option.tooltip().show(false);
|
||||
// 工具栏
|
||||
// 显示,保存为图片
|
||||
option.toolbox().show(false);
|
||||
// 图例
|
||||
option.color("#FF7E50");
|
||||
//控制图标在dataroom中的位置大小
|
||||
option.grid(new Grid().left("3%").right("11%").bottom("5%").containLabel(true));
|
||||
// 轴分类
|
||||
CategoryAxis xAxis = new CategoryAxis();
|
||||
xAxis.data(xName.toArray());
|
||||
xAxis.nameGap(5);
|
||||
xAxis.name("暂降幅值");
|
||||
// 起始和结束两端空白策略
|
||||
xAxis.boundaryGap(false);
|
||||
// x轴
|
||||
option.xAxis(xAxis);
|
||||
Line line = new Line("暂降幅值");
|
||||
line.setType(SeriesType.line);
|
||||
line.data(0, 10, 11, 15, 16, 30, 48, 66, 75, 89);
|
||||
option.series(line);
|
||||
// y轴
|
||||
ValueAxis yAxis = new ValueAxis();
|
||||
yAxis.name("概率分布").type(AxisType.value).nameGap(50).nameLocation(NameLocation.middle).axisLabel(new AxisLabel().formatter("{value} %"));
|
||||
option.yAxis(yAxis);
|
||||
String optionStr = option.toString().replace(" ", "");
|
||||
return new JSONObject(optionStr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user