c7083bace39d5757e736dac0335d8fdde6ec9954.svn-base 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. var echarts=[{name: '遵义市',value: 1},{name: '铜仁市',value: 1}, {name: '毕节市', value: 1},{name: '贵阳市',value: 1},
  2. {name: '六盘水市',value: 1},{name: '安顺市',value: 1},{name: '黔东南苗族侗族自治州',value: 1},
  3. {name: '黔西南布衣族苗族自治州',value: 1}, {name: '黔南布依族苗族自治州', value: 1} ];
  4. var mapChart ;
  5. var urls ="/nwyj/ws/jscbb/ReportJSCService/mapdata";
  6. $(function(){
  7. $(window).resize(function(){
  8. mapChart.resize();
  9. });
  10. });
  11. $.ajax({
  12. url : urls,
  13. type : 'post',
  14. timeout : 15000,
  15. async: false,
  16. data: window.top.getDeptId,
  17. dataType : 'text',
  18. success : function(data) {
  19. mapdata=eval('('+data+')');
  20. for(var i=0;i<mapdata.length;i++){
  21. if(mapdata[i][1]>0 && mapdata[i][2] !=0){ // 发生停电 ,未全部复电 ,停电
  22. var str1=mapdata[i][0].substr(0,2);
  23. for(var a=0;a<echarts.length;a++){
  24. if(echarts[a].name.indexOf(str1)>=0){
  25. echarts[a].value=2;
  26. };
  27. }
  28. }
  29. if(mapdata[i][1]>0 && mapdata[i][2] ==0){ // 发生停电,全部复电 , 复电
  30. var str=mapdata[i][0].substr(0,2);
  31. for(var b=0;b<echarts.length;b++){
  32. if(echarts[b].name.indexOf(str)>=0){
  33. echarts[b].value=0;
  34. };
  35. }
  36. }
  37. }
  38. },
  39. error : function(e) {
  40. $.messager.alert('查询数据失败!', '访问服务失败!', 'error');
  41. }
  42. });
  43. // Step:3 conifg ECharts's path, link to echarts.js from current page.
  44. // Step:3 为模块加载器配置echarts的路径,从当前页面链接到echarts.js,定义所需图表路径
  45. require.config({
  46. paths: {
  47. echarts: '/nwyj/page/cockpit/tableandmap/js'
  48. }
  49. });
  50. // Step:4 require echarts and use it in the callback.
  51. // Step:4 动态加载echarts然后在回调函数中开始使用,注意保持按需加载结构定义图表路径
  52. require(
  53. [
  54. 'echarts',
  55. 'echarts/chart/bar',
  56. 'echarts/chart/line',
  57. 'echarts/chart/map',
  58. 'echarts/chart/funnel'
  59. ],
  60. function (ec) {
  61. //DIVID
  62. mapChart = ec.init(document.getElementById('main'));
  63. option = {
  64. title : {
  65. text: '全省地市停复电分布图',
  66. x:'center',
  67. textStyle:{color:'#e6f3ff'}
  68. },
  69. tooltip : {
  70. trigger: 'item',
  71. formatter: '{b}'
  72. },
  73. //图例
  74. legend: {
  75. show:false,
  76. orient: 'vertical',
  77. x:'right',//横轴
  78. y:'bottom',//纵轴
  79. data:['红:停电','绿:复电','灰:正常'],
  80. },
  81. dataRange: {
  82. min: 0,
  83. max: 2,
  84. color:['red','#6b6882','green'],
  85. text:['高','低'], // 文本,默认为数值文本
  86. calculable : false,
  87. show:false
  88. },
  89. series : [
  90. {
  91. name: ['停电','复电','未发生停电'],
  92. type: 'map',
  93. mapType: '贵州',//设置默认进入省份
  94. roam: false,
  95. selectedMode : 'single',
  96. itemStyle:{
  97. TEXTSTYLE: {
  98. COLOR: "red"
  99. },
  100. normal:{label:{show:true}},
  101. emphasis:{label:{show:true}}
  102. },
  103. data: echarts
  104. }
  105. ]
  106. };
  107. mapChart.setOption(option);
  108. }
  109. );