I am trying to implement a “click to highlight” behavior on bar chart. Using the code below:
myPlot.on(‘plotly_click’, function(data){
var update_color = new Array(data.points[0].data.x.length)
update_color.fill(‘’);update_color[data.points[0].pointNumber] = 'rgb(255, 65, 54)' var update = {marker: {color: update_color}} Plotly.restyle(myPlot, update, 0);
});
But the empty strings in the update object turn the unselected bars into black. I also tried to use ‘undefined’, and it cannot maintains the current format either. Any clues?