Plotly.js How to Hide .text

Viewed 37

Scenario: I have a checkbox DataLabels, that the user clicks on the show the data points without having to hover over them. I've resolved some issues, but ran into some I'm unsure how to solve.

The problem I am having currently, is the user clicks on the checkbox to turn the chart.text.visibility = hidden/visible. However, when I do this it seems to also hide the chart.y values as well. Which causes all the values in the chart to be hidden/visible.

In these screenshots I was making the strings empty "", but the same applies to .visibility = hidden/visible. Just here you can clearly see the 2nd index is empty when I only affect .text.

enter image description here

enter image description here

In conclusion, how to I not reference the .y when hiding the .text? Or simply just turn the visibility off/on with the .text within plotly?

Thanks for your time,

User

0 Answers
Related