123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- var echarts=[{name: '遵义市',value: 1},{name: '铜仁市',value: 1}, {name: '毕节市', value: 1},{name: '贵阳市',value: 1},
- {name: '六盘水市',value: 1},{name: '安顺市',value: 1},{name: '黔东南苗族侗族自治州',value: 1},
- {name: '黔西南布衣族苗族自治州',value: 1}, {name: '黔南布依族苗族自治州', value: 1} ];
- var mapChart ;
- var urls ="/nwyj/ws/jscbb/ReportJSCService/mapdata";
- $(function(){
- $(window).resize(function(){
- mapChart.resize();
- });
- });
- $.ajax({
- url : urls,
- type : 'post',
- timeout : 15000,
- async: false,
- data: window.top.getDeptId,
- dataType : 'text',
- success : function(data) {
- mapdata=eval('('+data+')');
- for(var i=0;i<mapdata.length;i++){
- if(mapdata[i][1]>0 && mapdata[i][2] !=0){ // 发生停电 ,未全部复电 ,停电
- var str1=mapdata[i][0].substr(0,2);
- for(var a=0;a<echarts.length;a++){
- if(echarts[a].name.indexOf(str1)>=0){
- echarts[a].value=2;
- };
- }
- }
- if(mapdata[i][1]>0 && mapdata[i][2] ==0){ // 发生停电,全部复电 , 复电
- var str=mapdata[i][0].substr(0,2);
- for(var b=0;b<echarts.length;b++){
- if(echarts[b].name.indexOf(str)>=0){
- echarts[b].value=0;
- };
- }
-
- }
-
- }
-
- },
- error : function(e) {
- $.messager.alert('查询数据失败!', '访问服务失败!', 'error');
- }
- });
- // Step:3 conifg ECharts's path, link to echarts.js from current page.
- // Step:3 为模块加载器配置echarts的路径,从当前页面链接到echarts.js,定义所需图表路径
- require.config({
- paths: {
- echarts: '/nwyj/page/cockpit/tableandmap/js'
- }
- });
- // Step:4 require echarts and use it in the callback.
- // Step:4 动态加载echarts然后在回调函数中开始使用,注意保持按需加载结构定义图表路径
- require(
- [
- 'echarts',
- 'echarts/chart/bar',
- 'echarts/chart/line',
- 'echarts/chart/map',
- 'echarts/chart/funnel'
- ],
-
- function (ec) {
- //DIVID
- mapChart = ec.init(document.getElementById('main'));
- option = {
-
- title : {
- text: '全省地市停复电分布图',
- x:'center',
- textStyle:{color:'#e6f3ff'}
- },
- tooltip : {
- trigger: 'item',
- formatter: '{b}'
- },
- //图例
- legend: {
- show:false,
- orient: 'vertical',
- x:'right',//横轴
- y:'bottom',//纵轴
- data:['红:停电','绿:复电','灰:正常'],
- },
- dataRange: {
- min: 0,
- max: 2,
- color:['red','#6b6882','green'],
- text:['高','低'], // 文本,默认为数值文本
- calculable : false,
- show:false
- },
- series : [
- {
- name: ['停电','复电','未发生停电'],
- type: 'map',
- mapType: '贵州',//设置默认进入省份
- roam: false,
- selectedMode : 'single',
- itemStyle:{
- TEXTSTYLE: {
- COLOR: "red"
- },
- normal:{label:{show:true}},
- emphasis:{label:{show:true}}
- },
- data: echarts
- }
- ]
- };
- mapChart.setOption(option);
- }
- );
|