dash-core-components
dash-core-components copied to clipboard
No right/left click data from dcc.Graph
I am creating a 3d Network graph which uses two 3d scatter traces (one for the nodes, the other for the links). When I click on a node, it opens another graph. But I only want to open the new graph when the person does a left click.
I saw that plotly.js has a plotly_click data on figure, which says which button was clicked. go.Figure on python does not have plotly_click, so there is no straightforward way (at least as I can see) to get which button was clicked on a dcc.Graph.
You should be able to use the clickData prop from your dcc.Graph component.
clickData, as far as I could see, didn't tell me which button was clicked.
This is the output of clickData from clicking a random node on my graph: {'points': [{'x': -3.8299059635394284, 'y': 4.025534512740025, 'z': 7.094807144904843, 'curveNumber': 1, 'pointNumber': 619, 'text': 'Finding scientific topics', 'marker.size': 7, 'marker.color': 4}]}
First I thought curveNumber could maybe be the button id, but then I tested it out and it came out as 1 on all attempts.
Ah OK - so we need to add more info to clickData - moving this over to the dcc repo. Thanks!
I looked up the code. Graph React Fragments
On line 77 it gets the information from the EventData, if the EventData has the "which button was clicked" info, then it just needs to be added a line like
has('clickedButton', fullPoint) &&
I'm not good enough with messing around big projects, so I don't know my way around on running the code to do it myself, but since I am really in need of this feature here I am trying to accelerate the process by giving an insight I had (which may or may not be good).
Would also love to see a single click anywhere feature