BusinessWaterDistributeChart.vue 1.2 KB

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