# Multiple Points firing on plotly click

**URL:** <https://community.plotly.com/t/multiple-points-firing-on-plotly-click/4746>\
**Category:** plotly.js\
**Created:** [July 3, 2017, 5:30am UTC](https://community.plotly.com/t/multiple-points-firing-on-plotly-click/4746 "2017-07-03T05:30:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@raj](https://community.plotly.com/u/raj)\
**Post date:** [July 3, 2017, 5:30am UTC](https://community.plotly.com/t/multiple-points-firing-on-plotly-click/4746/1 "2017-07-03T05:30:29Z")

</div>

Hello Everybody,

I have a plotly graph which has the code something like this:

```auto
var trace = { token:ser_num_list[i],
                                  x: x1[i],
                                  y: y1[i],
                                  name: parameter1+' '+ser_num_list[i],
                                  curveNumber:i,
                                  yaxis: 'y1',
                                  type: 'scatter',
                                  mode: 'lines',
                                  line:{dash: 'dot',width:1}
                                };
                                  graph_data.push(trace);
                              }
                              var layout = {
                                boxmode:"overlay",
                                //boxpoints:"outliers",
                                xaxis:{title:"Timestamp"},
                                yaxis: {title: parameter1},
                                showlegend:true,
                                mode:'lines',
                                side:'right',
                                legend:{y:450}
                                };
                                if(x2.length==0 && y2.length==0)
                                {
                                  console.log("firing at point1");
                                Plotly.newPlot('plot', graph_data, layout);

                                var plot=document.getElementById('plot');
                                plot.on('plotly_click', function(graph_data){
                                var pts = '';
                                for(var i=0; i < graph_data.points.length; i++){
                                  var xquery=graph_data.points[i].x ;
                                  var yquery= graph_data.points[i].y;
                                 
                                  var name=graph_data.points[0];
                                  console.log(xquery);
                                  console.log(yquery);
                                  console.log(name);
                                }

```

The issue is that when I plot multiple graphs and invoke the plotly\_click it gives it me the point details of all the curves for that corresponding X axis instead of only the curve I am clicking on.

Can you please help me with this?

Thank You in Advance.

Rajarshi

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [July 3, 2017, 11:31pm UTC](https://community.plotly.com/t/multiple-points-firing-on-plotly-click/4746/2 "2017-07-03T23:31:47Z")

</div>

Setting `layout.hovermode` to `'closest'` should fix this.

---

<div class="post-metadata">

**Author:** ![raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@raj](https://community.plotly.com/u/raj)\
**Post date:** [July 4, 2017, 4:35am UTC](https://community.plotly.com/t/multiple-points-firing-on-plotly-click/4746/3 "2017-07-04T04:35:47Z")

</div>

Thank you very much etienne.

Help much appreciated 🙂
