Open stars-oceans opened 11 months ago
<template>
<div>
<div ref="chart" class="box">
</div>
<button @click="aa">11</button>
</div>
</template>
<script>
import * as echarts from 'echarts';
export default {
props: ['data'],
components: {
},
data() {
return {
data: ['']
}
},
mounted() {
this.myChart = echarts.init(this.$refs.chart);
//图表的配置项和数据
let option = {
xAxis: {
type: 'category',
data: this.data || ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [120, 200, 150, 80, 70, 110, 130],
type: 'bar'
}
]
};
//配置项和数据显示
this.myChart.setOption(option, true);
},
methods: {
//初始化
aa() {
// 需要修改的值
this.myChart.setOption({
backgroundColor: '#ccc',
series: [{ radius: ['30%', '150%'], }],
xAxis: {
data: ['1', '2', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
series: [
{
data: [1, 2, 3],
}
]
});
},
},
}
</script>
<style scoped>
.box {
width: 500px;
height: 500px;
background-color: pink;
}
</style>