Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens][Agg based Gauge & Goal] Convert to Lens Agg based Gauge and Goal. #142838

Merged
merged 50 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
62d1d15
Added support of metric.
Kuznietsov Oct 4, 2022
92972c0
Fixed bundle size.
Kuznietsov Oct 4, 2022
ee60eca
Added percentage mode.
Kuznietsov Oct 4, 2022
4c3bb5c
Merge branch 'main' into convert-to-lens_agg-based-metric
Kuznietsov Oct 5, 2022
dc539fc
Added fix of snapshot.
Kuznietsov Oct 5, 2022
24acad5
Fixed convertMetricToColumns tests.
Kuznietsov Oct 5, 2022
ae47b7d
Added tests for percentageMode enabled in convertMetricToColumns
Kuznietsov Oct 5, 2022
b73664b
Updated snapshots of run_pipeline/basic.ts
Kuznietsov Oct 5, 2022
0d247c7
Fixed snapshots.
Kuznietsov Oct 5, 2022
409661e
Fixed types.
Kuznietsov Oct 5, 2022
8369a31
Fixed checks.
Kuznietsov Oct 5, 2022
e1f1c1a
Added tests for convertToColumnInPercentageMode.
Kuznietsov Oct 5, 2022
c1765c9
Added unit tests for convertToLens.
Kuznietsov Oct 5, 2022
d1e384b
Added tests for palette.
Kuznietsov Oct 5, 2022
0bf4eb6
Added tests for getPercentageModeConfig
Kuznietsov Oct 5, 2022
3b23749
Added tests for getConfiguration.
Kuznietsov Oct 5, 2022
bc8b690
Fixed invalid behavior.
Kuznietsov Oct 5, 2022
9ff7877
Added functional tests.
Kuznietsov Oct 5, 2022
bf3f452
Added validation for top_hit percentage mode support.
Kuznietsov Oct 5, 2022
f08bc77
Merge branch 'main' into convert-to-lens_agg-based-gauge
Kuznietsov Oct 5, 2022
587e719
Merge branch 'main' into convert-to-lens_agg-based-gauge
Kuznietsov Oct 6, 2022
fb02520
Refactoring for the purpose of code reusage.
Kuznietsov Oct 6, 2022
e98d59f
Fixed imports.
Kuznietsov Oct 6, 2022
69dc9dc
Added support of gauge.
Kuznietsov Oct 6, 2022
f65b7c5
Added color ranges and min/max support.
Kuznietsov Oct 6, 2022
5eb9382
Finished gauge configuration.
Kuznietsov Oct 7, 2022
242c18a
Added goal config support.
Kuznietsov Oct 7, 2022
a0a5c91
Fixed tests.
Kuznietsov Oct 7, 2022
2a7aca6
Fixed types.
Kuznietsov Oct 7, 2022
5eec23d
Fixed tests.
Kuznietsov Oct 7, 2022
dc608a7
Removed goal.
Kuznietsov Oct 7, 2022
dd07c20
Fixed types (linter warning).
Kuznietsov Oct 7, 2022
96c3c0d
Added tests for gauge convertToLens.
Kuznietsov Oct 7, 2022
bd5fca5
Added tests for getConfigurationForGauge.
Kuznietsov Oct 7, 2022
7a9d417
Added functional tests.
Kuznietsov Oct 7, 2022
65c3a0f
Merge branch 'main' into convert-to-lens_agg-based-gauge
kibanamachine Oct 10, 2022
31ad753
Merge branch 'main' into convert-to-lens_agg-based-gauge
kibanamachine Oct 10, 2022
d25aaac
Added convertToLens for goal.
Kuznietsov Oct 10, 2022
a3fc9ef
Fixed percentage mode of gauge.
Kuznietsov Oct 10, 2022
ad9f9f4
palette tests added.
Kuznietsov Oct 10, 2022
01770f4
Fixed types.
Kuznietsov Oct 10, 2022
a5b2f49
Added tests for goal.
Kuznietsov Oct 10, 2022
2b7985e
Added tests for goal.
Kuznietsov Oct 10, 2022
bdbc970
Merge branch 'main' into convert-to-lens_agg-based-gauge
Kuznietsov Oct 10, 2022
b220007
Added tests for goal.
Kuznietsov Oct 10, 2022
a60fd33
Merge branch 'main' into convert-to-lens_agg-based-gauge
stratoula Oct 11, 2022
10dfb1b
Added support of subtitle and tests.
Kuznietsov Oct 11, 2022
e7c8e89
Fixed the problem with siblings.
Kuznietsov Oct 11, 2022
f25bc57
Fixed tests.
Kuznietsov Oct 11, 2022
d5df1eb
Fixed problems with dataTypes.
Kuznietsov Oct 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const gaugeFunction = (): GaugeExpressionFunctionDefinition => ({
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
},
canNavigateToLens: Boolean(handlers?.variables?.canNavigateToLens),
},
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type GaugeInput = Datatable;
export interface GaugeExpressionProps {
data: Datatable;
args: GaugeArguments;
canNavigateToLens: boolean;
}

