import * as echarts from "echarts"; const commonStyle = { xAxis: { type: "category", axisTick: { show: false, }, axisLine: { lineStyle: { color: "rgba(185,185,185,0.3)", }, }, axisLabel: { show: true, color: "rgba(255,255,255,0.6)", margin: 5, }, data: ["正常", "较大", "异常"], }, yAxis: { type: "value", show: false, axisLine: { show: false, }, }, grid: { top: "0%", left: "-10%", right: "0%", bottom: "0%", containLabel: true, }, }; const styleName1 = { ...commonStyle, series: [ { data: [32, 40, 42], type: "bar", barWidth: 26, label: { show: true, color: "#fff", position: "insideTop", }, itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#BBA269", }, { offset: 1, color: "#3D3523", }, ]), borderRadius: [2, 2, 0, 0], }, }, ], }; const styleName2 = { ...commonStyle, series: [ { data: [32, 40, 42], type: "bar", barWidth: 26, stack: "total", label: { show: true, color: "#fff", position: "insideTop", }, itemStyle: { normal:{ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#BBA269", }, { offset: 1, color: "#3D3523", }, ]), }, emphasis: { color: '#B81500' // 高亮时的颜色 }, // borderRadius: [2, 2, 0, 0], }, }, { data: [130, 140, 80,0, 0], type: "bar", barWidth: 26, stack: "total", label: { show: true, color: "#fff", position: "insideTop", formatter: ({ value }) => { return value ? value : ""; }, }, itemStyle: { normal:{ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#bb7d4c", }, { offset: 1, color: "#90603a", }, ]), }, emphasis: { color: '#B81500' // 高亮时的颜色 }, borderRadius: [2, 2, 0, 0], }, }, { data: [0,0,80, 130, 130], type: "bar", barWidth: 26, stack: "total", itemStyle: { normal:{ color: "rgba(56,56,56,0.94)", }, emphasis: { color: '#B81500' // 高亮时的颜色 }, borderRadius: [2, 2, 0, 0], }, label: { show: true, position: "insideTop", color: "#fff", formatter: ({ value }) => { return value ? value : ""; }, }, }, ], }; export const barOption = { styleName1, styleName2 };