From e8e1c1402fdbbbe40be2c0ed79fca09522e68919 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Thu, 17 Dec 2020 16:57:11 +0100 Subject: [PATCH] GraphNG: bring back tooltip (#29910) --- .../uPlot/config/UPlotConfigBuilder.test.ts | 46 +++++++++++++++++++ .../uPlot/config/UPlotConfigBuilder.ts | 3 ++ 2 files changed, 49 insertions(+) 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 8d8382adb46..74708ec79c8 100644 --- a/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.test.ts +++ b/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.test.ts @@ -6,6 +6,34 @@ import { expect } from '../../../../../../public/test/lib/common'; import { AreaGradientMode, AxisPlacement, DrawStyle, PointVisibility, ScaleDistribution } from '../config'; describe('UPlotConfigBuilder', () => { + describe('default config', () => { + it('builds default config', () => { + const builder = new UPlotConfigBuilder(); + expect(builder.getConfig()).toMatchInlineSnapshot(` + Object { + "axes": Array [], + "cursor": Object { + "drag": Object { + "setScale": false, + }, + "focus": Object { + "prox": 30, + }, + "points": Object { + "fill": [Function], + "size": [Function], + "stroke": [Function], + "width": [Function], + }, + }, + "scales": Object {}, + "series": Array [ + Object {}, + ], + } + `); + }); + }); describe('scales config', () => { it('allows scales configuration', () => { const builder = new UPlotConfigBuilder(); @@ -24,6 +52,9 @@ describe('UPlotConfigBuilder', () => { "drag": Object { "setScale": false, }, + "focus": Object { + "prox": 30, + }, "points": Object { "fill": [Function], "size": [Function], @@ -82,6 +113,9 @@ describe('UPlotConfigBuilder', () => { "drag": Object { "setScale": false, }, + "focus": Object { + "prox": 30, + }, "points": Object { "fill": [Function], "size": [Function], @@ -121,6 +155,9 @@ describe('UPlotConfigBuilder', () => { "drag": Object { "setScale": false, }, + "focus": Object { + "prox": 30, + }, "points": Object { "fill": [Function], "size": [Function], @@ -161,6 +198,9 @@ describe('UPlotConfigBuilder', () => { "drag": Object { "setScale": false, }, + "focus": Object { + "prox": 30, + }, "points": Object { "fill": [Function], "size": [Function], @@ -234,6 +274,9 @@ describe('UPlotConfigBuilder', () => { "drag": Object { "setScale": false, }, + "focus": Object { + "prox": 30, + }, "points": Object { "fill": [Function], "size": [Function], @@ -337,6 +380,9 @@ describe('UPlotConfigBuilder', () => { "drag": Object { "setScale": false, }, + "focus": Object { + "prox": 30, + }, "points": Object { "fill": [Function], "size": [Function], diff --git a/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.ts b/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.ts index ecc955f2d76..ad17b3795a2 100644 --- a/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.ts +++ b/packages/grafana-ui/src/components/uPlot/config/UPlotConfigBuilder.ts @@ -85,6 +85,9 @@ export class UPlotConfigBuilder { /*@ts-ignore*/ fill: (u, seriesIdx) => u.series[seriesIdx].points.stroke(u, seriesIdx), }, + focus: { + prox: 30, + }, }; defaultsDeep(config.cursor, cursorDefaults);