Skip to content

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

@shinji2048

Description

@shinji2048

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions