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 = \[\]

}

复制代码
}
相关推荐
费曼学习法8 分钟前
把 Agent 可观测性做进 Harness:从日志里只有 task finished 到全链路回放
前端
GuWenyue12 分钟前
z-index 写到 9999 还是被盖住:把层叠上下文的 6 个反例全复现了一遍
前端·css·浏览器
htzyl20616 分钟前
TypeScript:tsconfig配置误区及详情介绍,让你清清楚楚
前端·typescript
不服老的小黑哥22 分钟前
0b · M2:服务化 + SSE 流式
前端
梦曦i23 分钟前
0.9.0 新增页面级 style 支持
前端·uni-app x
不服老的小黑哥25 分钟前
10a · M1:命令行 Agent
前端
疯华整猫25 分钟前
类型全对、tsc 零错误,上线却白屏:AI 时代学 TypeScript,学的是它替不了的那一层
前端·typescript
Hilaku29 分钟前
2027制药业4大ERP选型参考:主流厂商对比与优缺点分析
前端·javascript·程序员
不可能片场32 分钟前
工程实践 管道截断让证据写不出来
前端·electron
Swot38 分钟前
mermaid 子图跨边:direction 失效与并行连接
前端