<template lang="html">
<div class="chart chart-trend">
<div ref="chartTrend"></div>
</div>
</template>
<script>
import * as chart from 'assets/js/echart-config';
export default {
props: {
sourceInfo: {
type: Object,
required: true,
default: () => {
return []
}
},
chartTitle: {
type: String,
required: false,
default: '分数趋势'
}
},
data() {
return {
}
},
computed: {
chartDom() {
return echarts.init(this.$refs.chartTrend);
},
optionDom() {
const option = chart.trendOption(this.sourceInfo, this.chartTitle);
return option;
}
},
watch: {
sourceInfo: {
handler(cates) {
this.hideLoading();
if ( cates && cates.trend_active ) {
this.doRender();
} else {
this.chartDom.setOption(chart.emptyOption(this.chartTitle), true);
}
},
deep: true
}
},
methods: {
doRender() {
this.chartDom.setOption(this.optionDom, true);
},
resize() {
this.chartDom.resize();
},
showLoading() {
this.chartDom.showLoading({
text: '',
color: '#3988ff',
textColor: '#000',
maskColor: 'rgba(255, 255, 255, 0)',
zlevel: 0
});
},
hideLoading() {
this.chartDom.hideLoading();
}
},
mounted() {
this.chartDom.resize(400, 400);
this.showLoading();
window.addEventListener('resize', this.resize);
},
destroyed() {
window.removeEventListener('resize', this.resize);
}
}
</script>
<style lang="scss">
</style>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。