✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Set minimum and maximum width of the bar in barchart

I have created a bar chart with rangeslider using react-ploty.js. When the bar is zoomed out, the bars turn into thin line(sometime disappear if the range is over long time duration) and when it is zoomed in, it turns into a a very thick bar. I am aware that this is the expected behavior but I would like to set minimum and maximum bar width. Is there a way to do that in plolty.js ?

Currently, I am not setting any bar width and using the default settings of the library.

We don’t expose a min / max width attribute for bar traces at the moment.

To achieve the desired results, you could try to listing to the plotly_relayout event and adjust the width attribute with e.g. Plotly.restyle.

Ok thanks! I will try that approach.