如何从闪电图JS中隐藏特定的点形状?



我想在我的网格的点击事件中隐藏某些数据点。我怎样才能做到这一点? 我有圆形、三角形和方形的系列,并希望使用显示这些符号的单独网格隐藏系列。

只要您引用了系列,就可以释放和恢复系列。

// Use PointSeries with Triangle shaped points as example and cache it.
const triangleSeries = chart.addPointSeries( { pointShape: PointShape.Triangle } )
// Add a checkbox to the chart for this example
const button = chart.addUIElement( UIElementBuilders.CheckBox )
// Set up the checkbox
button.setText('Click to hide/show series')
.setPosition( {x: 95, y: 95 } )
// Define the behavior when the button is clicked (changing its state)
.onSwitch( (_, state) => {
// The checkbox is in 'on' state, so restore series.
if (state)
// Restore the series to the chart, so it'll show in the chart again.
triangleSeries.restore()
else
// Dispose the series from the chart, effectively 'hiding' it.
triangleSeries.dispose()
})

您可以使用 UIElementBuilder 的setPictureOffsetPictureOn方法修改复选框形状:

// Create a checkbox
const checkBox = chart.addUIElement( UIElementBuilders.CheckBox
// Modify the shape of the checkbox
.setPictureOff(UIButtonPictures.Rectangle)
.setPictureOn(UIButtonPictures.Rectangle)
)

相关内容

  • 没有找到相关文章

最新更新