UI: Skip restacking on hover in stacked series charts

See https://github.com/leeoniya/uPlot/issues/988

Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
Julius Volz 2026-03-04 21:52:11 +01:00
parent ac12e30f99
commit 2df86b24ad

View File

@ -85,14 +85,16 @@ export function setStackedOpts(opts: uPlot.Options, data: uPlot.AlignedData) {
},
};
// restack on toggle
// restack on toggle (but not on focus/hover)
opts.hooks = opts.hooks || {};
opts.hooks.setSeries = opts.hooks.setSeries || [];
opts.hooks.setSeries.push((u, _i) => {
const stacked = stack(data, (i) => !u.series[i].show);
u.delBand(null);
stacked.bands.forEach((b) => u.addBand(b));
u.setData(stacked.data);
opts.hooks.setSeries.push((u, _i, opts) => {
if (opts.show != null) {
const stacked = stack(data, (i) => !u.series[i].show);
u.delBand(null);
stacked.bands.forEach((b) => u.addBand(b));
u.setData(stacked.data);
}
});
return { opts, data: stacked.data };