# Plotly click\_data with watch not working

**URL:** <https://discourse.holoviz.org/t/plotly-click-data-with-watch-not-working/6320>\
**Category:** Panel\
**Tags:** param, plotly\
**Created:** [November 1, 2023, 10:23am UTC](https://discourse.holoviz.org/t/plotly-click-data-with-watch-not-working/6320 "2023-11-01T10:23:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keyur\_ds](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/keyur_ds/32/5530_2.png) [@keyur\_ds](https://discourse.holoviz.org/u/keyur_ds)\
**Post date:** [November 1, 2023, 10:23am UTC](https://discourse.holoviz.org/t/plotly-click-data-with-watch-not-working/6320/1 "2023-11-01T10:23:03Z")

</div>

I’ve a below code in which I show plotly bar chart. Upon click on bar, I want to display which bar user has selected but the code I’ve written is not working. Please help.

```auto
import panel as pn
import param
import pandas as pd
import plotly.express as pltex

pn.extension('plotly')

class Example(param.Parameterized):
    df = param.DataFrame()
    selected_name = param.String(default='')

def bar_click(self, event):
    index = event.new['points'][0]['pointIndex']
    current_destination_name = self.df.iloc[index]['sr']
    self.selected_name = current_destination_name

def show_data():
    ex_obj = Example()
    data_list = [{'sr': 'A', 'total': 20},
                 {'sr': 'B', 'total': 50},
                 {'sr': 'C', 'total': 10},
                 {'sr': 'D', 'total': 70},
                 {'sr': 'E', 'total': 90},]
    ex_obj.df = pd.DataFrame(data_list)
    fig = pltex.bar(ex_obj.df, y='total', x='sr',
                    title="Bar Chart")
    fig.update_traces(textfont_size=12, textangle=0, textposition="outside", cliponaxis=False)
    fig.layout.autosize = True
    the_plotly_pane = pn.pane.Plotly(fig, config={'responsive': True})
    the_plotly_pane.param.watch(bar_click, 'click_data', onlychanged=False)
    gspec = pn.GridSpec()
    gspec[0:2, :3] = the_plotly_pane
    gspec[2,0] = pn.Column(pn.pane.Markdown(f"## Selected Sr : {ex_obj.selected_name}"), sizing_mode='stretch_width')
    tabs = pn.Tabs(('Analytics', gspec))
    return tabs

def show(page):
    tabs = show_data()
    return tabs

page = pn.widgets.RadioButtonGroup(
    value='First Page',
    options=['First Page', 'Second Page'],
    name="Page",
    button_type="success",
    orientation="vertical")

ishow = pn.bind(show, page=page)

pn.template.FastListTemplate(
    title="Data Analytics",
    sidebar=[page],
    main=[ishow]).servable()

```

It looks like this in browser.

 ![Screenshot 2023-11-01 at 3.49.55 PM](https://discourse.holoviz.org/uploads/default/original/2X/1/186b8c3152046af2821111f32dee69389a7239ef.png)

If I click on B bar then it should show **Selected Sr : B** but it’s not working currently. Nothing happens clicking on bar.
