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

Advanse use of `hovertemplate`

Ok, so I have just started with PlotyJS and need help with something I am stuck with:

I am working with hovertemplate and need it to display the following formate:


Total Deaths: X_AXIS,
Total Cases: Y_AXIS,
Active Cases: PLOT_SIZE*4000,

Now the problem is clear, first, where do I define COUNTRY_NAME if I can’t define it in one of the parameters of the go.Scatter, second, how do I numerically work with the Active Cases in which I have to multiply the plot size with 4000(as I used it as my prefered value for showing all the plots)

one solution may be to use costomdata but I can’t get it to work for more than one use case(Active Cases), as if I use something like %{customdata[0]} where my list is something like:

customdata = [
[Active Cases ,data],
[Country, data]

Does anyone know a way around?

Dex Devlon

Hi @bin0x00,

Welcome to Plotly forum!
From your post I cannot deduce if you are a plotly.js or a user, because you selected category.

This tutorial on how to define a customdata array is for Python users:

Hope it helps understand customdata definition even if you are working with plotly.js.

Ok, I found the solution, thanks to @empet.

For people struggling with the same problem, here’s the solution:

You will have to merge the two data into a list rather than having two different lists e.g.

customdata = [
[Active Cases Data, Country Data],

Dex Devlon