Kaktana / kaktana-react-lightweight-charts

A simple react wrapper for the tradingview lightweight charts module
MIT License
106 stars 55 forks source link

AutoWidth does not rezize when component gets smaller #26

Open ghost opened 3 years ago

ghost commented 3 years ago

Hi, as the title says, the Chart does not resize correctly when enabling the autoWidth property. My chart is in a flex container with the flex-grow = 1 enabled. I have tried to fix it by using hooks and feeding custom width and height values, with no luck.

Make the page width bigger, then try to make it smaller. You will see that you can scroll horizontally because the Chart component is not correctly sized.

https://codesandbox.io/s/width-resize-dhz1c

Any ideas? Thanks in advance.

DenysPavlenko commented 2 years ago

Hi there, Struggled with the same issue. The workaround is to wrap the chart in 2 divs. First div should have static height and relative position. The inner one should have absolute position and be stretched. Here is the code:

` <div className="relative" style={{ height }}>

</div>

`

I use tailwind for classes, but I believe you could easily transform them into regular css.