I am attempting to create an onclick event on my plotly chart. Following the documentation i have created the following chart:
var graphDiv = document.getElementById('uniqueId');
Plotly.newPlot('uniqueId', charData, layout);
graphDiv.on('plotly_click', function (data) {
var i = 0;
})
However when i run this i get the following error:
graphDiv.on is not a function
So can anyone tell me what im doing wrong?
Note i have also attempted with jquery:
$('#uniqueId').on('plotly_click', function(){})
This didnt throw an error but the function was not called when clicking the chart.
fiddle: