leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

some kind resize(width, height) API

danyalejandro opened this issue · comments

Use case: Our sensor dashboards are shared by a team of 7 scientists. Some of them have their screens rotated (portrait). They both want to maximize screen usage without changing the code.

Would it be possible to add a "stretch to fit" option?

image

image

i would recommend that you first measure the size of the container you intend to put the charts into using something like element.getBoundingClientRect() and use those metrics to create the uPlot instances.

i have no plans to implement auto or fluid sizing in the core, since most of this can be handled outside the lib. and most of the time is not necessary after initial render anyhow.

if you need to resize the plots after initial render. i can maybe add a .resize(width, height) method so you can use that after init.

this is now available as .setSize({width, height})

So I have an event listener and at certain break points I run:

size = document.getElementById("chart-wrap").getBoundingClientRect()
uplotD.setSize(size.width,size.height)

But the plot sorta disappears whenever the size is update.
image

Am I using the setSize wrong does it need some sort of redraw or update after?

Am I using the setSize wrong

yes, it takes a single {width: ..., height: ...} object, not two arguments.