initEchartsFive() { let that = this; var myChart = this.$echarts.init(document.getElementById("map")); // axios.get("map.json").then((res) => { this.$echarts.registerMap("china", mapdata); myChart.setOption({ title: { text: "分布", left: "center", }, tooltip: { trigger: "item", formatter: function (params) { return `${params.name}: ${params.value || 0}`; }, }, visualMap: { show: false, min: 800, max: 50000, text: ["High", "Low"], realtime: false, calculable: true, inRange: { color: ["lightskyblue", "yellow", "orangered"], }, }, series: [ { type: "map", map: "china", zoom: 1.2, // 这是要显示的数据 data: [ { name: "重庆市", value: 20057.34 }, { name: "新疆维吾尔自治区", value: 15477.48 }, { name: "宁夏回族自治区", value: 31686.1 }, { name: "西藏自治区", value: 6992.6 }, { name: "内蒙古自治区", value: 44045.49 }, { name: "河南省", value: 4045.49 }, ], // 自定义命名映射,不设置的话,label默认是使用 geoJson中的name名 nameMap: { 北京市: "北京重命名", 天津市: "天津重命名", }, }, ], }); var elementResize = ElementResize({ strategy: "scroll", // 推荐监听滚动,提升性能 callOnAdd: true, // 添加侦听器时是否应调用,默认true }); elementResize.listenTo( document.getElementById("map"), _.debounce(function (element) { // 当元素尺寸发生改变是会触发此事件,刷新图表 that.$nextTick(function () { myChart.resize(); }); }) ); // }); }, 链接: https://pan.baidu.com/s/1BQe1ICk6A9ckthj9lCSp1g 提取码: 0298
标签:map,name,地图,myChart,value,params,中国,echarts From: https://www.cnblogs.com/whlBooK/p/16944383.html