如何从 LightningChart JS 中隐藏特定的点形状?
How to hide particular point shapes from LightningChart 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 的 setPictureOff
或 setPictureOn
方法修改复选框形状:
// Create a checkbox
const checkBox = chart.addUIElement( UIElementBuilders.CheckBox
// Modify the shape of the checkbox
.setPictureOff(UIButtonPictures.Rectangle)
.setPictureOn(UIButtonPictures.Rectangle)
)
我想在网格的点击事件中隐藏某些数据点。我怎样才能做到这一点? 我有圆形、三角形和方形的系列,想使用显示这些符号的单独网格隐藏系列。
系列只要有引用就可以销毁和恢复
// 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 的 setPictureOff
或 setPictureOn
方法修改复选框形状:
// Create a checkbox
const checkBox = chart.addUIElement( UIElementBuilders.CheckBox
// Modify the shape of the checkbox
.setPictureOff(UIButtonPictures.Rectangle)
.setPictureOn(UIButtonPictures.Rectangle)
)