perf(legend): reduce amount stress caused by too many legends#1121
perf(legend): reduce amount stress caused by too many legends#1121H4ad wants to merge 1 commit intoleeoniya:masterfrom
Conversation
This PR will contain these main changes: - using document fragment to avoid create elements directly in the dom - using requestFrameAnimation + insert the legends & cursor points last - remove ::after and ::before css to avoid costs of reflow
that's actually an upcoming topic of discussion in Grafana. we have users with 2k+ series per panel, and the legend being in the dom becomes a performance issue, (even though Grafana uses its own React legend)
that's my main concern with this approach, too. |
Can't we just emit an new event and make this a breaking change release? |
|
imo, rendering an insane amount of legend items is fundamentally useless. since human eyes are unlikely to accurately distinguish more than 20-30 colors, trying to slightly optimize the legend for hundreds+ series use case is not a great approach to fix both a performance and a UX issue. virtualization is not really possible with a non-table legend which flows/wraps unpredictably, so that solution would only help the table legend case, which is not the default. since uPlot does not currently have a tooltip (it may get one in v2.0), it kinda has to render all items to make it possible to see the raw values on hover. i want to make sure that any solution still allows a live legend to display the hovered value(s). a couple new options to paginate/show-all the legend in addition to being able to live-sort it by hovered value may work well enough for all use cases and be much faster than trying to optimize css/dom for a thousand series. 🤔 |
This PR will contain these main changes:
To test:
Before:
After:
I found this while trying to optimize the SigNoz/signoz#9784