创建echarts的基本模板

创建echarts的基本模板

<template>
  <div class="com-container">
      <div class="com-chart" ref="trend_ref"></div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            chartInstance:null,
            allData:null
        }
    },
    mounted(){
        this.initChart();
        this.getData();
        this.screenAdapter();
        window.addEventListener('resize',this.screenAdapter);
    },
    destroyed(){
        window.removeEventListener('resize',this.screenAdapter);
    },
    methods:{
        initChart(){
            const initOption ={};
            this.chartInstance = window.echarts.init(this.$refs.trend_ref);
            this.chartInstance.setOption(initOption);
        },
        async getData(){
            //得到数据
            this.updateChart();
        },
        updateChart(){
            const dataOption ={};
            this.chartInstance.setOption(dataOption);

        },
        screenAdapter(){
            const adapterOption ={};
            this.chartInstance.setOption(adapterOption);
            this.chartInstance.resize();
        }

    }

}
</script>

<style>

</style>
上一篇:H5端引入echart 视图更新的大坑


下一篇:Android IJKPlayer缓冲区设置以及播放一段时间出错解决方案