Как скрыть определенные точечные фигуры от LightningChart JS? - PullRequest
0 голосов
/ 21 января 2020

Я хотел бы скрыть определенные точки данных при щелчке по моей сетке. Как мне этого добиться? У меня есть серии с кругом, треугольником и квадратной формой, и я хочу скрыть серии, используя отдельную сетку с этими символами.

1 Ответ

0 голосов
/ 22 января 2020

Вы можете располагать и восстанавливать серии, если у вас есть ссылки на них.

// 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()
})

Вы можете изменить формы флажков, используя setPictureOff или setPictureOn методы UIElementBuilder:

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