Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

How to make a single trace invisible?

I have a line graph, and I wish to make one line invisible when a button is clicked. At the moment, I have a button that triggers the following JS function:

function toggleView() {
		Plotly.restyle('realtime_data_line',
		{
			visible: 'false'
		}, [0])
}

I’m not sure if I’m putting this in the right function (ie restyle()) or if I’m even using the right property, but some research suggests visible is the property I want to manipulate. The function, however, does nothing. I know it is being triggered, because I had a test console.log in it that went off every time I clicked the button. What am I doing wrong?

I have once again realized my mistake minutes after posting. The value is a straight boolean, not a string. Meaning no quotes around the “false”.

1 Like