如何使用 Apex 图表更改特定值的条形颜色?
How to change bar color at a specific value with Apex Charts?
有没有办法改变 Apex 图表上低于特定值的条形颜色?例如,当重量超过 200 磅时,条形变为红色。
这是我正在使用的代码,但我不太确定我应该为 value、seriesIndex 和 w
添加什么
colors: ['#02DFDE'],
fill: {
colors: [function({ value, seriesIndex, w }) {
if(value < 360) {
return '#FF0000'
} else {
return '#02DFDE'
}
}]
},
如果你想根据值设置颜色,那么这个函数就足够了
colors: [
function({ value, seriesIndex, w }) {
if (value < 5000) {
return '#FF0000'
} else {
return '#02DFDE'
}
}
]
完整示例 - https://codepen.io/apexcharts/pen/RwRNXzX?editors=0010
有没有办法改变 Apex 图表上低于特定值的条形颜色?例如,当重量超过 200 磅时,条形变为红色。
这是我正在使用的代码,但我不太确定我应该为 value、seriesIndex 和 w
添加什么colors: ['#02DFDE'],
fill: {
colors: [function({ value, seriesIndex, w }) {
if(value < 360) {
return '#FF0000'
} else {
return '#02DFDE'
}
}]
},
如果你想根据值设置颜色,那么这个函数就足够了
colors: [
function({ value, seriesIndex, w }) {
if (value < 5000) {
return '#FF0000'
} else {
return '#02DFDE'
}
}
]
完整示例 - https://codepen.io/apexcharts/pen/RwRNXzX?editors=0010