leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.48k stars 370 forks source link

what would be an approach to make groups of series? #938

Closed unphased closed 1 month ago

unphased commented 1 month ago

I came up with the idea to make a cartesian product generator that produces combinations of values to generate results with. I'm testing by doing some compression algorithm benchmarking based off of this concept. What gets difficult though is the linear listing in the legend of all the series. When i have a hundred or more series (imagine the cartesian product of 5 compression algorithms with 10 compression levels each and two types of input string, that's 100 combinations already) it gets painful to go through and select them individually for toggling visibility. I did find though that Cmd+click on a legend item very helpfully deselects everything else.

Obviously this is an edge case and I'm going to have to come up with my own clever way to inject behavior to implement more advanced series toggling behavior. I was just curious if there are any examples of this being done. i looked through all demos and did not see anything like this.

leeoniya commented 1 month ago

the legend has a table mode that will probably be much more readable.

https://leeoniya.github.io/uPlot/demos/time-periods.html https://leeoniya.github.io/uPlot/demos/scatter.html

you can also restyle the legend via css to stack instead of have the series inline, and maybe use a fixed-width font. it's all in DOM.

in terms of toggle behavior, you can make your own buttons that hook into the u.setSeries(idx, {show: true/false}) API to toggle groups of series as you see fit. the built-in legend just has the click and cmd+click behavior.