8.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div id="myChartold8" style="width: 100%; height: 100%; "></div>
  3. </template>
  4. <script>
  5. import { oldPersonOldIncome } from '../../api'
  6. export default {
  7. //老年人收入来源统计
  8. name: "OldPersonSourcesOfIncomeCount",
  9. data() {
  10. return {
  11. dataArr: [],
  12. myChart: null
  13. }
  14. },
  15. methods: {
  16. async draw() {
  17. const result = await oldPersonOldIncome({}, 'POST');
  18. this.dataArr = result;
  19. this.myChart = this.$echarts.init(document.getElementById('myChartold8'));
  20. this.myChart.setOption({
  21. grid:{
  22. left:"16%",
  23. right:"5%",
  24. },
  25. xAxis: {
  26. type: 'category',
  27. boundaryGap: true,
  28. data: this.dataArr.map((item) => {
  29. return item.label;
  30. }),
  31. splitLine: {
  32. show: true,
  33. lineStyle:{
  34. color: ['#315070'],
  35. width: 1,
  36. type: 'solid'
  37. }
  38. },
  39. axisLine: {
  40. show: true,
  41. lineStyle: {
  42. color: '#344db0'
  43. }
  44. },
  45. axisLabel: {
  46. show: true,
  47. textStyle: {
  48. color: 'white',
  49. formatter: '{value}',
  50. },
  51. fontSize: 12
  52. },
  53. axisTick: {
  54. show: false
  55. }
  56. },
  57. yAxis: {
  58. type: 'value',
  59. axisLine: {
  60. show: true,
  61. lineStyle: {
  62. color: '#5c6ab6'
  63. }
  64. },
  65. splitLine: {
  66. show: true,
  67. lineStyle:{
  68. color: ['#315070'],
  69. width: 1,
  70. type: 'solid'
  71. }
  72. },
  73. axisLabel: {
  74. show: true,
  75. textStyle: {
  76. color: 'white',
  77. formatter: '{value}',
  78. }
  79. },
  80. axisTick: {
  81. show: false
  82. },
  83. },
  84. series: [
  85. {
  86. type: 'line',
  87. smooth: true,
  88. areaStyle: {
  89. color: {
  90. type: 'linear',
  91. x: 0,
  92. y: 0,
  93. x2: 0,
  94. y2: 1,
  95. colorStops: [{
  96. offset: 0, color: '#A79A84' // 0% 处的颜色
  97. }, {
  98. offset: 1, color: 'rgba(255,255,255,0.2)' // 100% 处的颜色
  99. }],
  100. global: false // 缺省为 false
  101. }
  102. },
  103. symbol: `image://${require('../../assets/oldStatistics/y.png')}`,
  104. symbolSize: [10, 10],
  105. data: this.dataArr.map((item) => {
  106. return item.value;
  107. }),
  108. label: {
  109. show: true,
  110. formatter: '{c}',
  111. color: '#fff',
  112. fontSize: 16
  113. },
  114. itemStyle: {
  115. color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  116. offset: 0,
  117. color: '#FF6C13'
  118. }, {
  119. offset: 1,
  120. color: '#ffea22'
  121. }]),
  122. },
  123. lineStyle: {
  124. width: 2
  125. }
  126. }
  127. ]
  128. });
  129. }
  130. },
  131. watch: {
  132. data() {
  133. this.myChart.destroy();
  134. this.draw();
  135. }
  136. },
  137. mounted() {
  138. this.draw();
  139. }
  140. }
  141. </script>
  142. <style scoped>
  143. </style>