xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(45)  评论(7编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-01-14 如何使用 VuePress 搭建一个 element-ui 风格的文档网站
2021-01-14 Semantic Pull Requests All In One
2021-01-14 markdown & git diff
2021-01-14 Stack Overflow Skill IQ Testing All In One
2021-01-14 Canvas & encryption image src
2021-01-14 React Gatsby 最新教程 All In One
2021-01-14 VuePress 最新教程 All In One
点击右上角即可分享
微信分享提示