# \[Resolved\] Valid modes for plotly\_selected

**URL:** <https://community.plotly.com/t/resolved-valid-modes-for-plotly-selected/9270>\
**Category:** plotly.js\
**Created:** [March 28, 2018, 3:10pm UTC](https://community.plotly.com/t/resolved-valid-modes-for-plotly-selected/9270 "2018-03-28T15:10:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![greatchickenmaster](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@greatchickenmaster](https://community.plotly.com/u/greatchickenmaster)\
**Post date:** [March 28, 2018, 3:10pm UTC](https://community.plotly.com/t/resolved-valid-modes-for-plotly-selected/9270/1 "2018-03-28T15:10:25Z")

</div>

After some experimentation with the select event plotly\_selected, I’ve noticed that  
x: x\_values,  
y: y\_values,  
type: ‘scatter’,  
mode: ‘markers’

allows the user to select points on the plot. However,  
x: x\_values,  
y: y\_values,  
type: ‘scatter’,  
mode: ‘lines’

Does not return any values after the event. (If you remove `mode: 'lines'`, it looks like `type: 'scatter'` defaults to `mode: 'lines'` and so removing it doesn’t solve the issue.)

For my plot, I need to allow the user to select the points drawn up (as lines). This seems to be an issue, so my questions:

1. For which modes are plotly\_selected currently supported
2. If plotly\_selected currently supports `mode: 'lines'`, what can I do to get my code to work?

I apologize if this has already been asked somewhere. I’ve been unable to locate it if it has.

Thank you in advance

---

<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:** [March 28, 2018, 4:05pm UTC](https://community.plotly.com/t/resolved-valid-modes-for-plotly-selected/9270/2 "2018-03-28T16:05:57Z")

</div>

That’s correct. Selection aren’t supported on lines yet. See [https://github.com/plotly/plotly.js/issues/170#issuecomment-317063282](https://github.com/plotly/plotly.js/issues/170#issuecomment-317063282) for more info.

---

<div class="post-metadata">

**Author:** ![greatchickenmaster](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@greatchickenmaster](https://community.plotly.com/u/greatchickenmaster)\
**Post date:** [March 28, 2018, 4:18pm UTC](https://community.plotly.com/t/resolved-valid-modes-for-plotly-selected/9270/3 "2018-03-28T16:18:09Z")

</div>

Thanks @etienne

Here’s a workaround for anybody else that encounters the same problem.

When defining your data, define `mode: 'lines+markers'` and set a marker size

For example,

```auto
{
   name: 1,
   x: x,
   y: x,
   type: 'scatter',
   mode: 'lines+markers',
   marker: {
      size: 0.01,
   }
}

```

Then the plotly\_selected will work. It’ll pick up the markers, but with the marker size so low the user won’t see the markers. I’m sure this increases overhead, but it does work.

---

<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:** [March 28, 2018, 5:18pm UTC](https://community.plotly.com/t/resolved-valid-modes-for-plotly-selected/9270/4 "2018-03-28T17:18:48Z")

</div>

```auto
{
   name: 1,
   x: x,
   y: x,
   type: 'scatter',
   mode: 'lines+markers',
   marker: {
      opacity: 0
   }
}

```

should perform even better.
