SortNumChart.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="app-container-Sortnum">
  3. <div id="SortnumChart" :style="{height:height,width:width}"></div>
  4. </div>
  5. </template>
  6. <script>
  7. require('echarts/theme/macarons')
  8. const animationDuration = 6000
  9. export default {
  10. name: "SortNumChart",
  11. props: {
  12. width: {
  13. type: String,
  14. default: '100%'
  15. },
  16. height: {
  17. type: String,
  18. default: '330px'
  19. },
  20. year: {
  21. type: Number,
  22. }
  23. },
  24. mounted() {
  25. this.$nextTick(() => {
  26. /*this.queryParams.year = this.searchFormField.year;*/
  27. this.getList()
  28. })
  29. },
  30. methods: {
  31. getList() {
  32. this.initChart()
  33. },
  34. initChart() {
  35. // 基于准备好的dom,初始化echarts实例
  36. this.chart = this.echarts.init(document.getElementById('SortnumChart'))
  37. this.chart.setOption({
  38. /* 周围边距 */
  39. grid: {
  40. left: '3%',
  41. right: '3%',
  42. bottom: '1%',
  43. top: '1%',
  44. containLabel: true
  45. },
  46. tooltip: {
  47. trigger: 'item'
  48. },
  49. visualMap: {
  50. show: false,
  51. min: 80,
  52. max: 600,
  53. inRange: {
  54. colorLightness: [0, 1]
  55. }
  56. },
  57. series: [
  58. {
  59. type: 'pie',
  60. radius: '80%',
  61. center: ['50%', '50%'],
  62. data: [
  63. {value: 335, name: this.$t('会议中的EHS开项')},
  64. {value: 310, name: this.$t('5S管理')},
  65. {value: 274, name: this.$t('风险查勘')},
  66. {value: 235, name: this.$t('现场EHS检查')},
  67. {value: 400, name: this.$t('政府检查')}
  68. ].sort(function (a, b) { return a.value - b.value; }),
  69. roseType: 'radius',
  70. label: {
  71. color: '#ffffff'
  72. },
  73. labelLine: {
  74. lineStyle: {
  75. color: 'rgba(255, 255, 255, 0.3)'
  76. },
  77. smooth: 0.2,
  78. length: 10,
  79. length2: 20
  80. },
  81. itemStyle: {
  82. color: '#30B08F',
  83. shadowBlur: 200,
  84. shadowColor: 'rgba(0, 0, 0, 0.5)'
  85. },
  86. animationType: 'scale',
  87. animationEasing: 'elasticOut',
  88. animationDelay: function (idx) {
  89. return Math.random() * 200;
  90. }
  91. }
  92. ]
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style scoped>
  99. </style>