Black Lives Matter. Please consider donating to Black Girls Code today.

Hoverover functionality to change the color of bars

Hey guys, I have made a basic bar chart using Plotly.js bar chart examples where the data is derived from a CSV file. Now I want to add functionality when we hover over the bars the color changes where and how can I add that, can anyone help me here.

After plotting my graph, I have used the function:
myPlot.on(‘plotly_hover’, function(data){
data[‘data1’] = {‘marker’: {‘color’: ‘#000’}}
.on(‘plotly_unhover’, function(data){
data[‘data1’] = {‘marker’: {‘color’: ‘#005587’}}

will this work?

Hi @shrutiPlot this example does exactly what you want I think, you just need to replace the scatter with a bar plot.

Hey @Emmanuelle, thank you that helped me:slight_smile: