RoseCon.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">玫瑰图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chart" id="chart_right2"></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import screenfull from 'screenfull'
  15. export default {
  16. name: "RoseCon",
  17. data() {
  18. return {
  19. option: null,
  20. HKcur: '',
  21. TWcur: '',
  22. SHcur: '',
  23. GDcur: '',
  24. SCcur: '',
  25. FJcur: '',
  26. NMGcur: ''
  27. }
  28. },
  29. mounted() {
  30. this.getConData();
  31. setTimeout(this.getEchartRight2, 2000)
  32. },
  33. methods: {
  34. //获取疫情数据
  35. getConData() {
  36. axios.get('https://www.maomin.club/fy/get', {
  37. dataType: "json"
  38. }).then(res => {
  39. let ConData = res.data
  40. let made = JSON.parse(ConData)
  41. let madeData = made.component
  42. let data = madeData[0]
  43. this.HKcur = data.caseList[4].curConfirm
  44. this.TWcur = data.caseList[3].curConfirm
  45. this.SHcur = data.caseList[21].curConfirm
  46. this.GDcur = data.caseList[31].curConfirm
  47. this.SCcur = data.caseList[24].curConfirm
  48. this.FJcur = data.caseList[20].curConfirm
  49. this.NMGcur = data.caseList[9].curConfirm
  50. this.overseasInputRelative = data.summaryDataIn.overseasInputRelative
  51. }).catch(err => {
  52. console.log(err)
  53. })
  54. },
  55. //绘制图表
  56. getEchartRight2() {
  57. let myChart = echarts.init(document.getElementById('chart_right2'));
  58. let option = {
  59. color: ['#EAEA26', '#906BF9', '#FE5656', '#01E17E', '#3DD1F9', '#FFAD05', '#4465fc'],
  60. //工具箱配置全屏
  61. toolbox: {
  62. feature: {
  63. mytool: {
  64. show: true,
  65. title: "全屏",
  66. icon: 'path://M181 357.5V181.2h176.4c14.3 0 25.9-11.6 25.9-25.9v-31.1c0-14.3-11.6-25.9-25.9-25.9H118c-11 0-20 9-20 20v239.4c0 14.3 11.6 25.9 25.9 25.9H155c14.4-0.1 26-11.7 26-26.1zM668.6 181.2H845v176.4c0 14.3 11.6 25.9 25.9 25.9H902c14.3 0 25.9-11.6 25.9-25.9V118.2c0-11-9-20-20-20H668.6c-14.3 0-25.9 11.6-25.9 25.9v31.1c0 14.3 11.6 26 25.9 26zM357.4 845.2H181V668.8c0-14.3-11.6-25.9-25.9-25.9H124c-14.3 0-25.9 11.6-25.9 25.9v239.4c0 11 9 20 20 20h239.4c14.3 0 25.9-11.6 25.9-25.9v-31.1c-0.1-14.4-11.7-26-26-26zM845 668.8v176.4H668.6c-14.3 0-25.9 11.6-25.9 25.9v31.1c0 14.3 11.6 25.9 25.9 25.9H908c11 0 20-9 20-20V668.8c0-14.3-11.6-25.9-25.9-25.9H871c-14.4 0-26 11.6-26 25.9z',
  67. onclick: function () {
  68. const element = document.getElementById('chart_right2');
  69. if (!screenfull.isEnabled) {//判断是否支持全屏
  70. this.$message({
  71. message: '您的浏览器暂时不支持全屏切换',
  72. type: 'warning'
  73. })
  74. return false
  75. }
  76. screenfull.toggle(element)
  77. },
  78. }
  79. },
  80. },
  81. tooltip: {
  82. //触发类型
  83. //数据项图形触发,主要在散点图,饼图等无类目轴的图表中使用。
  84. trigger: 'item',
  85. //提示框浮层内容格式器,支持字符串模板和回调函数两种形式。
  86. formatter: '{b} : {c} ({d}%)'
  87. },
  88. polar: {},
  89. //极坐标系的角度轴。
  90. angleAxis: {
  91. //强制设置坐标轴分割间隔
  92. interval: 1,
  93. //坐标轴类型。
  94. type: 'category',
  95. data: [],
  96. //角度轴组件的所有图形的z值。控制图形的前后顺序。z值小的图形会被z值大的图形覆盖。
  97. z: 10,
  98. //坐标轴轴线相关设置。
  99. axisLine: {
  100. //是否显示坐标轴轴线。
  101. show: false,
  102. //
  103. lineStyle: {
  104. //坐标轴线线的颜色。
  105. color: '#0B4A6B',
  106. //坐标轴线线宽。
  107. width: 5,
  108. //坐标轴线线的类型。
  109. type: 'solid'
  110. },
  111. },
  112. axisLabel: {
  113. /*默认会采用标签不重叠的策略间隔显示标签。
  114. 可以设置成 0 强制显示所有标签。*/
  115. interval: 0,
  116. //是否显示刻度标签。
  117. show: true,
  118. color: '#0B4A6B',
  119. margin: 8,
  120. fontSize: 16
  121. },
  122. },
  123. //极坐标系的径向轴。
  124. radiusAxis: {
  125. //坐标轴刻度最小值。
  126. min: 40,
  127. //坐标轴刻度最大值。
  128. max: 120,
  129. //强制设置坐标轴分割间隔。
  130. interval: 20,
  131. axisLine: {
  132. show: false,
  133. lineStyle: {
  134. color: '#0B3E5E',
  135. width: 1,
  136. type: 'solid'
  137. },
  138. },
  139. axisLabel: {
  140. formatter: '{value} %',
  141. show: false,
  142. padding: [0, 0, 20, 0],
  143. color: '#0B3E5E',
  144. fontSize: 16
  145. },
  146. splitLine: {
  147. lineStyle: {
  148. //分隔线颜色
  149. color: '#0B3E5E',
  150. //分隔线线宽。
  151. width: 2,
  152. type: "solid"
  153. }
  154. }
  155. },
  156. calculable: true,
  157. series: [{
  158. type: 'pie',
  159. //饼图半径
  160. radius: ['6%', '10%'],
  161. //是否开启 hover 在扇区上的放大动画效果。
  162. hoverAnimation: false,
  163. //是否显示视觉引导线。
  164. labelLine: {
  165. normal: {
  166. show: false,
  167. length: 30,
  168. length2: 50
  169. },
  170. emphasis: {
  171. show: false
  172. }
  173. },
  174. tooltip: {
  175. show: false
  176. },
  177. data: [{
  178. name: '',
  179. value: 0,
  180. itemStyle: {
  181. normal: {
  182. color: '#0B4A6B'
  183. }
  184. }
  185. }]
  186. },
  187. //最外圈
  188. {
  189. type: 'pie',
  190. radius: ['90%', '95%'],
  191. hoverAnimation: false,
  192. labelLine: {
  193. normal: {
  194. show: false,
  195. length: 30,
  196. length2: 50
  197. },
  198. emphasis: {
  199. show: false
  200. }
  201. },
  202. tooltip: {
  203. show: false
  204. },
  205. data: [{
  206. name: '',
  207. value: 0,
  208. itemStyle: {
  209. normal: {
  210. color: '#0B4A6B'
  211. }
  212. }
  213. }]
  214. },{
  215. stack: 'a',
  216. type: 'pie',
  217. radius: ['20%', '80%'],
  218. roseType: 'area',
  219. zlevel: 10,
  220. label: {
  221. normal: {
  222. show: true,
  223. formatter: '{b}',
  224. textStyle: {
  225. fontSize: 12,
  226. },
  227. position: 'outside'
  228. },
  229. emphasis: {
  230. show: false
  231. }
  232. },
  233. labelLine: {
  234. normal: {
  235. show: true,
  236. length: 15,
  237. length2: 50,
  238. lineStyle: {
  239. type: 'dotted'
  240. }
  241. },
  242. emphasis: {
  243. show: true
  244. }
  245. },
  246. data: [{
  247. value: this.HKcur,
  248. name: '香港'
  249. }, {
  250. value: this.TWcur,
  251. name: '台湾'
  252. }, {
  253. value: this.SHcur,
  254. name: '上海'
  255. }, {
  256. value: this.GDcur,
  257. name: '广东'
  258. }, {
  259. value: this.SCcur,
  260. name: '四川'
  261. }, {
  262. value: this.FJcur,
  263. name: '福建'
  264. }, {
  265. value: this.NMGcur,
  266. name: '内蒙古'
  267. }]
  268. }]
  269. }
  270. myChart.setOption(option, true);
  271. //自适应
  272. window.addEventListener('resize', () => {
  273. myChart.resize();
  274. });
  275. },
  276. },
  277. beforeDestroy() {
  278. }
  279. };
  280. </script>
  281. <style lang="scss" scoped>
  282. .sn-container {
  283. width: 99%;
  284. height: 99%;
  285. //position: relative;
  286. .chart {
  287. height: 90%;
  288. width: 90%;
  289. margin-bottom: 1%;
  290. margin-left: 7%;
  291. }
  292. }
  293. </style>