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
| var dom = document.getElementById('chart'); var myChart = echarts.init(dom, null, { renderer: 'canvas', useDirtyRect: false }); var app = {}; var option;
var img = new Image(); img.src = 'Fuzhou.webp';
img.onload = function () { $.get( 'Fuzhou.svg', function (svg) { echarts.registerMap('sicily', { svg: svg }); option = { tooltip: {}, geo: [ { map: 'sicily', roam: true, layoutCenter: ['50%', '50%'], layoutSize: '150%', selectedMode: 'single', itemStyle: { color: undefined }, emphasis: { itemStyle: { color: 'rgba(0, 255, 255, 0.25)', }, label: { show: false } }, selectedMode: false,
regions: [ { name: "福州市", itemStyle: { areaColor: { type: 'image', image: img, repeat: 'no-repeat', }, borderColor: '#111', shadowBlur: 5, shadowColor: "#000", shadowOffsetY: 5, opacity: 1 }, emphasis: { itemStyle: { areaColor: { type: 'image', image: img, repeat: 'no-repeat', }, borderColor: '#111', shadowBlur: 5, shadowColor: "#000", shadowOffsetY: 5, opacity: 1 }, }, tooltip: { show: true, confine: true, formatter: function () { return []; } } }, { name: "鼓楼区", tooltip: { show: true, confine: true, formatter: function () { return [ '鼓楼区', '啊!三坊七巷真是太好玩了!' ].join('<br/>'); } } }, { name: "仓山区", tooltip: { show: true, confine: true, formatter: function () { return [ '仓山区', '我们的时代多美好~像朝霞漫天灿烂~' ].join('<br/>'); } } }, { name: "闽侯县", tooltip: { show: true, confine: true, formatter: function () { return [ '闽侯县', '知明行笃~立诚致广~全面求发展~' ].join('<br/>'); } } }, { name: "长乐区", tooltip: { show: true, confine: true, formatter: function () { return [ '长乐区', '闽江江水都流向~流向长乐的海~' ].join('<br/>'); } } }, ] } ], }; myChart.setOption(option); myChart.on('selectchanged', function (params) { if (!params.selected.length) { myChart.dispatchAction({ type: 'hideTip' }); myChart.dispatchAction({ type: 'geoSelect', geoIndex: 0 }); } else { var btnDataIdx = params.selected[0].dataIndex[0]; var name = option.series.data[btnDataIdx][2]; myChart.dispatchAction({ type: 'geoSelect', geoIndex: 0, name: name }); myChart.dispatchAction({ type: 'showTip', geoIndex: 0, name: name }); } }); } );
if (option && typeof option === 'object') { myChart.setOption(option); }
myChart.on('click', function (params) { console.log("选中项: ", params.event); });
window.addEventListener('resize', myChart.resize); };
|