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

[Gauge] Vis Type #126048

Merged
merged 36 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
064e917
Added transparent background
Kuznietsov Feb 18, 2022
adb0404
Added gauge/goal visType.
Kuznietsov Feb 18, 2022
e21f21a
Merge branch 'main' into vis_editors_gauge-integration
Kuznietsov Feb 21, 2022
6a8c677
Fixed palette, scale and types.
Kuznietsov Feb 21, 2022
6f309f0
Merge branch 'main' into vis_editors_gauge-integration
kibanamachine Feb 21, 2022
7afcbc6
updated tests
Kuznietsov Feb 21, 2022
247689f
Cleaned up the code.
Kuznietsov Feb 21, 2022
29e9835
Updated limits.
Kuznietsov Feb 21, 2022
eae8f8a
Set legacy chart as default.
Kuznietsov Feb 21, 2022
e0200bc
Removed deprecation message.
Kuznietsov Feb 21, 2022
b370834
Added percent format params, comming from visdimensions.
Kuznietsov Feb 21, 2022
2b8bbe8
Merge branch 'main' into gauge-transparent-background
kibanamachine Feb 21, 2022
ff70db1
Updated snapshot.
Kuznietsov Feb 21, 2022
a2f442c
Merge branch 'gauge-transparent-background' of github.com:Kunzetsov/k…
Kuznietsov Feb 21, 2022
6b07be8
Merge branch 'gauge-transparent-background' into vis_editors_gauge-in…
Kuznietsov Feb 21, 2022
c2e8bab
Added support of labels/sublabels.
Kuznietsov Feb 21, 2022
48bbd6b
Merge branch 'main' into vis_editors_gauge-integration
kibanamachine Feb 21, 2022
10d9440
Merge branch 'main' into vis_editors_gauge-integration
kibanamachine Feb 22, 2022
573a5fe
fixed vistype toast test.
Kuznietsov Feb 22, 2022
3d96912
fixed i18n.
Kuznietsov Feb 22, 2022
d5d70b9
Updated i18n label.
Kuznietsov Feb 22, 2022
2e1717f
Merge branch 'main' into vis_editors_gauge-integration
kibanamachine Feb 22, 2022
9d5c1e4
Added support of showElasticChartsOptions
Kuznietsov Feb 22, 2022
d5d50b9
Added autoextend ranges elastic charts tooltip.
Kuznietsov Feb 22, 2022
2b28506
The outline elastic-charts message added.
Kuznietsov Feb 22, 2022
4b00e2c
outline renaming and metric/buckets limitations
Kuznietsov Feb 22, 2022
b601cbc
Merge branch 'main' into vis_editors_gauge-integration
kibanamachine Feb 23, 2022
127b03e
Merge branch 'main' into vis_editors_gauge-integration
kibanamachine Feb 24, 2022
b1f15c4
Merge branch 'main' into vis_editors_gauge-integration
kibanamachine Feb 28, 2022
6c48ded
Merge branch 'main' into vis_editors_gauge-integration
Kuznietsov Mar 2, 2022
c6b54e7
Fixed type.
Kuznietsov Mar 2, 2022
9eb731d
reverted mistaken change of sample_vis.test.mocks.
Kuznietsov Mar 2, 2022
9a94282
Warning message added to gauge split chart.
Kuznietsov Mar 3, 2022
4fd9c74
Added warning message to the splitChart button at goal/gauge.
Kuznietsov Mar 3, 2022
272427b
Fixed warning message
Kuznietsov Mar 3, 2022
55180a6
Merge branch 'main' into vis_editors_gauge-integration
kibanamachine Mar 3, 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
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"usageCollection": "src/plugins/usage_collection",
"utils": "packages/kbn-securitysolution-utils/src",
"visDefaultEditor": "src/plugins/vis_default_editor",
"visTypeGauge": "src/plugins/vis_types/gauge",
"visTypeHeatmap": "src/plugins/vis_types/heatmap",
"visTypeMarkdown": "src/plugins/vis_type_markdown",
"visTypeMetric": "src/plugins/vis_types/metric",
Expand Down
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ It acts as a container for a particular visualization and options tabs. Contains
The plugin exposes the static DefaultEditorController class to consume.