export interface GaugeRender {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe('GaugeComponent', function () {

beforeAll(async () => {
wrapperProps = {
canNavigateToLens: false,
data: createData(),
chartsThemeService,
args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export const gaugeRenderer: (
const visualizationType = extractVisualizationType(executionContext);

if (containerType && visualizationType) {
plugins.usageCollection?.reportUiCounter(containerType, METRIC_TYPE.COUNT, [
const events = [
`render_${visualizationType}_${type}`,
]);
config.canNavigateToLens ? `render_${visualizationType}_${type}_convertable` : undefined,
].filter<string>((event): event is string => Boolean(event));
plugins.usageCollection?.reportUiCounter(containerType, METRIC_TYPE.COUNT, events);
}

handlers.done();
Expand Down
23 changes: 18 additions & 5 deletions src/plugins/vis_types/gauge/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,26 @@
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["charts", "data", "expressions", "visualizations"],
"requiredBundles": ["visDefaultEditor"],
"optionalPlugins": ["expressionGauge"],
"extraPublicDirs": ["common/index"],
"requiredPlugins": [
"charts",
"data",
"expressions",
"visualizations",
"dataViews"
],
"requiredBundles": [
"visDefaultEditor",
"kibanaUtils"
],
"optionalPlugins": [
"expressionGauge"
],
"extraPublicDirs": [
"common/index"
],
"owner": {
"name": "Vis Editors",
"githubTeam": "kibana-vis-editors"
},
"description": "Contains the gauge chart implementation using the elastic-charts library. The goal is to eventually deprecate the old implementation and keep only this. Until then, the library used is defined by the Legacy charts library advanced setting."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { ColorSchemas } from '@kbn/charts-plugin/common';
import { CustomPaletteParams, PaletteOutput } from '@kbn/coloring';
import { getConfiguration } from './gauge';
import { GaugeVisParams } from '../../types';

const params: GaugeVisParams = {
addTooltip: false,
addLegend: false,
isDisplayWarning: true,
gauge: {
type: 'meter',
orientation: 'vertical',
alignment: 'automatic',
gaugeType: 'Arc',
scale: {
color: 'rgba(105,112,125,0.2)',
labels: false,
show: false,
},
gaugeStyle: 'Full',
extendRange: false,
backStyle: 'Full',
percentageMode: false,
percentageFormatPattern: '',
colorSchema: ColorSchemas.Greys,
colorsRange: [
{ type: 'range', from: 0, to: 100 },
{ type: 'range', from: 100, to: 200 },
],
labels: {},
invertColors: false,
style: {
bgFill: '',
bgColor: false,
labelColor: false,
subText: '',
fontSize: 10,
},
},
type: 'gauge',
};

describe('getConfiguration', () => {
const palette = {
name: 'custom',
params: { name: 'custom' },
type: 'palette',
} as PaletteOutput<CustomPaletteParams>;

test('shourd return correct configuration', () => {
const layerId = 'layer-id';
const metricAccessor = 'metric-id';
const minAccessor = 'min-accessor';
const maxAccessor = 'max-accessor';
expect(
getConfiguration(layerId, params, palette, {
metricAccessor,
minAccessor,
maxAccessor,
})
).toEqual({
colorMode: 'palette',
labelMajorMode: 'none',
labelMinor: undefined,
layerId: 'layer-id',
layerType: 'data',
maxAccessor: 'max-accessor',
metricAccessor: 'metric-id',
minAccessor: 'min-accessor',
palette: { name: 'custom', params: { name: 'custom' }, type: 'palette' },
shape: 'horizontalBullet',
ticksPosition: 'bands',
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { CustomPaletteParams, PaletteOutput } from '@kbn/coloring';
import { GaugeVisConfiguration } from '@kbn/visualizations-plugin/common';
import { GaugeVisParams } from '../../types';

export const getConfiguration = (
layerId: string,
params: GaugeVisParams,
palette: PaletteOutput<CustomPaletteParams> | undefined,
{
metricAccessor,
minAccessor,
maxAccessor,
}: {
metricAccessor: string;
minAccessor: string;
maxAccessor: string;
}
): GaugeVisConfiguration => {
const showLabels = Boolean(params.gauge.labels.show);
return {
layerId,
layerType: 'data',
palette,
metricAccessor,
minAccessor,
maxAccessor,
shape: 'horizontalBullet',
ticksPosition: 'bands',
labelMajorMode: showLabels ? 'auto' : 'none',
colorMode: palette ? 'palette' : 'none',
labelMinor: showLabels ? params.gauge.style.subText : undefined,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { ColorSchemas } from '@kbn/charts-plugin/common';
import { CustomPaletteParams, PaletteOutput } from '@kbn/coloring';
import { GaugeVisParams } from '../../types';
import { getConfiguration } from './goal';

const params: GaugeVisParams = {
addTooltip: false,
addLegend: false,
isDisplayWarning: true,
gauge: {
type: 'meter',
orientation: 'vertical',
alignment: 'automatic',
gaugeType: 'Arc',
scale: {
color: 'rgba(105,112,125,0.2)',
labels: false,
show: false,
},
gaugeStyle: 'Full',
extendRange: false,
backStyle: 'Full',
percentageMode: false,
percentageFormatPattern: '',
colorSchema: ColorSchemas.Greys,
colorsRange: [
{ type: 'range', from: 0, to: 100 },
{ type: 'range', from: 100, to: 200 },
],
labels: {},
invertColors: false,
style: {
bgFill: '',
bgColor: false,
labelColor: false,
subText: '',
fontSize: 10,
},
},
type: 'gauge',
};

describe('getConfiguration', () => {
const palette = {
name: 'custom',
params: { name: 'custom' },
type: 'palette',
} as PaletteOutput<CustomPaletteParams>;

test('shourd return correct configuration', () => {
const layerId = 'layer-id';
const metricAccessor = 'metric-id';
const breakdownByAccessor = 'bucket-id';
const metrics = [metricAccessor];
const buckets = [breakdownByAccessor];
const maxAccessor = 'max-accessor-id';
const collapseFn = 'sum';
expect(
getConfiguration(layerId, params, palette, {
metrics,
buckets,
maxAccessor,
columnsWithoutReferenced: [],
bucketCollapseFn: { [metricAccessor]: collapseFn },
})
).toEqual({
breakdownByAccessor,
collapseFn,
layerId,
layerType: 'data',
maxAccessor,
metricAccessor,
palette,
});
});
});
Loading