echart总结




定义option

const option = ref({});

const chart = ref()

option.value = {

tooltip: {

trigger: "axis",

axisPointer: {

type: "shadow",

},

},

legend: {

textStyle: {

color: "#fff",

fontSize: 16,

},

top:'4%',

},

grid: {

left: "3%",

right: "0%",

bottom: "3%",

containLabel: true,

},

xAxis: {

type: "category",

data: [],

axisLabel: {

color: "#fff",

interval: 0,

fontSize: 16,

},

},

yAxis: {

type: "value",

axisLabel: {

color: "#fff",

interval: 0,

fontSize: 16,

},

splitLine:{

lineStyle:{

color: 'rgba(106,110,126,0.5)'

}

}

},

series: [

],

};

接口返回数据时的处理方式

if (res.success) {

console.log('res.data.data',res.data.data.length)

if (res.data.data.length > 0) {

let newList = [];

newList = res.data.series;

option.value.xAxis.data = res.data.xAxis;

newList.forEach((item) => {

item.type = "bar",

item.barWidth = "30",

item.label = {

show: true,

position: "top",

fontSize: "16",

color: "#fff",

};

});

option.value.series = newList;

window.onresize = chart.value.resize();

}else {

option.value.xAxis.data = []

option.value.series = []

}

复制代码
}
相关推荐
IT_陈寒4 小时前
Redis缓存击穿把我坑惨了,原来这样解决才靠谱
前端·人工智能·后端
mfxcyh4 小时前
Vue3 右键菜单实现方案(基于 vue3-context-menu)
前端
treesforest4 小时前
从IP地址归属地查询到IP地理位置精准查询指南
服务器·前端·网络
棉猴4 小时前
python海龟绘图之画布与窗口
javascript·python·html·setup·turtle·海龟绘图·screensize
LF男男4 小时前
WindmillBullect.cs
前端
小白学大数据4 小时前
Python 爬虫爬取应用商店数据:请求构造与数据解析
前端·爬虫·python·数据分析
pkowner4 小时前
若依分页问题及解决方法
java·前端·算法
AI_paid_community5 小时前
25k Star 登顶 GitHub:这个专门吃 K 线图长大的 AI,让我意识到之前三年都在裸奔
javascript·claude
golang学习记5 小时前
Cursor官方团队的AI指南:Cursor Team Kit
前端·cursor
Lee川5 小时前
RAG 知识库问答:从概念到代码的完整实现
前端·人工智能·后端