I'm trying to change the data to update the plot. I can do this manually by changing the .data()
with data1
or data2
. But I would like to do this by using select input. I added the select input but I am unsure about how to bind it. I'm also not sure if I am on the right track. Please see this
CodePudding user response:
You can use a reactive statement to do this:
$: selected === 'data1' ? setData (data1) : setData (data2)
EDIT: Adding Functioning REPL: https://svelte.dev/repl/02c579e1d3c54fe584f4ced130ddbf06?version=3.49.0