Skip to content

Commit

Permalink
[Gauge] Vis editors gauge legacy percent mode. (#126318)
Browse files Browse the repository at this point in the history
* Added legacy percentage mode to the gauge.

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
Kuznietsov and kibanamachine authored Mar 8, 2022
1 parent 5ad355e commit 720fbed
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 60 deletions.

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 @@ -180,6 +180,14 @@ export const gaugeFunction = (): GaugeExpressionFunctionDefinition => ({
defaultMessage: 'Specifies the mode of centralMajor',
}),
},
// used only in legacy gauge, consider it as @deprecated
percentageMode: {
types: ['boolean'],
default: false,
help: i18n.translate('expressionGauge.functions.gauge.percentageMode.help', {
defaultMessage: 'Enables relative precentage mode',
}),
},
ariaLabel: {
types: ['string'],
help: i18n.translate('expressionGauge.functions.gaugeChart.config.ariaLabel.help', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export interface GaugeState {
colorMode?: GaugeColorMode;
palette?: PaletteOutput<CustomPaletteParams>;
shape: GaugeShape;
/** @deprecated This field is deprecated and going to be removed in the futher release versions. */
percentageMode?: boolean;
}

export type GaugeArguments = GaugeState & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import type { ChartsPluginSetup } from '../../../../charts/public';
import type { ChartsPluginSetup, PaletteRegistry } from '../../../../charts/public';
import type { IFieldFormat, SerializedFieldFormat } from '../../../../field_formats/common';
import type { GaugeExpressionProps } from './expression_functions';

Expand All @@ -15,6 +15,7 @@ export type FormatFactory = (mapping?: SerializedFieldFormat) => IFieldFormat;
export type GaugeRenderProps = GaugeExpressionProps & {
formatFactory: FormatFactory;
chartsThemeService: ChartsPluginSetup['theme'];
paletteService: PaletteRegistry;
};

export interface ColorStop {
Expand Down

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 @@ -54,6 +54,7 @@ jest.mock('@elastic/charts', () => {
});

const chartsThemeService = chartPluginMock.createSetupContract().theme;
const paletteThemeService = chartPluginMock.createSetupContract().palettes;
const formatService = fieldFormatsServiceMock.createStartContract();
const args: GaugeArguments = {
labelMajor: 'Gauge',
Expand Down Expand Up @@ -81,12 +82,13 @@ const createData = (
describe('GaugeComponent', function () {
let wrapperProps: GaugeRenderProps;

beforeAll(() => {
beforeAll(async () => {
wrapperProps = {
data: createData(),
chartsThemeService,
args,
formatFactory: formatService.deserialize,
paletteService: await paletteThemeService.getPalettes(),
};
});

Expand Down
Loading

0 comments on commit 720fbed

Please sign in to comment.