# Updating shared List with multiple callback inputs

**URL:** <https://community.plotly.com/t/updating-shared-list-with-multiple-callback-inputs/37875>\
**Category:** Dash Python\
**Created:** [April 16, 2020, 3:59am UTC](https://community.plotly.com/t/updating-shared-list-with-multiple-callback-inputs/37875 "2020-04-16T03:59:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayjunjuly0313](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mayjunjuly0313](https://community.plotly.com/u/mayjunjuly0313)\
**Post date:** [April 16, 2020, 3:59am UTC](https://community.plotly.com/t/updating-shared-list-with-multiple-callback-inputs/37875/1 "2020-04-16T03:59:25Z")

</div>

Hello, I’m trying to make website that when I click on the graph, it’s Id is appended to some list and change color of the figure. If I click again, it will change bgcolor again and remove ID from the list. And, eventually when I click a button, I want to show that selected graphs on other window.  
Right now I’m stuck with putting id’s of clicked graphs on the list.  
here’s my code

```auto
for i in range(40):
    app.callback(
        [Output('graph-{}'.format(i), 'figure'),
         Output('selected-graphs{}'.format(i), 'children')],
        [Input('graph-{}'.format(i), 'clickData')],
          [State('file-input', 'filename'),
           State('graphWrapper-{}'.format(i), 'id'),
           State('selected-graphs', 'children')]
        )(select_graphs)

```

I have total maximum 40 graphs with different IDs. So, I needed to make 40 callbacks for each graphs to know which one is clicked. Now, the problem is, I cannot have same output for multiple callbacks.

```auto
Output('selected-graphs', 'children')],

```

this part is problematic. ‘selected-graphs’ is ID of hidden div to store the data. But, I cannot use this as output of 40 callbacks. How can I add or delete each graphs’ IDs in the shared list when I click on the graph?

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [April 16, 2020, 2:54pm UTC](https://community.plotly.com/t/updating-shared-list-with-multiple-callback-inputs/37875/2 "2020-04-16T14:54:36Z")

</div>

It might be worth switching to use Dash pattern-matching callbacks,

[https://dash.plotly.com/pattern-matching-callbacks](https://dash.plotly.com/pattern-matching-callbacks)

It that does not solve the issue, I have written a small util class, which makes it possible to assign an output multiple times,

> **[dash-extensions](https://pypi.org/project/dash-extensions/)**
>
> Various extensions for the Plotly Dash framework

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [April 17, 2020, 5:32am UTC](https://community.plotly.com/t/updating-shared-list-with-multiple-callback-inputs/37875/3 "2020-04-17T05:32:34Z")

</div>

> [@mayjunjuly0313](#):
>
> I have total maximum 40 graphs with different IDs. So, I needed to make 40 callbacks for each graphs to know which one is clicked.

> [@Emil](#):
>
> It might be worth switching to use Dash pattern-matching callbacks,

Yes indeed, this is a perfect use case for Pattern Matching Callbacks ([Pattern-Matching Callbacks | Dash for Python Documentation | Plotly](https://dash.plotly.com/pattern-matching-callbacks))! Please let us know how it goes @mayjunjuly0313 as this is a new feature (we’d love to see what you make!)

---

<div class="post-metadata">

**Author:** ![churchill1973](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@churchill1973](https://community.plotly.com/u/churchill1973)\
**Post date:** [August 28, 2020, 4:29pm UTC](https://community.plotly.com/t/updating-shared-list-with-multiple-callback-inputs/37875/4 "2020-08-28T16:29:31Z")

</div>

Hi there! Your use case is exactly what I am looking for.  
Did you get it? I tried to match the graph’s id with a dropdown’s option, but there is no id for every dropdown’s option.  
My idea is (step by step):

1. The user adds a graph (and he can add as many as wanted)
2. A new element is added to the dropdown’s options (so there is a match between this element and the added graph).
3. The user can select this option.
4. Given the selected option, he can modify the figure.

I am stuck trying to figure it out. Thank you for your help!

@chriddyp I woud be grateful if I can take one minute of your time! Thanks!!

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [August 28, 2020, 7:35pm UTC](https://community.plotly.com/t/updating-shared-list-with-multiple-callback-inputs/37875/5 "2020-08-28T19:35:48Z")

</div>

Hi @churchill1973

This announcement includes a nice example of pattern matching callbacks: [📣 Dash v1.11.0 Release - Introducing Pattern-Matching Callbacks](https://community.plotly.com/t/dash-v1-11-0-release-introducing-pattern-matching-callbacks/37592/2)

It sounds like what you are looking for.
