chart-hydrant.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <!-- **************************************NO.13 消火栓*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <div id="hydrant" style="width: 100%; height:23vh;">
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import * as echarts from 'echarts';
  10. export default {
  11. name: 'hydrant',
  12. data() {
  13. return {
  14. count: 0
  15. }
  16. },
  17. mounted() {
  18. this.myEcharts()
  19. },
  20. methods: {
  21. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=Ve9zCnhVwZvXTdD0
  22. myEcharts() {
  23. var chartDom = document.getElementById('hydrant');
  24. var myChart = echarts.init(chartDom);
  25. var color = ['#0E7CE2', '#FF8352', '#E271DE', '#F8456B', '#00FFFF', '#4AEAB0'];
  26. var option;
  27. var trafficWay = [
  28. {
  29. name: '双辽市',
  30. value: 20,
  31. },
  32. {
  33. name: '梨树县',
  34. value: 20,
  35. },
  36. {
  37. name: '伊通县',
  38. value: 20,
  39. },
  40. {
  41. name: '铁东区',
  42. value: 25,
  43. },
  44. {
  45. name: '铁西区',
  46. value: 20,
  47. },
  48. ];
  49. var data = [];
  50. var color = ['#F6C558', '#25EFBD', '#21bad6', '#3283F5', '#E44660'];
  51. for (var i = 0; i < trafficWay.length; i++) {
  52. data.push(
  53. {
  54. value: trafficWay[i].value,
  55. name: trafficWay[i].name,
  56. itemStyle: {
  57. normal: {
  58. borderWidth: 8,
  59. shadowBlur: 0,
  60. borderColor: color[i],
  61. shadowColor: color[i],
  62. },
  63. },
  64. },
  65. {
  66. value: 3,
  67. name: '',
  68. labelLine:{
  69. show:false
  70. },
  71. itemStyle: {
  72. normal: {
  73. label: {
  74. show: false,
  75. },
  76. labelLine: {
  77. show: false,
  78. },
  79. color: 'rgba(0, 0, 0, 0)',
  80. borderColor: 'rgba(0, 0, 0, 0)',
  81. borderWidth: 0,
  82. },
  83. },
  84. }
  85. );
  86. }
  87. var seriesOption = [
  88. {
  89. name: '',
  90. type: 'pie',
  91. clockWise:true,
  92. radius: [70, 70],
  93. hoverAnimation: true,
  94. itemStyle: {
  95. normal: {
  96. label: {
  97. show: true
  98. },
  99. },
  100. },
  101. data: data,
  102. labelLine: {
  103. normal: {
  104. length: 20,
  105. length2: 20,
  106. lineStyle: {
  107. type: 'solid',
  108. color: '#31FFFF',
  109. },
  110. },
  111. },
  112. label: {
  113. normal: {
  114. formatter: function (params) {
  115. var result = '';
  116. if (params.name) {
  117. result += params.name+'{blue|' + params.value + '}';
  118. }
  119. return result;
  120. },
  121. borderWidth: 0,
  122. borderRadius: 4,
  123. padding: [60, 0],
  124. height: 10,
  125. fontSize: 10,
  126. align: 'center',
  127. color: '#DEDEDE',
  128. rich: {
  129. blue: {
  130. fontSize: 10,
  131. lineHeight: 5,
  132. color: '#31FFFF',
  133. padding: [0, 5],
  134. },
  135. },
  136. },
  137. },
  138. },
  139. {
  140. type: 'pie',
  141. radius: [60, 60],
  142. hoverAnimation: false,
  143. clockWise: false,
  144. itemStyle: {
  145. normal: {
  146. borderColor: 'rgba(2,178,247,0.2)',
  147. borderWidth: 10,
  148. },
  149. },
  150. label: {
  151. show: false,
  152. },
  153. data: [200],
  154. },
  155. {
  156. type: 'pie',
  157. radius: [0, '20%'],
  158. zlevel: 3,
  159. silent: true,
  160. label: {
  161. normal: {
  162. show: false,
  163. },
  164. },
  165. labelLine: {
  166. normal: {
  167. show: false,
  168. },
  169. },
  170. data: [
  171. {
  172. value: 6,
  173. name: '总数',
  174. itemStyle: {
  175. normal: {
  176. color: {
  177. x: 0,
  178. y: 0,
  179. x2: 1,
  180. y2: 0,
  181. type: 'linear',
  182. global: false,
  183. colorStops: [
  184. {
  185. offset: 0,
  186. color: 'rgba(2,178,247,0.2)',
  187. },
  188. {
  189. offset: 1,
  190. color: 'rgba(2,178,247,0.2)',
  191. },
  192. ],
  193. },
  194. },
  195. },
  196. },
  197. ],
  198. },
  199. ];
  200. option = {
  201. color: color,
  202. tooltip: {
  203. show: false,
  204. },
  205. toolbox: {
  206. show: false,
  207. },
  208. series: seriesOption,
  209. };
  210. option && myChart.setOption(option);
  211. },
  212. },
  213. }
  214. </script>
  215. <style rel="stylesheet/scss" lang="scss" scoped>
  216. .chart-container {
  217. width: 100%;
  218. height: auto;
  219. position: relative;
  220. padding-bottom: 10px;
  221. display: flex;
  222. }
  223. </style>