State timeline: defer quadtree construction until first mousemove (#34949)
This commit is contained in:
@@ -143,7 +143,7 @@ export function getConfig(opts: TimelineCoreOptions) {
|
|||||||
const fieldConfig = getFieldConfig(seriesIdx);
|
const fieldConfig = getFieldConfig(seriesIdx);
|
||||||
const fillColor = getFillColor(fieldConfig, valueColor);
|
const fillColor = getFillColor(fieldConfig, valueColor);
|
||||||
|
|
||||||
const boxRect = (boxRectsBySeries[seriesIdx][valueIdx] = {
|
boxRectsBySeries[seriesIdx][valueIdx] = {
|
||||||
x: round(left - xOff),
|
x: round(left - xOff),
|
||||||
y: round(top - yOff),
|
y: round(top - yOff),
|
||||||
w: boxWidth,
|
w: boxWidth,
|
||||||
@@ -152,9 +152,7 @@ export function getConfig(opts: TimelineCoreOptions) {
|
|||||||
didx: valueIdx,
|
didx: valueIdx,
|
||||||
// for computing label contrast
|
// for computing label contrast
|
||||||
fillColor,
|
fillColor,
|
||||||
});
|
};
|
||||||
|
|
||||||
qt.add(boxRect);
|
|
||||||
|
|
||||||
if (discrete) {
|
if (discrete) {
|
||||||
let fillStyle = fillColor;
|
let fillStyle = fillColor;
|
||||||
@@ -429,6 +427,16 @@ export function getConfig(opts: TimelineCoreOptions) {
|
|||||||
const setCursor = (u: uPlot) => {
|
const setCursor = (u: uPlot) => {
|
||||||
let cx = round(u.cursor!.left! * pxRatio);
|
let cx = round(u.cursor!.left! * pxRatio);
|
||||||
let cy = round(u.cursor!.top! * pxRatio);
|
let cy = round(u.cursor!.top! * pxRatio);
|
||||||
|
|
||||||
|
// if quadtree is empty, fill it
|
||||||
|
if (!qt.o.length && qt.q == null) {
|
||||||
|
for (const seriesRects of boxRectsBySeries) {
|
||||||
|
for (const rect of seriesRects) {
|
||||||
|
rect && qt.add(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
doHover(cx, cy);
|
doHover(cx, cy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user