可视化Echart模板component

<template>
<div class="com-container">
地区销售排行图表
<div class="com-chart" ref="rank_ref"></div>
</div>
</template>
<script>
export default {
data() {
return {
chartInstance: null,
allData: null
}
},
mounted() {
this.initChart();
this.getData();
window.addEventListener("resize", this.screenAdapter);
this.screenAdapter();
},
destroyed() {
window.removeEventListener("resize", this.screenAdapter);
},
methods: {
initChart() {
this.chartInstance = this.$echarts.init(this.$refs.rank_ref);
const initOption = {};
this.chartInstance.setOption(initOption);
},
async getData() {
// 获取服务器的数据,对this.allData进行赋值之后,调用updateChart方法更新图表
this.updateChart();
},
updateChart() {
// 处理图表需要的数据
const dataOption = {};
this.chartInstance.setOption(dataOption);
},
screenAdapter() {
const adapterOption = {};
this.chartInstance.setOption(adapterOption);
this.chartInstance.resize();
}
}
}
</script>
<style lang="less" scoped>
</style>
posted @   Felix_Openmind  阅读(93)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
*{cursor: url(https://files-cdn.cnblogs.com/files/morango/fish-cursor.ico),auto;}
点击右上角即可分享
微信分享提示