|{kib-repo}blob/{branch}/src/plugins/vis_types/gauge[visTypeGauge]
|WARNING: Missing README.


|{kib-repo}blob/{branch}/src/plugins/vis_types/heatmap[visTypeHeatmap]
|WARNING: Missing README.

Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ pageLoadAssetSize:
expressionPartitionVis: 26338
sharedUX: 16225
ux: 20784
visTypeGauge: 24113
cloudSecurityPosture: 19109
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const PLUGIN_ID = 'expressionGauge';
export const PLUGIN_NAME = 'expressionGauge';

export type {
GaugeExpressionFunctionDefinition,
GaugeExpressionProps,
FormatFactory,
GaugeRenderProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Chart, Goal, Settings } from '@elastic/charts';
import { FormattedMessage } from '@kbn/i18n-react';
import type { CustomPaletteState } from '../../../../charts/public';
import { EmptyPlaceholder } from '../../../../charts/public';
import { isVisDimension } from '../../../../visualizations/common/utils';
import {
GaugeRenderProps,
GaugeLabelMajorMode,
Expand Down Expand Up @@ -234,17 +235,22 @@ export const GaugeComponent: FC<GaugeRenderProps> = memo(
/>
);
}
const customMetricFormatParams = isVisDimension(args.metric) ? args.metric.format : undefined;
const tableMetricFormatParams = metricColumn?.meta?.params?.params
? metricColumn?.meta?.params
: undefined;

const defaultMetricFormatParams = {
id: 'number',
params: {
pattern: max - min > 5 ? `0,0` : `0,0.0`,
},
};

const tickFormatter = formatFactory(
metricColumn?.meta?.params?.params
? metricColumn?.meta?.params
: {
id: 'number',
params: {
pattern: max - min > 5 ? `0,0` : `0,0.0`,
},
}
customMetricFormatParams ?? tableMetricFormatParams ?? defaultMetricFormatParams
);

const colors = palette?.params?.colors ? normalizeColors(palette.params, min, max) : undefined;
const bands: number[] = (palette?.params as CustomPaletteState)
? normalizeBands(args.palette?.params as CustomPaletteState, { min, max })
Expand Down
9 changes: 9 additions & 0 deletions src/plugins/vis_types/gauge/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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.
*/

export const LEGACY_GAUGE_CHARTS_LIBRARY = 'visualization:visualize:legacyGaugeChartsLibrary';
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
* Side Public License, v 1.
*/

import { VisTypeDefinition } from 'src/plugins/visualizations/public';
import { gaugeVisTypeDefinition } from './gauge';
import { goalVisTypeDefinition } from './goal';
import { schema, TypeOf } from '@kbn/config-schema';

export { pieVisTypeDefinition } from './pie';
export const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
});

export const visLibVisTypeDefinitions: Array<VisTypeDefinition<any>> = [
gaugeVisTypeDefinition,
goalVisTypeDefinition,
];
export type ConfigSchema = TypeOf<typeof configSchema>;
18 changes: 18 additions & 0 deletions src/plugins/vis_types/gauge/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/src/plugins/vis_types/gauge'],
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/vis_types/gauge',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/src/plugins/vis_types/gauge/{common,public,server}/**/*.{ts,tsx}',
],
};
16 changes: 16 additions & 0 deletions src/plugins/vis_types/gauge/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "visTypeGauge",
"version": "1.0.0",
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["charts", "data", "expressions", "visualizations"],
"requiredBundles": ["visDefaultEditor"],
"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."
}

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 @@ -7,21 +7,18 @@
*/

import { i18n } from '@kbn/i18n';

import { colorSchemas } from '../../../../charts/public';
import { getPositions, getScaleTypes } from '../../../xy/public';

import { Alignment, GaugeType } from '../types';

