I’m using Dash, and I made a heatmap (go.Heatmap). It works, it’s visible, it’s gorgeous.
Now I’m trying to add
customdata to it (to be used on a click event later, aka I’m accessing
clickdata later). I have two bar graphs were I put in
customdata and when I click on them, I get the
customdata field in my
clickdata. I have tried and failed to do the same with the heatmap. Here is a dummy example of what I’m writing:
trace_heatmap = go.Heatmap(
Everything works, except the customdata. In this example, I’ve set it equal to the same thing as what I’m using for the
text field, as both are lists and the
text one worked, so I thought it’d be a good thing to test with. But, as said above, when I click a point and access the
clickdata, there is no
customdata at all. Any guidance would be appreciated!
Thanks for reporting @raaid!
I have replicated the issue with this example:
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc
app = dash.Dash()
app.layout = html.Div([
[1, 2, 3],
[4, 5, 6]
['a', 'b', 'c'],
['d', 'e', 'f']
['c-a', 'c-b', 'c-c'],
['c-d', 'c-e', 'c-f'],
def display_hoverdata(hoverData, clickData):
if __name__ == '__main__':
Looks like a bug to me, I’ll have to look into this a little bit deeper.
Thanks for responding and looking into it! =)
Any updates in looking into this, @chriddyp ?
It looks like this is possible in plotly.js: https://codepen.io/chriddyp/pen/NagXpM?editors=1011, so this is probably a bug in the Graph component itself
Hi @chriddyp I am also experiencing this issue in Scatter traces using mode=‘lines’. The bug does indeed seem to be in the Graph component, although my JS knowledge is very limited, I am identifying the conditional below as the likely culprit:
if (has('curveNumber', fullPoint) &&
has('pointNumber', fullPoint) &&
pointData['customdata'] = data[
The bug seems to be that elements (such as lines) which do not have pointNumber attributes are then being cut off from having customdata.
Any chance this bug will be addressed in the near future?
Btw, first plotly comment of mine and just want to say thanks for the amazing work Chris!
Hm, odd. I thought that
mode: 'lines' would still have
pointNumber. Can you make a small, reproducable example?
Also, welcome to dash!
This still appears to be a problem today (dash==1.13.4, plotly==4.8.1).
go.Heatmap can appear in the figure’s
hovertemplate but not in
My current solution is to include the necessary data in the figure’s
text attribute and parse it out from
clickdata['points']['text'] but this is less than ideal.
Can you clarify what you mean by text attribute? I am also trying to navigate this issue. Thanks for the help!
I’ve also been looking at this issue with @bwander.
There are two aspects of current behaviour that was unexpected but we’re not sure if they’re bugs:
customdata is not returned on a
clickData event with a
text is a list, there is no complaint from plotly, however the list is not returned on a
clickData event – maybe this should throw an error?
Just wanted to revive this topic because this is a real headache to workaround, especially if you want to use both
customdata for different purposes.
Bump because i have the same issue. I have long labels that have to be shortened before using as the y data, so I add the full text to the customdata for the hovertemplate. In a callback I would like to get the full text.
I think I ran into the same issue as well, here a simple example to reproduce:
import plotly.graph_objects as go
labels = ["a", "b", "c"]
z = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
customdata = [["http://google.com", "http://google.com", "http://google.com"], ["http://google.com", "http://google.com", "http://google.com"], ["http://google.com", "http://google.com", "http://google.com"]]
fig = go.Figure(data=go.Heatmap(x=labels, y=labels,
How does the workaround work, how do you parse data from the text?
And another bump, because I too have the issue that if the customdata is an array on any datum, it is not returned in the clickData