plouc / nivo

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
https://nivo.rocks
MIT License
13.08k stars 1.02k forks source link

Legend of ResponsiveBar are not updated properly on resize #1338

Closed dubzzz closed 3 years ago

dubzzz commented 3 years ago

First of all, thanks a lot for this amazing project πŸ‘

Describe/explain the bug

It seems that the legend on charts rendered using the component <ResponsiveBar /> is not resized properly when updating the size of the parent.

The issue only happens with production build (I was not able to reproduce it with dev mode). It seems that it was introduced between 0.62.x and 0.66.x.

To Reproduce

The detailed scenario with dev and production bundles is available at: https://github.com/dubzzz/nivo-legend-resize-bug/blob/main/README.md

Steps to reproduce the behavior:

  1. Go to https://2zjxx.csb.app/ (or https://codesandbox.io/s/fervent-chaum-2zjxx?file=/src/App.js) - dev bundle
  2. Try to resize the window: legend and chart are both properly resized
  3. Go to https://dubzzz.github.io/nivo-legend-resize-bug/build/ - prod bundle, same code
  4. Try to resize the window: legend does not seem to be resized properly

Expected behavior

Production and dev should behave the same way. Resize of the window should resize the legend and the chart together.

Screenshots

Here is what I have with the production bundle: nivo-prod

dubzzz commented 3 years ago

Just in case it can help, I think that the issue is not limited to bar chart and also happens with others πŸ€”

plouc commented 3 years ago

@dubzzz thank you very much for the examples and detailed report, it comes from an issue with react-spring which is now used for the axes/grids, it has an issue, and the fix hasn't been released yet, but there are ways to fix it, please have a look at this issue: https://github.com/plouc/nivo/issues/1290

dubzzz commented 3 years ago

Whaou thanks a lot for the linked issue, I'll have a look to it