console
<template>
<div>
<div id="abc"></div>
<el-button type="primary" @click="changeData">修改</el-button>
</div>
</template>
<script>
export default {
data() {
return {
salesData: [
{ label: 'Basic',value: 10, color: '#3366CC' },
{ label: 'Plus',value: 20, color: '#DC3912' },
{ label: 'Lite', value: 30,color: '#FF9900' },
{ label: 'Elite',value: 40, color: '#109618' },
{ label: 'Delux',value: 50, color: '#990099' }
]
};
},
mounted() {
pie('#abc',700,400,this.salesData,250, 200, 150, 100, 30);
},
methods: {
changeData() {
pie('#abc',700,400,this.randomData(),250, 200, 150, 100, 30);
},
randomData() {
return this.salesData.map(function(d) {
return { label: d.label, value: 1000 * Math.random(), color: d.color };
});
}
}
};
</script>
<style scoped lang="scss">
</style>