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.

Hi,

@SDesai : Did you finally implement a solution that you can share to the community?

I have the same issue with Gantt charts where the bars get too small to be shown,
and my workaround was to add a line around each bar using:

fig.update_traces(marker_line_color=‘rgb(0,48,107)’, marker_line_width=1, opacity=1)

This just does not solve the issue that hovers are not displayed if the bar is to small,
and “hoverdistance” does not work for bars. Playing now around for several hours,
i could not find a way to get hovers for super small gantt bars working.

Anyone has an idea here?