BusinessWaterDistributeChart.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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', '#A6A6FF', '#FFB580', '#FFDF80', '#79F2E8'],
  19. tooltip: {
  20. trigger: 'item'
  21. },
  22. legend: {
  23. bottom: '5%',
  24. left: '10%',
  25. right: '10%',
  26. icon: 'circle'
  27. },
  28. series: [
  29. {
  30. name: '用水量',
  31. type: 'pie',
  32. radius: ['40%', '70%'],
  33. center: ['50%','40%'],
  34. data: [
  35. { value: 1048, name: '自来水' },
  36. { value: 735, name: '中水' },
  37. ],
  38. emphasis: {
  39. itemStyle: {
  40. shadowBlur: 10,
  41. shadowOffsetX: 0,
  42. shadowColor: 'rgba(0, 0, 0, 0.5)'
  43. }
  44. }
  45. }
  46. ]
  47. };
  48. chart.setOption(option)
  49. }
  50. }
  51. }
  52. </script>
  53. <template>
  54. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  55. </template>
  56. <style lang="less" scoped>
  57. </style>