PopulationStructure.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <div id="populationStructure">
  3. <div id="pop"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import echarts from 'echarts'
  8. export default {
  9. name: 'populationStructure',
  10. components: {
  11. },
  12. data() {
  13. return {
  14. }
  15. },
  16. mounted() {
  17. },
  18. methods: {
  19. init(){
  20. var myChart = echarts.init(document.getElementById('pop'));
  21. var xData = ["优良率", "达标率"];
  22. var yData = [50, 87.3];
  23. var shadowYData=[100,100];
  24. var color="#19dfdd";
  25. var shadowColor="#0b5767";
  26. var barWidth=50;
  27. var option = {
  28. backgroundColor: '#05233b',
  29. "grid": {
  30. "top": "25%",
  31. "left": "-5%",
  32. "bottom": "5%",
  33. "right": "5%",
  34. "containLabel": true
  35. },
  36. animation: false,
  37. "xAxis": [{
  38. "type": "category",
  39. "data": xData,
  40. "axisTick": {
  41. "alignWithLabel": true
  42. },
  43. "nameTextStyle": {
  44. "color": "#82b0ec"
  45. },
  46. "axisLine": {
  47. show: false,
  48. "lineStyle": {
  49. "color": "#82b0ec"
  50. }
  51. },
  52. "axisLabel": {
  53. "textStyle": {
  54. "color": color
  55. },
  56. margin: 30
  57. }
  58. }],
  59. "yAxis": [{
  60. show: false,
  61. "type": "value",
  62. "axisLabel": {
  63. "textStyle": {
  64. "color": "#fff"
  65. },
  66. },
  67. "splitLine": {
  68. "lineStyle": {
  69. "color": "#0c2c5a"
  70. }
  71. },
  72. "axisLine": {
  73. "show": false
  74. }
  75. }],
  76. "series": [
  77. {
  78. "name": "数据上椭圆",
  79. type: 'pictorialBar',
  80. symbolSize: [barWidth, 10],
  81. symbolOffset: [0, -6],
  82. symbolPosition: 'end',
  83. z: 12,
  84. "label": {
  85. "normal": {
  86. "show": true,
  87. "position": "top",
  88. fontSize: 14,
  89. color: color,
  90. formatter:function(params,index){
  91. return params.value+"%";
  92. }
  93. }
  94. },
  95. color: "#2DB1EF",
  96. data: yData
  97. },
  98. {
  99. name: '',
  100. type: 'pictorialBar',
  101. symbolSize: [barWidth, 10],
  102. symbolOffset: [0, 7],
  103. z: 12,
  104. "color": color,
  105. "data": yData
  106. },
  107. {
  108. name: '',
  109. type: 'pictorialBar',
  110. symbolSize: [barWidth+5, 15],
  111. symbolOffset: [0, 12],
  112. z: 10,
  113. itemStyle: {
  114. normal: {
  115. color: 'transparent',
  116. borderColor: color,
  117. borderType: 'solid',
  118. borderWidth: 1
  119. }
  120. },
  121. data: yData
  122. },
  123. {
  124. name: '',
  125. type: 'pictorialBar',
  126. symbolSize: [barWidth+10, 20],
  127. symbolOffset: [0, 18],
  128. z: 10,
  129. itemStyle: {
  130. normal: {
  131. color: 'transparent',
  132. borderColor: color,
  133. borderType: 'solid',
  134. borderWidth: 2
  135. }
  136. },
  137. data: yData
  138. },
  139. {
  140. type: 'bar',
  141. "barWidth": barWidth,
  142. barGap: '10%', // Make series be overlap
  143. barCateGoryGap: '10%',
  144. itemStyle: {
  145. normal: {
  146. color: new echarts.graphic.LinearGradient(0, 0, 0, 0.7, [{
  147. offset: 0,
  148. color: "rgba(25,223,221,.7)"
  149. },
  150. {
  151. offset: 1,
  152. color: "rgba(25,223,221,.3)"
  153. }
  154. ]),
  155. },
  156. },
  157. data: yData
  158. },
  159. {
  160. "name": "阴影椭圆",
  161. type: 'pictorialBar',
  162. symbolSize: [barWidth, 10],
  163. symbolOffset: [0, -6],
  164. symbolPosition: 'end',
  165. z: 12,
  166. "label": {
  167. "show": false,
  168. },
  169. color: shadowColor,
  170. data: shadowYData
  171. },
  172. {
  173. name:"阴影柱体",
  174. type: 'bar',
  175. "barWidth": barWidth,
  176. barCateGoryGap: '10%',
  177. "zlevel": -1,
  178. "barGap": "-100%",
  179. itemStyle: {
  180. color: shadowColor
  181. },
  182. data: shadowYData
  183. },
  184. ]
  185. };
  186. // 使用刚指定的配置项和数据显示图表。
  187. myChart.setOption(option);
  188. }
  189. }
  190. }
  191. </script>
  192. <style scoped>
  193. #populationStructure{
  194. position: absolute;
  195. width: 100%;
  196. height: 25%;
  197. z-index: 2;
  198. top:75%;
  199. /* background-color: rgb(0, 0, 255,0.4); */
  200. }
  201. </style>