Black Lives Matter. Please consider donating to Black Girls Code today.

Using clicktoshow for annotations

I’m trying to use the clicktoshow attribute of annotations on my ‘lines+markers’ mode line chart, but I can’t get it to work. I’ve made annotations for each datapoint, which all show up when using default visibility and ‘clicktoshow: onoff’, but if I add ‘visible: false’ I can’t make them appear.
Can someone show me a simple example of a plot with functional ‘clicktoshow: onoff’, please, so I can see how it’s meant to work? I’m a newbie for JS as well as plotly (etc!) so I will really appreciate any help.

Here’s one

Thanks heaps @etienne for your quick response; sorry I’ve just got to it now - can you believe I got so engaged in the problem that I forgot I was going on holidays last week! I’ll have a close look now and try to work out why my graph’s clicktoshow wouldn’t work. If it looks like I was doing everything right and there might be a bug I’ll report back…
Thanks again :slightly_smiling_face:

Ok, I’ve had a look and also joined codepen so I can share one with you!
I worked out my problem was with the date format I am using for the arguments on the x axis. I’m programming in Java, and the argument list was made from LocalDateTime objects using .toString(), resulting in datetimes that look like this: “2018-07-10T03:12:40”
Plotly graphs this without difficulty, but apparently converts it to this format (without the T): “2018-07-10 03:12:40”
So as I discovered when I wrote a function to do clicktoshow’s job, the x value returned in a plotly click event is of the latter format - which doesn’t match the given argument list, and I presume that’s why clicktoshow doesn’t work when you’ve entered datetimes including a T.
I got my function to work by reformatting the string provided by the click event to add the T; I got clicktoshow to work by using an datetimes without the T for the annotation x values as in this codepen:

PS: Just realised I kept using the word ‘argument’ in my previous comment in a weird way - I really meant the values to plot on x!