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

}

复制代码
}
相关推荐
inksci3 分钟前
发布Ai生成的html markdown 推荐
前端·javascript·html
Lank_M8 分钟前
PDF签完名还能改什么?会签能过,压缩不行
前端
修炼的dance15 分钟前
压完的PDF验签不报错,是因为签名被删了
前端
ModStart18 分钟前
ProcHub v0.7.0 命令行工具上线,进程、配置与 WSL 都能在终端管理
前端
那年那棵树21 分钟前
基于WebGis的人生如旅地图系统
前端·arcgis·vue·课程设计
XZ-07000129 分钟前
week9-三元表达式
java·前端·python
叫我铁汁儿吧37 分钟前
Redux的原理
前端
云和数据.ChenGuang39 分钟前
name=“张三“ age=18 weight=100.3 print (name,age,weight)
java·服务器·前端
代码猎人39 分钟前
前端怎么优化兼容性
前端