From 77d6100b44708e85d5b1233e4454847e88dcc306 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Fri, 11 Dec 2020 13:01:55 -0600 Subject: [PATCH] GraphNG: update uPlot v1.5.0 (#29763) --- packages/grafana-ui/package.json | 2 +- .../src/components/GraphNG/utils.ts | 77 +--- .../{Plot.test.tsx => Plot.test_skip.tsx} | 0 .../uPlot/config/UPlotConfigBuilder.test.ts | 17 + .../uPlot/config/UPlotConfigBuilder.ts | 10 +- .../uPlot/config/UPlotScaleBuilder.ts | 1 + .../uPlot/config/UPlotSeriesBuilder.ts | 25 +- .../src/components/uPlot/hooks.test.ts | 8 - .../grafana-ui/src/components/uPlot/hooks.ts | 13 +- .../grafana-ui/src/components/uPlot/paths.ts | 370 ------------------ .../uPlot/plugins/SelectionPlugin.tsx | 4 + .../grafana-ui/src/components/uPlot/utils.ts | 6 - yarn.lock | 8 +- 13 files changed, 57 insertions(+), 484 deletions(-) rename packages/grafana-ui/src/components/uPlot/{Plot.test.tsx => Plot.test_skip.tsx} (100%) delete mode 100644 packages/grafana-ui/src/components/uPlot/paths.ts diff --git a/packages/grafana-ui/package.json b/packages/grafana-ui/package.json index 99affc01406..c05569cd0ac 100644 --- a/packages/grafana-ui/package.json +++ b/packages/grafana-ui/package.json @@ -71,7 +71,7 @@ "react-transition-group": "4.4.1", "slate": "0.47.8", "tinycolor2": "1.4.1", - "uplot": "1.4.7" + "uplot": "1.5.0" }, "devDependencies": { "@rollup/plugin-commonjs": "16.0.0", diff --git a/packages/grafana-ui/src/components/GraphNG/utils.ts b/packages/grafana-ui/src/components/GraphNG/utils.ts index 2d6376708f6..260f23587a3 100755 --- a/packages/grafana-ui/src/components/GraphNG/utils.ts +++ b/packages/grafana-ui/src/components/GraphNG/utils.ts @@ -8,7 +8,7 @@ import { FieldMatcherID, } from '@grafana/data'; import { AlignedFrameWithGapTest } from '../uPlot/types'; -import uPlot, { AlignedData, AlignedDataWithGapTest } from 'uplot'; +import uPlot, { AlignedData } from 'uplot'; import { XYFieldMatchers } from './GraphNG'; // the results ofter passing though data @@ -103,7 +103,7 @@ export function alignDataFrames(frames: DataFrame[], fields?: XYFieldMatchers): } // do the actual alignment (outerJoin on the first arrays) - let { data: alignedData, isGap } = outerJoinValues(valuesFromFrames, skipGaps); + let { data: alignedData, isGap } = uPlot.join(valuesFromFrames, skipGaps); if (alignedData!.length !== sourceFields.length) { throw new Error('outerJoinValues lost a field?'); @@ -121,76 +121,3 @@ export function alignDataFrames(frames: DataFrame[], fields?: XYFieldMatchers): isGap, }; } - -// skipGaps is a tables-matched bool array indicating which series can skip storing indices of original nulls -export function outerJoinValues(tables: AlignedData[], skipGaps?: boolean[][]): AlignedDataWithGapTest { - if (tables.length === 1) { - return { - data: tables[0], - isGap: skipGaps ? (u: uPlot, seriesIdx: number, dataIdx: number) => !skipGaps[0][seriesIdx] : () => true, - }; - } - - let xVals: Set = new Set(); - let xNulls: Array> = [new Set()]; - - for (let ti = 0; ti < tables.length; ti++) { - let t = tables[ti]; - let xs = t[0]; - let len = xs.length; - let nulls: Set = new Set(); - - for (let i = 0; i < len; i++) { - xVals.add(xs[i]); - } - - for (let j = 1; j < t.length; j++) { - if (skipGaps == null || !skipGaps[ti][j]) { - let ys = t[j]; - - for (let i = 0; i < len; i++) { - if (ys[i] == null) { - nulls.add(xs[i]); - } - } - } - } - - xNulls.push(nulls); - } - - let data: AlignedData = [Array.from(xVals).sort((a, b) => a - b)]; - - let alignedLen = data[0].length; - - let xIdxs = new Map(); - - for (let i = 0; i < alignedLen; i++) { - xIdxs.set(data[0][i], i); - } - - for (const t of tables) { - let xs = t[0]; - - for (let j = 1; j < t.length; j++) { - let ys = t[j]; - - let yVals = Array(alignedLen).fill(null); - - for (let i = 0; i < ys.length; i++) { - yVals[xIdxs.get(xs[i])] = ys[i]; - } - - data.push(yVals); - } - } - - return { - data: data, - isGap(u: uPlot, seriesIdx: number, dataIdx: number) { - // u.data has to be AlignedDate - let xVal = u.data[0][dataIdx]; - return xNulls[seriesIdx].has(xVal!); - }, - }; -} diff --git a/packages/grafana-ui/src/components/uPlot/Plot.test.tsx b/packages/grafana-ui/src/components/uPlot/Plot.test_skip.tsx similarity index 100% rename from packages/grafana-ui/src/components/uPlot/Plot.test.tsx rename to packages/grafana-ui/src/components/uPlot/Plot.test_skip.tsx diff --git a/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.test.ts b/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.test.ts index 0b72f6e0eb8..7ded002dc1b 100644 --- a/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.test.ts +++ b/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.test.ts @@ -20,12 +20,19 @@ describe('UPlotConfigBuilder', () => { expect(builder.getConfig()).toMatchInlineSnapshot(` Object { "axes": Array [], + "cursor": Object { + "drag": Object { + "setScale": false, + }, + }, "scales": Object { "scale-x": Object { + "auto": false, "range": [Function], "time": true, }, "scale-y": Object { + "auto": true, "range": [Function], "time": false, }, @@ -95,6 +102,11 @@ describe('UPlotConfigBuilder', () => { "values": Array [], }, ], + "cursor": Object { + "drag": Object { + "setScale": false, + }, + }, "scales": Object {}, "series": Array [ Object {}, @@ -138,6 +150,11 @@ describe('UPlotConfigBuilder', () => { expect(builder.getConfig()).toMatchInlineSnapshot(` Object { "axes": Array [], + "cursor": Object { + "drag": Object { + "setScale": false, + }, + }, "scales": Object {}, "series": Array [ Object {}, diff --git a/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.ts b/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.ts index 1a3b7cc1697..e871fca368e 100644 --- a/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.ts +++ b/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.ts @@ -4,6 +4,7 @@ import { SeriesProps, UPlotSeriesBuilder } from './UPlotSeriesBuilder'; import { AxisProps, UPlotAxisBuilder } from './UPlotAxisBuilder'; import { AxisPlacement } from '../config'; import { Cursor } from 'uplot'; +import { defaultsDeep } from 'lodash'; export class UPlotConfigBuilder { private series: UPlotSeriesBuilder[] = []; @@ -68,9 +69,12 @@ export class UPlotConfigBuilder { config.scales = this.scales.reduce((acc, s) => { return { ...acc, ...s.getConfig() }; }, {}); - if (this.cursor) { - config.cursor = this.cursor; - } + + config.cursor = this.cursor || {}; + + // prevent client-side zoom from triggering at the end of a selection + defaultsDeep(config.cursor, { drag: { setScale: false } }); + return config; } } diff --git a/packages/grafana-ui/src/components/uPlot/config/UPlotScaleBuilder.ts b/packages/grafana-ui/src/components/uPlot/config/UPlotScaleBuilder.ts index 13709f605c3..d23125b8f99 100644 --- a/packages/grafana-ui/src/components/uPlot/config/UPlotScaleBuilder.ts +++ b/packages/grafana-ui/src/components/uPlot/config/UPlotScaleBuilder.ts @@ -27,6 +27,7 @@ export class UPlotScaleBuilder extends PlotConfigBuilder { return { [scaleKey]: { time: isTime, + auto: !isTime, range: range ?? this.range, }, }; diff --git a/packages/grafana-ui/src/components/uPlot/config/UPlotSeriesBuilder.ts b/packages/grafana-ui/src/components/uPlot/config/UPlotSeriesBuilder.ts index 81207aa96ee..57c96d6cfa2 100755 --- a/packages/grafana-ui/src/components/uPlot/config/UPlotSeriesBuilder.ts +++ b/packages/grafana-ui/src/components/uPlot/config/UPlotSeriesBuilder.ts @@ -1,9 +1,19 @@ import tinycolor from 'tinycolor2'; import uPlot, { Series } from 'uplot'; import { DrawStyle, LineConfig, AreaConfig, PointsConfig, PointVisibility, LineInterpolation } from '../config'; -import { barsBuilder, smoothBuilder, stepBeforeBuilder, stepAfterBuilder } from '../paths'; import { PlotConfigBuilder } from '../types'; +const pathBuilders = uPlot.paths; + +const barWidthFactor = 0.6; +const barMaxWidth = Infinity; + +const barsBuilder = pathBuilders.bars!({ size: [barWidthFactor, barMaxWidth] }); +const linearBuilder = pathBuilders.linear!(); +const smoothBuilder = pathBuilders.spline!(); +const stepBeforeBuilder = pathBuilders.stepped!({ align: -1 }); +const stepAfterBuilder = pathBuilders.stepped!({ align: 1 }); + export interface SeriesProps extends LineConfig, AreaConfig, PointsConfig { drawStyle: DrawStyle; scaleKey: string; @@ -32,15 +42,8 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder { } else { lineConfig.stroke = lineColor; lineConfig.width = lineWidth; - lineConfig.paths = ( - self: uPlot, - seriesIdx: number, - idx0: number, - idx1: number, - extendGap: Series.ExtendGap, - buildClip: Series.BuildClip - ) => { - let pathsBuilder = self.paths; + lineConfig.paths = (self: uPlot, seriesIdx: number, idx0: number, idx1: number) => { + let pathsBuilder = linearBuilder; if (drawStyle === DrawStyle.Bars) { pathsBuilder = barsBuilder; @@ -54,7 +57,7 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder { } } - return pathsBuilder(self, seriesIdx, idx0, idx1, extendGap, buildClip); + return pathsBuilder(self, seriesIdx, idx0, idx1); }; } diff --git a/packages/grafana-ui/src/components/uPlot/hooks.test.ts b/packages/grafana-ui/src/components/uPlot/hooks.test.ts index 7a0637882d4..68df840f563 100644 --- a/packages/grafana-ui/src/components/uPlot/hooks.test.ts +++ b/packages/grafana-ui/src/components/uPlot/hooks.test.ts @@ -22,10 +22,6 @@ describe('usePlotConfig', () => { // "focus": Object { // "alpha": 1, // }, -// "gutters": Object { -// "x": 8, -// "y": 8, -// }, // "height": 0, // "hooks": Object {}, // "legend": Object { @@ -66,10 +62,6 @@ describe('usePlotConfig', () => { // "focus": Object { // "alpha": 1, // }, -// "gutters": Object { -// "x": 8, -// "y": 8, -// }, // "height": 0, // "hooks": Object {}, // "legend": Object { diff --git a/packages/grafana-ui/src/components/uPlot/hooks.ts b/packages/grafana-ui/src/components/uPlot/hooks.ts index afa9a363534..772b42c7a10 100644 --- a/packages/grafana-ui/src/components/uPlot/hooks.ts +++ b/packages/grafana-ui/src/components/uPlot/hooks.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'; import { PlotPlugin } from './types'; import { pluginLog } from './utils'; -import uPlot, { Options } from 'uplot'; +import uPlot, { Options, PaddingSide } from 'uplot'; import { getTimeZoneInfo, TimeZone } from '@grafana/data'; import { usePlotPluginContext } from './context'; import { UPlotConfigBuilder } from './config/UPlotConfigBuilder'; @@ -85,7 +85,11 @@ export const usePlotPlugins = () => { }; }; -export const DEFAULT_PLOT_CONFIG = { +const paddingSide: PaddingSide = (u, side, sidesWithAxes, cycleNum) => { + return sidesWithAxes[side] ? 0 : 8; +}; + +export const DEFAULT_PLOT_CONFIG: Partial = { focus: { alpha: 1, }, @@ -97,10 +101,7 @@ export const DEFAULT_PLOT_CONFIG = { legend: { show: false, }, - gutters: { - x: 8, - y: 8, - }, + padding: [paddingSide, paddingSide, paddingSide, paddingSide], series: [], hooks: {}, }; diff --git a/packages/grafana-ui/src/components/uPlot/paths.ts b/packages/grafana-ui/src/components/uPlot/paths.ts deleted file mode 100644 index 3173dcbf86e..00000000000 --- a/packages/grafana-ui/src/components/uPlot/paths.ts +++ /dev/null @@ -1,370 +0,0 @@ -import uPlot, { Series } from 'uplot'; - -export const barsBuilder: Series.PathBuilder = ( - u: uPlot, - seriesIdx: number, - idx0: number, - idx1: number, - extendGap: Series.ExtendGap, - buildClip: Series.BuildClip -) => { - const series = u.series[seriesIdx]; - const xdata = u.data[0]; - const ydata = u.data[seriesIdx]; - const scaleX = u.series[0].scale as string; - const scaleY = series.scale as string; - - const gapFactor = 0.25; - - let gap = (u.width * gapFactor) / (idx1 - idx0); - let maxWidth = Infinity; - - //@ts-ignore - let fillTo = series.fillTo(u, seriesIdx, series.min, series.max); - - let y0Pos = u.valToPos(fillTo, scaleY, true); - let colWid = u.bbox.width / (idx1 - idx0); - - let strokeWidth = Math.round(series.width! * devicePixelRatio); - - let barWid = Math.round(Math.min(maxWidth, colWid - gap) - strokeWidth); - - let stroke = new Path2D(); - - for (let i = idx0; i <= idx1; i++) { - let yVal = ydata[i]; - - if (yVal == null) { - continue; - } - - let xVal = u.scales.x.distr === 2 ? i : xdata[i]; - - // TODO: all xPos can be pre-computed once for all series in aligned set - let xPos = u.valToPos(xVal, scaleX, true); - let yPos = u.valToPos(yVal, scaleY, true); - - let lft = Math.round(xPos - barWid / 2); - let btm = Math.round(Math.max(yPos, y0Pos)); - let top = Math.round(Math.min(yPos, y0Pos)); - let barHgt = btm - top; - - stroke.rect(lft, top, barWid, barHgt); - } - - let fill = series.fill != null ? new Path2D(stroke) : undefined; - - return { - stroke, - fill, - }; -}; - -/* -const enum StepSide { - Before, - After, -} -*/ - -export const stepBeforeBuilder = stepBuilderFactory(false); -export const stepAfterBuilder = stepBuilderFactory(true); - -// babel does not support inlined const enums, so this uses a boolean flag for perf -// possible workaround: https://github.com/dosentmatter/babel-plugin-const-enum -function stepBuilderFactory(after: boolean): Series.PathBuilder { - return ( - u: uPlot, - seriesIdx: number, - idx0: number, - idx1: number, - extendGap: Series.ExtendGap, - buildClip: Series.BuildClip - ) => { - const series = u.series[seriesIdx]; - const xdata = u.data[0]; - const ydata = u.data[seriesIdx]; - const scaleX = u.series[0].scale as string; - const scaleY = series.scale as string; - const halfStroke = series.width! / 2; - - const stroke = new Path2D(); - - // find first non-null dataPt - while (ydata[idx0] == null) { - idx0++; - } - - // find last-null dataPt - while (ydata[idx1] == null) { - idx1--; - } - - let gaps: Series.Gaps = []; - let inGap = false; - let prevYPos = Math.round(u.valToPos(ydata[idx0]!, scaleY, true)); - let firstXPos = Math.round(u.valToPos(xdata[idx0], scaleX, true)); - let prevXPos = firstXPos; - - stroke.moveTo(firstXPos, prevYPos); - - for (let i = idx0 + 1; i <= idx1; i++) { - let yVal1 = ydata[i]; - - let x1 = Math.round(u.valToPos(xdata[i], scaleX, true)); - - if (yVal1 == null) { - //@ts-ignore - if (series.isGap(u, seriesIdx, i)) { - extendGap(gaps, prevXPos, x1); - inGap = true; - } - - continue; - } - - let y1 = Math.round(u.valToPos(yVal1, scaleY, true)); - - if (inGap) { - extendGap(gaps, prevXPos, x1); - - // don't clip vertical extenders - if (prevYPos !== y1) { - let lastGap = gaps[gaps.length - 1]; - lastGap[0] += halfStroke; - lastGap[1] -= halfStroke; - } - - inGap = false; - } - - if (after) { - stroke.lineTo(x1, prevYPos); - } else { - stroke.lineTo(prevXPos, y1); - } - - stroke.lineTo(x1, y1); - - prevYPos = y1; - prevXPos = x1; - } - - const fill = new Path2D(stroke); - - //@ts-ignore - let fillTo = series.fillTo(u, seriesIdx, series.min, series.max); - - let minY = Math.round(u.valToPos(fillTo, scaleY, true)); - - fill.lineTo(prevXPos, minY); - fill.lineTo(firstXPos, minY); - - let clip = !series.spanGaps ? buildClip(gaps) : null; - - return { - stroke, - fill, - clip, - }; - }; -} - -// adapted from https://gist.github.com/nicholaswmin/c2661eb11cad5671d816 (MIT) -/** - * Interpolates a Catmull-Rom Spline through a series of x/y points - * Converts the CR Spline to Cubic Beziers for use with SVG items - * - * If 'alpha' is 0.5 then the 'Centripetal' variant is used - * If 'alpha' is 1 then the 'Chordal' variant is used - * - * - * @param {Array} data - Array of points, each point in object literal holding x/y values - * @return {String} d - SVG string with cubic bezier curves representing the Catmull-Rom Spline - */ -function catmullRomFitting(xCoords: number[], yCoords: number[], alpha: number) { - const path = new Path2D(); - - const dataLen = xCoords.length; - - let p0x, - p0y, - p1x, - p1y, - p2x, - p2y, - p3x, - p3y, - bp1x, - bp1y, - bp2x, - bp2y, - d1, - d2, - d3, - A, - B, - N, - M, - d3powA, - d2powA, - d3pow2A, - d2pow2A, - d1pow2A, - d1powA; - - path.moveTo(Math.round(xCoords[0]), Math.round(yCoords[0])); - - for (let i = 0; i < dataLen - 1; i++) { - let p0i = i === 0 ? 0 : i - 1; - - p0x = xCoords[p0i]; - p0y = yCoords[p0i]; - - p1x = xCoords[i]; - p1y = yCoords[i]; - - p2x = xCoords[i + 1]; - p2y = yCoords[i + 1]; - - if (i + 2 < dataLen) { - p3x = xCoords[i + 2]; - p3y = yCoords[i + 2]; - } else { - p3x = p2x; - p3y = p2y; - } - - d1 = Math.sqrt(Math.pow(p0x - p1x, 2) + Math.pow(p0y - p1y, 2)); - d2 = Math.sqrt(Math.pow(p1x - p2x, 2) + Math.pow(p1y - p2y, 2)); - d3 = Math.sqrt(Math.pow(p2x - p3x, 2) + Math.pow(p2y - p3y, 2)); - - // Catmull-Rom to Cubic Bezier conversion matrix - - // A = 2d1^2a + 3d1^a * d2^a + d3^2a - // B = 2d3^2a + 3d3^a * d2^a + d2^2a - - // [ 0 1 0 0 ] - // [ -d2^2a /N A/N d1^2a /N 0 ] - // [ 0 d3^2a /M B/M -d2^2a /M ] - // [ 0 0 1 0 ] - - d3powA = Math.pow(d3, alpha); - d3pow2A = Math.pow(d3, 2 * alpha); - d2powA = Math.pow(d2, alpha); - d2pow2A = Math.pow(d2, 2 * alpha); - d1powA = Math.pow(d1, alpha); - d1pow2A = Math.pow(d1, 2 * alpha); - - A = 2 * d1pow2A + 3 * d1powA * d2powA + d2pow2A; - B = 2 * d3pow2A + 3 * d3powA * d2powA + d2pow2A; - N = 3 * d1powA * (d1powA + d2powA); - - if (N > 0) { - N = 1 / N; - } - - M = 3 * d3powA * (d3powA + d2powA); - - if (M > 0) { - M = 1 / M; - } - - bp1x = (-d2pow2A * p0x + A * p1x + d1pow2A * p2x) * N; - bp1y = (-d2pow2A * p0y + A * p1y + d1pow2A * p2y) * N; - - bp2x = (d3pow2A * p1x + B * p2x - d2pow2A * p3x) * M; - bp2y = (d3pow2A * p1y + B * p2y - d2pow2A * p3y) * M; - - if (bp1x === 0 && bp1y === 0) { - bp1x = p1x; - bp1y = p1y; - } - - if (bp2x === 0 && bp2y === 0) { - bp2x = p2x; - bp2y = p2y; - } - - path.bezierCurveTo(bp1x, bp1y, bp2x, bp2y, p2x, p2y); - } - - return path; -} - -export const smoothBuilder: Series.PathBuilder = ( - u: uPlot, - seriesIdx: number, - idx0: number, - idx1: number, - extendGap: Series.ExtendGap, - buildClip: Series.BuildClip -) => { - const series = u.series[seriesIdx]; - const xdata = u.data[0]; - const ydata = u.data[seriesIdx]; - const scaleX = u.series[0].scale as string; - const scaleY = series.scale as string; - - // find first non-null dataPt - while (ydata[idx0] == null) { - idx0++; - } - - // find last-null dataPt - while (ydata[idx1] == null) { - idx1--; - } - - let gaps: Series.Gaps = []; - let inGap = false; - let firstXPos = Math.round(u.valToPos(xdata[idx0], scaleX, true)); - let prevXPos = firstXPos; - - let xCoords = []; - let yCoords = []; - - for (let i = idx0; i <= idx1; i++) { - let yVal = ydata[i]; - let xVal = xdata[i]; - let xPos = u.valToPos(xVal, scaleX, true); - - if (yVal == null) { - //@ts-ignore - if (series.isGap(u, seriesIdx, i)) { - extendGap(gaps, prevXPos + 1, xPos); - inGap = true; - } - - continue; - } else { - if (inGap) { - extendGap(gaps, prevXPos + 1, xPos + 1); - inGap = false; - } - - xCoords.push((prevXPos = xPos)); - yCoords.push(u.valToPos(ydata[i]!, scaleY, true)); - } - } - - const stroke = catmullRomFitting(xCoords, yCoords, 0.5); - - const fill = new Path2D(stroke); - - //@ts-ignore - let fillTo = series.fillTo(u, seriesIdx, series.min, series.max); - - let minY = Math.round(u.valToPos(fillTo, scaleY, true)); - - fill.lineTo(prevXPos, minY); - fill.lineTo(firstXPos, minY); - - let clip = !series.spanGaps ? buildClip(gaps) : null; - - return { - stroke, - fill, - clip, - }; -}; diff --git a/packages/grafana-ui/src/components/uPlot/plugins/SelectionPlugin.tsx b/packages/grafana-ui/src/components/uPlot/plugins/SelectionPlugin.tsx index 285568f98e0..1aa029db2eb 100644 --- a/packages/grafana-ui/src/components/uPlot/plugins/SelectionPlugin.tsx +++ b/packages/grafana-ui/src/components/uPlot/plugins/SelectionPlugin.tsx @@ -67,6 +67,10 @@ export const SelectionPlugin: React.FC = ({ onSelect, onDi width: u.select.width, }, }); + + // manually hide selected region (since cursor.drag.setScale = false) + /* @ts-ignore */ + u.setSelect({ left: 0, width: 0 }, false); }, }, }); diff --git a/packages/grafana-ui/src/components/uPlot/utils.ts b/packages/grafana-ui/src/components/uPlot/utils.ts index 4d5bccf5dd7..069c25a5da9 100755 --- a/packages/grafana-ui/src/components/uPlot/utils.ts +++ b/packages/grafana-ui/src/components/uPlot/utils.ts @@ -1,5 +1,4 @@ import throttle from 'lodash/throttle'; -import { rangeUtil, RawTimeRange } from '@grafana/data'; import { Options } from 'uplot'; import { PlotPlugin, PlotProps } from './types'; @@ -9,11 +8,6 @@ export const timeFormatToTemplate = (f: string) => { return f.replace(ALLOWED_FORMAT_STRINGS_REGEX, match => `{${match}}`); }; -export function rangeToMinMax(timeRange: RawTimeRange): [number, number] { - const v = rangeUtil.convertRawToRange(timeRange); - return [v.from.valueOf() / 1000, v.to.valueOf() / 1000]; -} - export const buildPlotConfig = (props: PlotProps, plugins: Record): Options => { return { width: props.width, diff --git a/yarn.lock b/yarn.lock index e4aa761fb04..02bd8830e65 100644 --- a/yarn.lock +++ b/yarn.lock @@ -25703,10 +25703,10 @@ update-notifier@^2.5.0: semver-diff "^2.0.0" xdg-basedir "^3.0.0" -uplot@1.4.7: - version "1.4.7" - resolved "https://registry.yarnpkg.com/uplot/-/uplot-1.4.7.tgz#feab0cf48b569184bfefacf29308deb021bad765" - integrity sha512-zyVwJWuZ5/DOULPpJZb8XhVsSFgWXvitPg1acAwIjZEblUfKAwvfHXA6+Gz6JruCWCokNyC4f3ZGgMcqT0Bv0Q== +uplot@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/uplot/-/uplot-1.5.0.tgz#c2814cd7a073ed12b0a1d2fc985f3d9cd33bf0cd" + integrity sha512-ghzlTe4rgoYiM98pMUJCplQhSmhyJV8Pv+obV3sHDoC+VBrZDc8fxXnUNGUVcKhUW2eqyeO5D0huardirwOmHw== upper-case@^1.1.1: version "1.1.3"