echarts 切换省

require.config({ paths: { echarts: ‘http://echarts.baidu.com/build/dist‘ } }); require( [ ‘echarts’, ‘echarts/chart/map’ ], function (ec) { var myChart = ec.init( document.getElementById(‘eMain’) ); option = { tooltip : { trigger: ‘item’, formatter: ‘{b}’ }, series : [ { name: ‘中国’, type: ‘map’, mapType: ‘china’, selectedMode : ‘multiple’, itemStyle:{ normal:{label:{show:true}}, emphasis:{label:{show:true}} }, data:[ {name:’湖北’,selected:true} ] } ] }; updateText(option.series[0].data[0].name); var ecConfig = require(‘echarts/config’); myChart.on(ecConfig.EVENT.MAP_SELECTED, function (param){ var selected = param.selected; var str = ‘’; var arr = []; for ( var p in selected ) { if( param.target == p ) { param.selected[p] = true; option.series[0].data[0].name = p + ‘’; }else{ param.selected[p] = undefined; } }; myChart.setOption(option); updateText(param.target); }); myChart.setOption(option); } ); function updateText(x){ document.getElementById(‘province’).innerHTML = x; document.getElementById(‘provinceText’).innerHTML = x + “ 内容区域”; }


echarts 切换省
http://example.com/2016-05-10 迁徙图、省市区图/
作者
csorz
发布于
2016年5月10日
许可协议