I am new to plotly, but am so far very pleased and pleasantly surprised by its functionality!
I do have a question about plotly_click and how to link it to a graph via class.
There will be multiple graphs on one page, and each graph will need to have one of a few different functionalities.
Originally the page creates a graph using plotly and allows the user to select a point on this graph. Lets call it graph1.
(I dont think the details for the first graph are important, but if they are please let me know and I will explain)
Then using
graph1.on('plotly_click', function(data)){
selected_point = data.points[0].x;
make_new_graph(selected_point, ckass = 'graph_type1')
}
a new graph is made in a new div with make_new_graph with the class given
make_new_graph creates a graph automatically in a new div as such
<div id="div1_box" class="drop_box graph_type1 js-plotly-plot">
graph_info...
</div>
graph_type1
is an example of a graph with one of the functionalities mentioned above.
The id on the graph ticks up each time so next time the user click it would make the same with id="div2_box"
I was hoping to use something like;
$(document).on('plotly_click', '.graph_type1', function(data){
selected_ms2 = data.points[0].x;
console.log(selected_ms2);
etc.
});
This would then apply to every graph that has the class tag graph_type1
The console.log is purely to check if it is working.
I have tried quite a few things, and this seems to get me the closest as it registers the click, but can not get the data.
The error reads, Uncaught TypeError: Cannot read property ‘0’ of undefined.
I know what it means, but I have no idea how to resolve it
Thank you for your time!
`