key-service-population.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. (function() {
  2. //<label class="btn btn-default" :class="{active: activeIndex == 1}" @click="btnClick(1)">
  3. // <input type="radio">季
  4. // </label>
  5. Vue.component('key-service-population', {
  6. template: '<div style="height: 100%;">\
  7. <h4 class="c-b5e1fc c-f16 c-t-center div-common-title">重点服务人群增加趋势</h4>\
  8. <div v-show="!hasData" class="no-result-panel">\
  9. <div class="no-result-img">\
  10. <img src="../images/noData.png">\
  11. </div>\
  12. <div class="no-result-text">暂无数据!</div>\
  13. </div>\
  14. <div v-show="hasData" data-toggle="buttons" class="btn-group fr mr40 mt0" style="position: absolute;right: 0.208rem;top: 0.05rem;z-index: 99999;">\
  15. <label class="btn btn-default" :class="{active: activeIndex == 0}" @click="btnClick(0)">\
  16. <input type="radio">月\
  17. </label>\
  18. <label class="btn btn-default" :class="{active: activeIndex == 2}" @click="btnClick(2)">\
  19. <input type="radio">年\
  20. </label>\
  21. </div>\
  22. <div id="div-zhongidan-echart" class="ml30" v-show="hasData"></div>\
  23. </div>',
  24. props: ["data"],
  25. data: function() {
  26. return {
  27. keyServiceData:null,
  28. activeIndex:0,
  29. fontSize: 0.007 * window.screen.width,
  30. hasData:true,
  31. monthData:null,
  32. yearData:null
  33. }
  34. },
  35. mounted: function() {
  36. },
  37. watch:{
  38. data:function(newData){
  39. this.data = newData;
  40. if(this.data && JSON.parse(this.data[0].obj.viewInfos[0].options[0].option).series[0].data){
  41. this.monthData = this.data[0].successFlg?this.data[0].obj.viewInfos&&JSON.parse(this.data[0].obj.viewInfos[0].options[0].option):{};
  42. this.yearData = this.data[1].successFlg?this.data[1].obj.viewInfos&&JSON.parse(this.data[1].obj.viewInfos[0].options[0].option):{};
  43. this.initData();
  44. this.hasData = true;
  45. }else{
  46. this.hasData = false;
  47. }
  48. }
  49. },
  50. methods: {
  51. initData:function(){//重点人群
  52. this.activeIndex = 0;
  53. this.changeData();
  54. this.chartMainFun();
  55. },
  56. changeData:function(){
  57. if(this.activeIndex==0){//月
  58. this.keyServiceData = this.monthData;
  59. }else if(this.activeIndex==2){//年
  60. this.keyServiceData = this.yearData;
  61. }
  62. },
  63. btnClick:function(type){
  64. this.activeIndex = type;
  65. this.changeData();
  66. this.chartMainFun();
  67. },
  68. chartMainFun:function(){
  69. var vm = this;
  70. var xAxisData = this.keyServiceData.xAxis[0].data;
  71. var pjcrsData = this.keyServiceData.series[0].data;
  72. var huanbiData = this.keyServiceData.series[1].data;
  73. var zhongdianChart = echarts.init(document.getElementById('div-zhongidan-echart'));
  74. var zhongdianOption = {
  75. tooltip: {
  76. trigger: 'axis',
  77. axisPointer: {
  78. type : 'shadow'
  79. },
  80. formatter: '{b} <br /> {a0}: {c0}<br />{a1}: {c1}' + "%"
  81. },
  82. grid: {top: 50, bottom: 30, left: 30,right:80},
  83. legend: {
  84. data:['新增人数','环比'],
  85. textStyle: {
  86. color: '#b5e1fc'
  87. }
  88. },
  89. xAxis: [
  90. {
  91. type: 'category',
  92. data: xAxisData,
  93. axisPointer: {
  94. type: 'shadow'
  95. },
  96. axisTick: {
  97. show: false
  98. },
  99. axisLine: {
  100. lineStyle: {
  101. color: '#095f8e'
  102. }
  103. },
  104. axisLabel: {
  105. color: '#b5e1fc',
  106. fontSize:vm.fontSize
  107. }
  108. }
  109. ],
  110. yAxis: [
  111. {
  112. type: 'value',
  113. name: '新增人数',
  114. nameTextStyle: {
  115. color: '#b5e1fc' // 坐标轴名称颜色
  116. },
  117. splitLine: {
  118. show: false
  119. },
  120. axisLine: {
  121. lineStyle: {
  122. color: '#095f8e'
  123. }
  124. },
  125. axisLabel: {
  126. color: '#b5e1fc',
  127. fontSize:vm.fontSize
  128. }
  129. },
  130. {
  131. type: 'value',
  132. name: '环比',
  133. nameTextStyle: {
  134. color: '#b5e1fc' // 坐标轴名称颜色
  135. },
  136. splitLine: {
  137. show: false // 不显示坐标轴刻度
  138. },
  139. axisLine: {
  140. lineStyle: {
  141. color: '#095f8e' // 坐标轴轴线颜色
  142. }
  143. },
  144. axisLabel: {
  145. color: '#b5e1fc' ,// 坐标轴刻度标签文本颜色
  146. fontSize:vm.fontSize
  147. },
  148. show: true
  149. }
  150. ],
  151. series: [
  152. {
  153. name:'新增人数',
  154. type:'bar',
  155. data:pjcrsData,
  156. barWidth: 20,
  157. label: {
  158. normal: {
  159. show: true,
  160. position: 'top', // 在柱状图上方显示
  161. color: '#fff',// 柱状图上方显示的数值颜色
  162. }
  163. },
  164. itemStyle: {
  165. barBorderRadius: [8,8,0,0],
  166. color: '#00e6f3'
  167. }
  168. },
  169. {
  170. name:'环比',
  171. type:'line',
  172. yAxisIndex: 1,
  173. data:huanbiData,
  174. itemStyle: {
  175. color: '#03fa6d'
  176. },
  177. }
  178. ]
  179. };
  180. if(zhongdianChart){
  181. zhongdianChart.clear();
  182. }
  183. zhongdianChart.setOption(zhongdianOption);
  184. },
  185. }
  186. })
  187. })()