123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <script>
- export default {
- data() {
- return {}
- },
- props: {
- height: Number,
- },
- mounted() {
- this.$nextTick(()=>{
- this.initChart()
- })
- },
- methods: {
- initChart() {
- let chart = this.$echarts.init(this.$refs.myChart)
- let option = {
- color: ['#80D4FF', '#FFDF80'],
- tooltip: {
- trigger: 'item'
- },
- legend: {
- bottom: '8%',
- icon: 'circle'
- },
- series: [
- {
- name: '用水量',
- type: 'pie',
- radius: '50%',
- data: [
- { value: 53, name: '自来水' },
- { value: 235, name: '中水' },
- ],
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- };
- chart.setOption(option)
- }
- }
- }
- </script>
- <template>
- <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
- </template>
- <style lang="less" scoped>
- </style>
|