zoukankan      html  css  js  c++  java
  • 【echart】showLoading hideLoading 无数据时显示正在加载

    1.要实现的功能当echart无数据时显示数据加载中!有数据显示echarts图形

     2.实现步骤(showLoading可根据要求设置样式)

    myChart.showLoading({
        text: '数据加载中...',
        color: '#c23531',
        textColor: '#ffffc2',
        maskColor: 'rgba(255, 255, 255, 0)',
        zlevel: 0
    });

     3.全部代码

    <template>
        <div >
            <div  id="top" style=" 100%;height: 100%" ></div>
        </div>
    </template>
    
    <script>
        import {getFlow} from '@/api/dashboard';
        export default {
            name: "TopRightChart",
            data(){
                return{
                    dataFlow:{},
                }
            },
            mounted(){
                this.drawLine()
            },
            methods:{
                drawLine() {
                    // 基于准备好的dom,初始化echarts实例
                    var myChart = this.$echarts.init(document.getElementById('top'))
                    myChart.showLoading({
                        text: '数据加载中...',
                        color: '#c23531',
                        textColor: '#ffffc2',
                        maskColor: 'rgba(255, 255, 255, 0)',
                        zlevel: 0
                    });
                    getFlow('60').then(res=>{
                        this.dataFlow=res.data.data
                        myChart.hideLoading();
                        myChart.setOption({
                            xAxis: {
                                data:  this.dataFlow.xdata
                            },
                            series: [{
                                // 根据名字对应到相应的系列
                                data:  this.dataFlow.deny
                            }]
                        });
                    })
                    var option={
                            xAxis: [      //部分样式省略
                                {
                                    data:[],   
                                }
                            ],
                            series: [
                                {
                                    data: []  //部分样式省略
                                }
    
                            ]
                        }
                    myChart .setOption(option);
                    window.addEventListener("resize", function () {
                        myChart.resize();
                    });
                }
            }
        }
    </script>
    <style scoped>
    </style>
    

      

  • 相关阅读:
    VMware 克隆一个虚拟机(win7)
    HDU 5695 Gym Class (拓扑排序、贪心、优先队列)
    HDU2647 Reward (拓扑排序、反向建图)
    HDU 3342 Legal or Not (拓扑排序、有向图是否存在环)
    Vue框架简介及简单使用
    Linux文件常用指令
    Linux系统相关命令
    Linux关机指令详解
    linux目录结构
    Linux用户相关命令
  • 原文地址:https://www.cnblogs.com/whblogs/p/13083721.html
Copyright © 2011-2022 走看看