1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
| <template> <div class="hello"> 涟漪特效动画 <div id="myChart" ref="myChart" style="width: 700px;height:500px;"></div> </div> </template>
<script> var echarts = require("echarts"); import {planePath} from "./map/dataPlanePath"
export default { name: 'effectScatter', data () { return { msg: '涟漪特效动画 effectScatter', geoCoordMapChina: { '新疆': [87.36, 43.45], '北京': [116.413554, 39.911013], '杭州': [120.161693, 30.280059], '广东': [113.14, 23.08], }, planePath: planePath } }, mounted() { this.drawMap(); }, methods: { /** * 地图 */ drawMap() { let planePath = this.planePath; // fei_tip: 见下面 // 接口给的数据格式---可以考虑用这种格式 // let resData = [ // todo: 接口数据 // {"name": "杭州", "value": 60}, // {"name": "广东", "value": 59}, // {"name": "新疆", "value": 15} // ]; let _data = [ [{"name": "北京", "value": 60}, {name: '杭州'}], [{"name": "广东", "value": 59}, {name: '杭州'}], [{"name": "新疆", "value": 15}, {name: '杭州'}], ];
let option = { tooltip: { trigger: 'item', formatter: function (params) { if (params.seriesType === "effectScatter") { return "线路:" + params.data.name + "" + params.data.value[2]; } else if (params.seriesType === "lines") { return params.data.fromName + ">" + params.data.toName + "<br />" + params.data.value; } else { return params.name; } } }, geo: { show: true, map: 'china', roam: false, }, series: [ { // 地图 type: 'map', map: 'china', roam: false, //是否开启鼠标缩放和平移漫游 label: { show: true, //显示省份标签 color: "#90ee90", }, itemStyle: { // 地图整体背景颜色 areaColor: "#c0c0c0" } }, { // fei_tip:线路 name: '杭州Top3', type: 'lines', zlevel: 2, symbol: ['none', 'arrow'], symbolSize: 10, effect: { show: true, period: 6, trailLength: 0, symbol: planePath, symbolSize: 15 }, lineStyle: { color: '#2d9df1', //航线的颜色 width: 1, opacity: 0.6, curveness: 0.2 // 弯曲程度 }, data: this.convertData(_data) }, { type: 'effectScatter', // fei_tip: 点名字 coordinateSystem: 'geo', // fei_tip: 使用地理坐标系 zlevel: 2, rippleEffect: { //涟漪特效 period: 4, //动画时间,值越小速度越快 brushType: 'stroke', //波纹绘制方式 stroke, fill scale: 4 //波纹圆环最大限制,值越大波纹越大 }, label: { show: true, position: 'right', //显示位置 offset: [5, -10], //偏移设置 formatter: function (params) {// 圆环显示文字 return params.data.name; }, fontSize: 13, color: '#ff6b81', }, symbol: 'circle', symbolSize: function (val) { return 6; //圆环大小 }, itemStyle: { show: true, color: '#90a5dc' // 圆环颜色 }, data: [ // todo:fei_tip {name: '北京', value: [116.413554, 39.911013, 60]}, {name: '广东', value: [113.14, 23.08, 59]}, {name: '新疆', value: [87.36, 43.45, 15]}, ] }, { // 目的地样式 name: '杭州', type: 'effectScatter', coordinateSystem: 'geo', zlevel: 2, rippleEffect: { brushType: 'stroke' }, label: { show: true, position: 'right', formatter: '{b}', color: '#ff6b81' }, symbolSize: function (val) { return 8 }, itemStyle: { color: '#fe4272', }, data: [ {name: '杭州', value: [120.161693, 30.280059, null]}, ] } ], }; let myChart = echarts.init(document.getElementById("myChart")); myChart.setOption(option,true) }, convertData(data) { let res = []; for (var i = 0; i < data.length; i++) { let dataItem = data[i]; let fromCoord = this.geoCoordMapChina[dataItem[0].name]; let toCoord = [119.5313, 29.8773]; // todo:fei_tip:??? if (fromCoord && toCoord) { res.push({ fromName: dataItem[0].name, toName: dataItem[1].name, coords: [fromCoord, toCoord], value: dataItem[1].value }); } } return res; } } } </script>
<style scoped>
</style>
|