Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start without values #162

Closed
LostKobrakai opened this issue Mar 24, 2020 · 10 comments
Closed

Start without values #162

LostKobrakai opened this issue Mar 24, 2020 · 10 comments
Labels
question Further information is requested

Comments

@LostKobrakai
Copy link

I'm looking into using uPlot for a dashboard, where the dashboard starts being rendered with empty charts. Data only comes in after the initial render via websocket connections to metrics gathered via pub sub. I'm wondering if there's a way to make uPlot render something even if the array of data does not yet hold data?

@leeoniya
Copy link
Owner

you can use an empty data struct and specify the initial scale values:

https://jsfiddle.net/afL8o2zh/

@leeoniya leeoniya added the question Further information is requested label Mar 24, 2020
@LostKobrakai
Copy link
Author

This looks like what I was looking for, thanks.

@LostKobrakai
Copy link
Author

Just another follow up. Can I change the series config after initialization? E.g. switch out the label or add additional series with different labels after the fact? plot.setSeries doesn't seem to do that.

@leeoniya
Copy link
Owner

leeoniya commented Mar 24, 2020

there's not currently a way to add or remove series dynamically. you can toggle the pre-configured ones on/off and if you really wish to hide any trace of them, you can add a bit of code to display: none their legend's DOM. the series label is static and not touched by uPlot after initial legend creation, so again, you can poke the DOM to switch it out when/if needed.

there's also a setSeries and setData hooks you can use, too.

is the use case to have some library of metrics that you can toggle in a dashboard UI to add to a single plot? if so, it probably easiest to just re-build the plot with the new settings.

@LostKobrakai
Copy link
Author

The usecase are a single type of metric, but grouped per path and new paths can come in at any time. Axis and scales are the same between values, but the path and therefore the series are different.

@leeoniya
Copy link
Owner

i see.

it seems like rather strange UI for series to be dynamically added without limits. is there really a boundless quantity of series that might be shown on the plot?

is there an example of such a UI somewhere?

that being said, there's not really any architectural hurdle to adding .addSeries() and .delSeries(). i just want to control lib size and feature creep.

@leeoniya
Copy link
Owner

at some point you're gonna have to limit how many series can actually be added, if not for the terrible UI, then for perf reasons ;)

https://leeoniya.github.io/uPlot/bench/uPlot-600-series.html

@LostKobrakai
Copy link
Author

I wasn't really thinking about the without limits yet, but you're right. Should probably clarify that sooner rather than later. Thanks again.

@josevalim
Copy link

To clarify it a bit, in our case the number of paths is not really unbound. We are building a generic dashboard for application telemetry and each series in the graph is a different route pattern. So if we have a routing pattern like this:

get "/posts/:id"

and you access it as "/posts/1" and "/posts/2", both entries will be part of the same series.

In our case, since the dashboard is generic, some applications will have 10 different series, all added dynamically, which will be totally fine. While others will have more than 100 series, which indeed won't look good, as you showed. So for our purposes, adding series dynamically would still be valuable, even if it had a limit on the overall number of series.

I hope this helps give more context and thanks for the great lib!

@leeoniya
Copy link
Owner

@josevalim

alright, let me see what can be done. if for no other reason than to reduce the number of issues asking for the same in the span of a week 😆 (#167)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants