|
@@ -31,9 +31,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.chart = echarts.init(this.$refs.chart)
|
|
|
- // 初始化表格
|
|
|
- this.init()
|
|
|
+ if (this.$refs.chart) {
|
|
|
+ this.chart = echarts.init(this.$refs.chart)
|
|
|
+ // 初始化表格
|
|
|
+ this.init()
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
items: {
|
|
@@ -47,18 +49,20 @@ export default {
|
|
|
},
|
|
|
label: {
|
|
|
handler() {
|
|
|
- this.chart.setOption({
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.chart?.setOption({
|
|
|
xAxis: {
|
|
|
data: this.label
|
|
|
}
|
|
|
});
|
|
|
+ })
|
|
|
},
|
|
|
deep: true
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
init() {
|
|
|
- this.chart.setOption({
|
|
|
+ this.chart?.setOption({
|
|
|
tooltip: {
|
|
|
trigger: "axis",
|
|
|
formatter: "{b} : {c}",
|
|
@@ -152,7 +156,7 @@ export default {
|
|
|
// 重载数据
|
|
|
if (this.chart) {
|
|
|
const max = this.items.map(item => parseInt(item.value || 0)).sort((a,b) => b - a)
|
|
|
- this.chart.setOption({
|
|
|
+ this.chart?.setOption({
|
|
|
yAxis: {
|
|
|
min: 0,
|
|
|
max: function (value) {
|