0

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

4

1 回答 1

0

只要您有参考,您就可以处置和恢复系列。

// 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)
)
于 2020-01-22T13:54:39.597 回答