export const getGaugeTypes = () => [
{
text: i18n.translate('visTypeVislib.gauge.gaugeTypes.arcText', {
text: i18n.translate('visTypeGauge.gauge.gaugeTypes.arcText', {
defaultMessage: 'Arc',
}),
value: GaugeType.Arc,
},
{
text: i18n.translate('visTypeVislib.gauge.gaugeTypes.circleText', {
text: i18n.translate('visTypeGauge.gauge.gaugeTypes.circleText', {
defaultMessage: 'Circle',
}),
value: GaugeType.Circle,
Expand All @@ -30,19 +27,19 @@ export const getGaugeTypes = () => [

export const getAlignments = () => [
{
text: i18n.translate('visTypeVislib.gauge.alignmentAutomaticTitle', {
text: i18n.translate('visTypeGauge.gauge.alignmentAutomaticTitle', {
defaultMessage: 'Automatic',
}),
value: Alignment.Automatic,
},
{
text: i18n.translate('visTypeVislib.gauge.alignmentHorizontalTitle', {
text: i18n.translate('visTypeGauge.gauge.alignmentHorizontalTitle', {
defaultMessage: 'Horizontal',
}),
value: Alignment.Horizontal,
},
{
text: i18n.translate('visTypeVislib.gauge.alignmentVerticalTitle', {
text: i18n.translate('visTypeGauge.gauge.alignmentVerticalTitle', {
defaultMessage: 'Vertical',
}),
value: Alignment.Vertical,
Expand All @@ -54,9 +51,3 @@ export const getGaugeCollections = () => ({
alignments: getAlignments(),
colorSchemas,
});

export const getHeatmapCollections = () => ({
legendPositions: getPositions(),
scales: getScaleTypes(),
colorSchemas,
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ import React, { useCallback } from 'react';
import { EuiSpacer } from '@elastic/eui';

import { VisEditorOptionsProps } from 'src/plugins/visualizations/public';
import { GaugeVisParams } from '../../../gauge';
import { GaugeTypeProps, GaugeVisParams } from '../../../types';
import { RangesPanel } from './ranges_panel';
import { StylePanel } from './style_panel';
import { LabelsPanel } from './labels_panel';

export type GaugeOptionsInternalProps = VisEditorOptionsProps<GaugeVisParams> & {
export interface GaugeOptionsProps extends VisEditorOptionsProps<GaugeVisParams>, GaugeTypeProps {}

export type GaugeOptionsInternalProps = GaugeOptionsProps & {
setGaugeValue: <T extends keyof GaugeVisParams['gauge']>(
paramName: T,
value: GaugeVisParams['gauge'][T]
) => void;
};

function GaugeOptions(props: VisEditorOptionsProps<GaugeVisParams>) {
function GaugeOptions(props: GaugeOptionsProps) {
const { stateParams, setValue } = props;

const setGaugeValue: GaugeOptionsInternalProps['setGaugeValue'] = useCallback(
Expand All @@ -37,13 +39,9 @@ function GaugeOptions(props: VisEditorOptionsProps<GaugeVisParams>) {
return (
<>
<StylePanel {...props} setGaugeValue={setGaugeValue} />

<EuiSpacer size="s" />

<RangesPanel {...props} setGaugeValue={setGaugeValue} />

<EuiSpacer size="s" />

<LabelsPanel {...props} setGaugeValue={setGaugeValue} />
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ function LabelsPanel({ stateParams, setValue, setGaugeValue }: GaugeOptionsInter
<EuiTitle size="xs">
<h3>
<FormattedMessage
id="visTypeVislib.controls.gaugeOptions.labelsTitle"
id="visTypeGauge.controls.gaugeOptions.labelsTitle"
defaultMessage="Labels"
/>
</h3>
</EuiTitle>
<EuiSpacer size="s" />

<SwitchOption
label={i18n.translate('visTypeVislib.controls.gaugeOptions.showLabelsLabel', {
label={i18n.translate('visTypeGauge.controls.gaugeOptions.showLabelsLabel', {
defaultMessage: 'Show labels',
})}
paramName="show"
Expand All @@ -40,7 +40,7 @@ function LabelsPanel({ stateParams, setValue, setGaugeValue }: GaugeOptionsInter

<TextInputOption
disabled={!stateParams.gauge.labels.show}
label={i18n.translate('visTypeVislib.controls.gaugeOptions.subTextLabel', {
label={i18n.translate('visTypeGauge.controls.gaugeOptions.subTextLabel', {
defaultMessage: 'Sub label',
})}
paramName="subText"
Expand Down
Loading