waterDistributionChart.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <script>
  2. export default {
  3. data() {
  4. return {}
  5. },
  6. props: {
  7. height: Number,
  8. },
  9. mounted() {
  10. this.$nextTick(()=>{
  11. this.initChart()
  12. })
  13. },
  14. methods: {
  15. initChart() {
  16. let chart = this.$echarts.init(this.$refs.myChart)
  17. let option = {
  18. color: ['#80D4FF', '#FFDF80'],
  19. tooltip: {
  20. trigger: 'item'
  21. },
  22. legend: {
  23. bottom: '8%',
  24. icon: 'circle'
  25. },
  26. series: [
  27. {
  28. name: '用水量',
  29. type: 'pie',
  30. radius: '50%',
  31. data: [
  32. { value: 53, name: '自来水' },
  33. { value: 235, name: '中水' },
  34. ],
  35. emphasis: {
  36. itemStyle: {
  37. shadowBlur: 10,
  38. shadowOffsetX: 0,
  39. shadowColor: 'rgba(0, 0, 0, 0.5)'
  40. }
  41. }
  42. }
  43. ]
  44. };
  45. chart.setOption(option)
  46. }
  47. }
  48. }
  49. </script>
  50. <template>
  51. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  52. </template>
  53. <style lang="less" scoped>
  54. </style>