plotly / plotly/react-plotly.js

[Question] How to tell which point is clicked on when using onClick Event with multiple traces?

未关闭
#165 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
1.1k
派生
138
平均合并
3 天 2 小时
30 天内合并 PR
4

描述

I have setup a react application where I am using createPlotComponent to create an instance of an graph that I can interact with and I am controlling it using react-chart-editor


constructor() {
    this.PlotComponent =  createPlotComponent(plotly)
}
<this.PlotComponent
         ...data ,frames etc
         onClick={(e) => {
         console.log(e)
  }}/>

The problem I am having is that when I have multiple traces on my graph, I want to determine which trace I am clicking. At the moment the event from onClick exposes the points (an array of all of the points clicked) and a MouseEvent which shows information about the point on the graph that is clicked. Is there any way to get specifically the information about the one point that is clicked on?

There might be a way to determine which point is clicked by using the mouse event and matching up the position of the mouse click on the graph with the position of the point on the graph. However, there doesn't seem to access the position of the points on the graph in terms of their coordinates

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 issue 中展示的 createPlotComponent 用法和 onClick 回调开始,然后检查多个 trace 生成的 event.points 数组和 MouseEvent。确定现有事件数据是否能识别选中的 trace 和 point;完成标准是记录或公开一种可靠区分被点击 point 的方法。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, react
领域
data-visualization, frontend
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。