# Plotly Reactjs Linear/Bar Graph

**URL:** <https://community.plotly.com/t/plotly-reactjs-linear-bar-graph/58779>\
**Category:** plotly.js\
**Created:** [November 26, 2021, 6:40am UTC](https://community.plotly.com/t/plotly-reactjs-linear-bar-graph/58779 "2021-11-26T06:40:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bk70937](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@bk70937](https://community.plotly.com/u/bk70937)\
**Post date:** [November 26, 2021, 6:40am UTC](https://community.plotly.com/t/plotly-reactjs-linear-bar-graph/58779/1 "2021-11-26T06:40:39Z")

</div>

myPlot.on(‘plotly\_click’, function(data){

```
            console.log(data)

            for(var i=0; i<data.points.length; i++){

                annotate_text = 'x = '+data.points[i].x +' y = '+data.points[i].y.toPrecision(4);

                annotation = {

                    text: annotate_text,

                    x: data.points[i].x,

                    y: parseFloat(data.points[i].y.toPrecision(4))

                }

                annotations = self.layout.annotations || [];

                annotations.push(annotation);

                Plotly.relayout('myDiv',{annotations: annotations})

            }

        });

```

how to use plotly\_click event in reactjs?
