我正在使用 LightningChartJS 创建带有条形的图表。我有正值和负值的数据。是否有任何可用的属性,我可以根据我想看到的内容隐藏负条或正条?
注意:我显然可以编写一些基本逻辑来实现此功能,但我正在寻找一些内置功能。
const rectangles = chart.addRectangleSeries()
const addValues = (entries) => {
for (const entry of entries) {
bars.push(add(entry))
}
}
const add = (entry) => {
// Create rect dimentions.
const rectDimensions = {
x: x - figureThickness,
y: 0,
width: figureThickness,
height: entry.value
}
// Add rect to the series.
x += figureThickness + figureGap
// Return data-structure with both original 'entry' and the rectangle figure that represents it.
return {
entry,
rect
}
}
chart.addValues([
{ category: '', value: 20 },
{ category: '', value: 40 },
{ category: '', value: -23 },
{ category: '', value: -29 },
{ category: '', value: 15 }
])