luoyang-screen/src/page/LinePage/Left/BarChart/chart.config.ts
2024-08-27 13:26:25 +08:00

80 lines
1.6 KiB
TypeScript

import * as echarts from "echarts";
export default function getOptions(dataProps: number[], color: string[]) {
if (dataProps.length === 0) return null;
return {
grid: { top: 30, right: 12, bottom: 26, left: 48 },
legend: {
show: false,
},
xAxis: {
type: "category",
data: ["磨边后", "包装1", "包装2"],
axisLabel: {
color: "#fff",
fontSize: 14,
interval: 0,
},
axisTick: { show: false },
axisLine: {
lineStyle: {
width: 2,
color: "#5982B2",
},
},
},
yAxis: {
name: "单位/片",
nameTextStyle: {
color: "#fff",
fontSize: 14,
},
type: "value",
axisLabel: {
color: "#fff",
fontSize: 14,
formatter: "{value}",
},
axisLine: {
show: true,
lineStyle: {
width: 2,
color: "#5982B2",
},
},
splitLine: {
lineStyle: {
width: 2,
color: "#5982B2",
},
},
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
className: "luoyang-chart-tooltip",
show: false,
},
series: [
{
data: dataProps,
type: "bar",
barWidth: 10,
label: {
show: true,
fontSize: 12,
color: "#9CD4FF",
position: "top",
},
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: color[0] },
{ offset: 1, color: color[1] },
]),
},
},
],
};
}