# Updating Dash Datatable based on Scatter\_Mapbox Selection

**URL:** <https://community.plotly.com/t/updating-dash-datatable-based-on-scatter-mapbox-selection/53915>\
**Category:** Dash Python\
**Created:** [June 15, 2021, 4:30pm UTC](https://community.plotly.com/t/updating-dash-datatable-based-on-scatter-mapbox-selection/53915 "2021-06-15T16:30:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![plotlynoob](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@plotlynoob](https://community.plotly.com/u/plotlynoob)\
**Post date:** [June 15, 2021, 4:30pm UTC](https://community.plotly.com/t/updating-dash-datatable-based-on-scatter-mapbox-selection/53915/1 "2021-06-15T16:30:34Z")

</div>

Hi,

I am new to dash so my apologies for the basic questions.

I have a map generated via px.scatter\_mapbox. I have a dash data table that uses the same dataframe that fed the map.

I would like people to select a dot (or group select dots) on the map, and then have the data table filter based on that selection.

I have been having a hard time finding a working example, so I am unsure where to begin. I have enabled ‘’‘clickmode = “event+select”’’’ in the map, but I am unsure how to do the callbacks. Can someone point me in the right direction?

Thanks

---

<div class="post-metadata">

**Author:** ![atharvakatre](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/atharvakatre/32/14713_2.png) [@atharvakatre](https://community.plotly.com/u/atharvakatre)\
**Post date:** [June 15, 2021, 4:57pm UTC](https://community.plotly.com/t/updating-dash-datatable-based-on-scatter-mapbox-selection/53915/2 "2021-06-15T16:57:37Z")

</div>

Hi @plotlynoob

There are few options available to filter out based on the graph data points.  
Check this out [Part 4. Interactive Graphing and Crossfiltering | Dash for Python Documentation | Plotly](https://dash.plotly.com/interactive-graphing).  
Once you have the data from the graph you can then use the [conditional formatting](https://dash.plotly.com/datatable/conditional-formatting) of the dash datatable to highlight the rows.

---

<div class="post-metadata">

**Author:** ![plotlynoob](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@plotlynoob](https://community.plotly.com/u/plotlynoob)\
**Post date:** [June 15, 2021, 6:54pm UTC](https://community.plotly.com/t/updating-dash-datatable-based-on-scatter-mapbox-selection/53915/3 "2021-06-15T18:54:03Z")

</div>

@ [atharvakatre](https://community.plotly.com/u/atharvakatre)

Thank you for the links. I will have a look.

My main goal is to use elements from a graph/map to filter a datatable that is being fed a different dataset. So for example, if a datatable is 200 records long, and the person hits point “x” on the map, then only point “x” records in the 200 records datatable will appear.

I will create a reproducible example if I have any problems.

Thanks!

---

<div class="post-metadata">

**Author:** ![plotlynoob](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@plotlynoob](https://community.plotly.com/u/plotlynoob)\
**Post date:** [June 16, 2021, 11:40am UTC](https://community.plotly.com/t/updating-dash-datatable-based-on-scatter-mapbox-selection/53915/4 "2021-06-16T11:40:25Z")

</div>

So I am able to retrieve specific data elements, and filter the datatable based on that click, so that is good!

But when I use selection, it only grabs the first specific element it encounters, instead of all within the selection.

I am using this code to access elements instead of json.dumps():

`selectedData["points"][0]["customdata"][0]`

Do you have any thoughts?
