v-charts no data All In One
v-charts no data All In One
echarts dispose
async getData () {
this.chartLoading = true;
this.dataEmpty = false;
const params = this.getParams();
const res = await apiService[this.pieApi](params).finally(() => {
this.chartLoading = false;
});
const {data, key, value} = res.data.data;
// this.$refs.chart.echarts.resize();
this.chartData = Object.assign({}, {
columns: [key, value],
rows: this.formatRows(data),
});
if (!data.length) {
this.chartData.columns = [];
this.chartData.rows = [];
// this.$refs.chart.echarts.dispose();
console.log('this.$refs.chart', this.$refs.chart);
console.log('this.$refs.chart.echarts', this.$refs.chart.echarts);
this.$refs.chart.init();
this.$refs.chart.clean();
// const id = this.$refs.chart.echarts.id;
// const div = document.querySelector(`[_echarts_instance_="${id}"]`);
// div.style.display = 'none';
// this.$refs.chart.echarts.setOption({series: []}, true);
// this.$refs.chart.echarts.resize();
// this.chartExtend.series = [];
// this.chartSettings.series = [];
// this.chartSettings.setOptionOpts = true;
// this.chartSettings['set-option-opts'] = true;
this.dataEmpty = true;
return;
}
// document.getElementById('e1').removeAttribute('_echarts_instance_');
// this.$nextTick(_ => {
// this.$refs.chart.echarts.resize();
// });
},
v-charts 重绘
echarts setOption
set-option-opts
https://sunra.top/2020/03/13/v-charts/
bug
destroy
clear series
// this.chartData.columns = [];
// this.chartData.rows = [];
// this.chartExtend.series = [];
// this.chartSettings.series = [];
this.$refs.chart.echarts.setOption({series: []}, true);
solution
CSS show / hidden ✅
async getData () {
this.chartLoading = true;
this.dataEmpty = false;
const params = this.getParams();
const res = await apiService[this.pieApi](params).finally(() => {
this.chartLoading = false;
});
const {data, key, value} = res.data.data;
this.chartData = Object.assign({}, {
columns: [key, value],
rows: this.formatRows(data),
});
const id = this.$refs.chart.echarts.id;
const div = document.querySelector(`[_echarts_instance_="${id}"]`);
div.style.display = 'block';
if (!data.length) {
// this.chartData.columns = [];
// this.chartData.rows = [];
div.style.display = 'none';
this.dataEmpty = true;
return;
}
},
refs
https://v-charts.xgqfrms.xyz/#/props-demo2
https://www.runoob.com/echarts/echarts-ajax-data.html
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/15800259.html
未经授权禁止转载,违者必究!