StateTimeline: Share cursor with rest of the panels (#41038)

* First working version of shared cursor for state timeline

* Only publish x value for time series

* Don't send legacy graph event

* Don't add y scale to cursor sync

* Snap cursor to the bottom of the canvas when sync is out of bounds

* Fix snapshot
This commit is contained in:
Zoltán Bedi
2021-11-05 18:52:40 +01:00
committed by GitHub
parent d69ffe0e44
commit af61839a26
7 changed files with 63 additions and 7 deletions
@@ -95,7 +95,7 @@ Object {
],
"scales": Array [
"x",
"__fixed",
null,
],
},
},
@@ -363,7 +363,8 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{ sync: DashboardCursor
},
},
// ??? setSeries: syncMode === DashboardCursorSync.Tooltip,
scales: builder.scaleKeys,
//TODO: remove any once https://github.com/leeoniya/uPlot/pull/611 got merged or the typing is fixed
scales: [xScaleKey, null as any],
match: [() => true, () => true],
};
}
@@ -181,6 +181,11 @@ export function findMidPointYPosition(u: uPlot, idx: number) {
y = u.valToPos((min || max)!, u.series[(sMaxIdx || sMinIdx)!].scale!);
}
// if y is out of canvas bounds, snap it to the bottom
if (y !== undefined && y < 0) {
y = u.bbox.height / devicePixelRatio;
}
return y;
}