Display toggle in Chart: XY widget Workshop

I have line chart with multiple layers in Workshop’s Chart:XY widget. I would like to add buttons that will allow the end users to toggle on/off some of the lines and have more control over what they would like to compare.

I have tried to use the button group widget, but don’t quite understand how to connect it with the chart widget. How can I add a button to toggle layers in Chart:XY?

Thanks in advance!

Question originally asked by MarsBars on Stack Overflow: palantir foundry - Display toggle in Chart: XY widget Workshop - Stack Overflow

If you add a legend to a chart (which you can do in the chart config panel), it gives you the ability to toggle the visibility of different series. Would that work for your use case?

Here’s a screenshot of what I’m talking about

Answer originally provided by Ontologize on Stack Overflow: palantir foundry - Display toggle in Chart: XY widget Workshop - Stack Overflow