From b3387793f17695658e801685d46ad7b2f2acf6a9 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Fri, 29 Dec 2023 13:43:15 -0600 Subject: [PATCH] Chore: uPlot v1.6.28 (#79732) --- package.json | 2 +- packages/grafana-data/package.json | 2 +- packages/grafana-ui/package.json | 2 +- .../core/components/TimelineChart/timeline.ts | 7 ++++ public/app/plugins/panel/barchart/bars.ts | 32 +++---------------- .../status-history/StatusHistoryTooltip2.tsx | 5 ++- yarn.lock | 14 ++++---- 7 files changed, 24 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 07f6100aa40..7623be0ff2b 100644 --- a/package.json +++ b/package.json @@ -414,7 +414,7 @@ "tinycolor2": "1.6.0", "tslib": "2.6.0", "tween-functions": "^1.2.0", - "uplot": "1.6.27", + "uplot": "1.6.28", "uuid": "9.0.0", "vendor": "link:./public/vendor", "visjs-network": "4.25.0", diff --git a/packages/grafana-data/package.json b/packages/grafana-data/package.json index 9f966f93258..b17a82b18c5 100644 --- a/packages/grafana-data/package.json +++ b/packages/grafana-data/package.json @@ -58,7 +58,7 @@ "string-hash": "^1.1.3", "tinycolor2": "1.6.0", "tslib": "2.6.0", - "uplot": "1.6.27", + "uplot": "1.6.28", "xss": "^1.0.14" }, "devDependencies": { diff --git a/packages/grafana-ui/package.json b/packages/grafana-ui/package.json index d18ecbd49d7..62054c80636 100644 --- a/packages/grafana-ui/package.json +++ b/packages/grafana-ui/package.json @@ -109,7 +109,7 @@ "slate-react": "0.22.10", "tinycolor2": "1.6.0", "tslib": "2.6.0", - "uplot": "1.6.27", + "uplot": "1.6.28", "uuid": "9.0.0" }, "devDependencies": { diff --git a/public/app/core/components/TimelineChart/timeline.ts b/public/app/core/components/TimelineChart/timeline.ts index 8cd9817921a..6143ffe5763 100644 --- a/public/app/core/components/TimelineChart/timeline.ts +++ b/public/app/core/components/TimelineChart/timeline.ts @@ -441,6 +441,13 @@ export function getConfig(opts: TimelineCoreOptions) { return hovered[seriesIdx]?.didx; }, + focus: { + prox: 30, + dist: (u, seriesIdx, dataIdx, valPos, curPos) => { + valPos = yMids[seriesIdx - 1] / uPlot.pxRatio; + return valPos - curPos; + }, + }, points: { fill: 'rgba(255,255,255,0.2)', bbox: (u, seriesIdx) => { diff --git a/public/app/plugins/panel/barchart/bars.ts b/public/app/plugins/panel/barchart/bars.ts index be528a04794..ac127b87134 100644 --- a/public/app/plugins/panel/barchart/bars.ts +++ b/public/app/plugins/panel/barchart/bars.ts @@ -15,7 +15,7 @@ import { formatTime } from '@grafana/ui/src/components/uPlot/config/UPlotAxisBui import { StackingGroup, preparePlotData2 } from '@grafana/ui/src/components/uPlot/utils'; import { distribute, SPACE_BETWEEN } from './distribute'; -import { findRect, intersects, pointWithin, Quadtree, Rect } from './quadtree'; +import { intersects, pointWithin, Quadtree, Rect } from './quadtree'; const groupDistr = SPACE_BETWEEN; const barDistr = SPACE_BETWEEN; @@ -470,14 +470,7 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) { qt.get(cx, cy, 1, 1, (o) => { if (pointWithin(cx, cy, o.x, o.y, o.x + o.w, o.y + o.h)) { - if (isStacked) { - // choose the smallest hovered rect (when stacked bigger ones overlap smaller ones) - if (hRect == null || o.h * o.w < hRect.h * hRect.w) { - hRect = o; - } - } else { - hRect = o; - } + hRect = o; } }); } @@ -489,26 +482,11 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) { bbox: (u, seriesIdx) => { let isHovered = hRect && seriesIdx === hRect.sidx; - let heightReduce = 0; - let widthReduce = 0; - - // get height of bar rect at same index of the series below the hovered one - if (isStacked && isHovered) { - const rect = hRect && hRect.sidx > 1 && findRect(qt, hRect.sidx - 1, hRect.didx); - if (rect) { - if (isXHorizontal) { - heightReduce = rect.h; - } else { - widthReduce = rect.w; - } - } - } - return { - left: isHovered ? (hRect!.x + widthReduce) / uPlot.pxRatio : -10, + left: isHovered ? hRect!.x / uPlot.pxRatio : -10, top: isHovered ? hRect!.y / uPlot.pxRatio : -10, - width: isHovered ? (hRect!.w - widthReduce) / uPlot.pxRatio : 0, - height: isHovered ? (hRect!.h - heightReduce) / uPlot.pxRatio : 0, + width: isHovered ? hRect!.w / uPlot.pxRatio : 0, + height: isHovered ? hRect!.h / uPlot.pxRatio : 0, }; }, }, diff --git a/public/app/plugins/panel/status-history/StatusHistoryTooltip2.tsx b/public/app/plugins/panel/status-history/StatusHistoryTooltip2.tsx index 16c52153dfd..622f0bd3745 100644 --- a/public/app/plugins/panel/status-history/StatusHistoryTooltip2.tsx +++ b/public/app/plugins/panel/status-history/StatusHistoryTooltip2.tsx @@ -52,10 +52,9 @@ export const StatusHistoryTooltip2 = ({ }: StatusHistoryTooltipProps) => { const styles = useStyles2(getStyles); - // @todo: check other dataIdx, it can be undefined or null in array - const datapointIdx = dataIdxs.find((idx) => idx !== undefined); + const datapointIdx = seriesIdx != null ? dataIdxs[seriesIdx] : dataIdxs.find((idx) => idx != null); - if (!data || datapointIdx == null) { + if (datapointIdx == null || seriesIdx == null) { return null; } diff --git a/yarn.lock b/yarn.lock index 9d2fdfaf4dd..8d5087cb4d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2969,7 +2969,7 @@ __metadata: tinycolor2: "npm:1.6.0" tslib: "npm:2.6.0" typescript: "npm:5.2.2" - uplot: "npm:1.6.27" + uplot: "npm:1.6.28" xss: "npm:^1.0.14" peerDependencies: react: ^17.0.0 || ^18.0.0 @@ -3481,7 +3481,7 @@ __metadata: tinycolor2: "npm:1.6.0" tslib: "npm:2.6.0" typescript: "npm:5.2.2" - uplot: "npm:1.6.27" + uplot: "npm:1.6.28" uuid: "npm:9.0.0" webpack: "npm:5.89.0" peerDependencies: @@ -17617,7 +17617,7 @@ __metadata: tslib: "npm:2.6.0" tween-functions: "npm:^1.2.0" typescript: "npm:5.2.2" - uplot: "npm:1.6.27" + uplot: "npm:1.6.28" uuid: "npm:9.0.0" vendor: "link:./public/vendor" visjs-network: "npm:4.25.0" @@ -29926,10 +29926,10 @@ __metadata: languageName: node linkType: hard -"uplot@npm:1.6.27": - version: 1.6.27 - resolution: "uplot@npm:1.6.27" - checksum: b46de70804fdec2aa62101d8980aa18517a9a84e94fdeac922baa8121140ddae35685002a7cbdc74bbe6ea2306e341628490f5a5e2fa4b8086ff1643dccf2be9 +"uplot@npm:1.6.28": + version: 1.6.28 + resolution: "uplot@npm:1.6.28" + checksum: 6771289c45f2b8e8ad5d56abd8c92e7f5687244d75265f80957af857c2034b7b5e3128122262e5a546da2fc4437b600e56a058523eff1435b5bf6728ddc19612 languageName: node linkType: hard