英文:
How to return x y coordinates of the selection box in Plotly JavaScript?
问题
我想要检索使用Plotly JavaScript创建的图表中由“Box Select”生成的坐标,但在文档中查看时似乎没有layout.selections.path的属性,如何检索选择框的x.min、x.max、y.min和y.max坐标?
谢谢!
英文:
I would like to retrieve the coordinates generated by Box Select from a chart made with Plotly JavaScript, but looking in the documentation it seems there is no attribute for the layout.selections.path, how can I retrieve the x.min, x.max, y.min and y.max coordinates of a selection box?
Thanks!
答案1
得分: 1
我最终找到了一个解决方案,使用了事件 plotly_selected 的回调函数:
graphDiv.on("plotly_selected", function (d) {
console.log(d.range);
});
完整的代码在 Codepen 上。
英文:
I finally came to a solution, using a callback function of the event plotly_selected:
graphDiv.on("plotly_selected", function (d) {
console.log(d.range);
});
The full code on Codepen
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论