提交地图修改内容
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package com.njcn.echarts.bar;
|
||||
|
||||
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.SeriesType;
|
||||
import com.github.abel533.echarts.json.GsonOption;
|
||||
import com.github.abel533.echarts.series.Bar;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* 用于组装柱状图的option数据
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年08月18日 10:58
|
||||
*/
|
||||
public class BarOptionUtil {
|
||||
|
||||
|
||||
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("江苏省", "四川省", "海南省").collect(Collectors.toList());
|
||||
GsonOption option = new GsonOption();
|
||||
// 大标题、位置
|
||||
String title = "区域统计";
|
||||
option.title().text(title).x("center");
|
||||
// 提示工具
|
||||
// 在轴上触发提示数据
|
||||
option.tooltip().show(false);
|
||||
// 工具栏
|
||||
// 显示,保存为图片
|
||||
option.toolbox().show(false);
|
||||
// 图例
|
||||
option.color("#FF7E50");
|
||||
option.legend("暂降次数");
|
||||
//控制图标在dataroom中的位置大小
|
||||
option.grid(new Grid().left("3%").right("15%").bottom("5%").containLabel(true));
|
||||
// 轴分类
|
||||
CategoryAxis xAxis = new CategoryAxis();
|
||||
xAxis.data(xName.toArray());
|
||||
xAxis.splitLine(new SplitLine().show(false));
|
||||
xAxis.name("地区\n(监测点数)");
|
||||
xAxis.axisLabel(new AxisLabel().interval(0).show(true));
|
||||
// 起始和结束两端空白策略
|
||||
xAxis.boundaryGap(true);
|
||||
// x轴
|
||||
option.xAxis(xAxis);
|
||||
//循环数据
|
||||
Bar bar = new Bar();
|
||||
bar.setType(SeriesType.bar);
|
||||
bar.barMaxWidth(30);
|
||||
bar.data(30, 48, 66);
|
||||
option.series(bar);
|
||||
// y轴
|
||||
ValueAxis yAxis = new ValueAxis();
|
||||
yAxis.name("(次)").type(AxisType.value);
|
||||
option.yAxis(yAxis);
|
||||
String optionStr = option.toString().replace(" ", "");
|
||||
return new JSONObject(optionStr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user