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

[PieVis] Chart expressions pie. #121612

Merged
merged 25 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d13df0b
Moved pie_vis to the other.
Kuznietsov Dec 17, 2021
32a2a81
Added semicolon.
Kuznietsov Dec 17, 2021
c5c41a6
Fixed check errors.
Kuznietsov Dec 20, 2021
4c40252
Removed not used types.
Kuznietsov Dec 20, 2021
6ef8429
Changed docs.
Kuznietsov Dec 20, 2021
282c017
Fixed labels.
Kuznietsov Dec 20, 2021
b01e118
Fixed more translation labels.
Kuznietsov Dec 20, 2021
3231f72
Merge branch 'main' into charts_expressions-pie
Kuznietsov Dec 20, 2021
e54c816
Removed own types and replaced by `expression_pie`.
Kuznietsov Dec 20, 2021
a363fb3
Changed types of buildExpressionFunction.
Kuznietsov Dec 20, 2021
7faa2b6
Added limits and extraPublicDir.
Kuznietsov Dec 20, 2021
604f497
Fixed i18n checks.
Kuznietsov Dec 20, 2021
1f9d54c
Fixes.
Kuznietsov Dec 20, 2021
90dd2ee
More fixes.
Kuznietsov Dec 20, 2021
c300657
Fixed translations checks.
Kuznietsov Dec 21, 2021
457e4f8
More translation fixes.
Kuznietsov Dec 21, 2021
2160608
Merge branch 'main' into charts_expressions-pie
kibanamachine Dec 21, 2021
4662d77
Fixed Arguments type of pie_labels.
Kuznietsov Dec 22, 2021
25c9e6a
Merge branch 'main' into charts_expressions-pie
kibanamachine Dec 22, 2021
dba6957
Added codeowners to expression_pie.
Kuznietsov Dec 23, 2021
3f684a4
Merge branch 'main' into charts_expressions-pie
kibanamachine Dec 24, 2021
3eac0c6
Merge branch 'main' into charts_expressions-pie
kibanamachine Dec 28, 2021
9785423
Merge branch 'main' into charts_expressions-pie
kibanamachine Jan 4, 2022
0d63551
Addressed comments about unused deps.
Kuznietsov Jan 4, 2022
16cbd77
Fixed not used imports/refs.
Kuznietsov Jan 4, 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 @@ -32,6 +32,7 @@
"expressionGauge": "src/plugins/chart_expressions/expression_gauge",
"expressionTagcloud": "src/plugins/chart_expressions/expression_tagcloud",
"expressionMetricVis": "src/plugins/chart_expressions/expression_metric",
"expressionPie": "src/plugins/chart_expressions/expression_pie",
"inputControl": "src/plugins/input_control_vis",
"inspector": "src/plugins/inspector",
"inspectorViews": "src/legacy/core_plugins/inspector_views",
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 @@ -114,6 +114,10 @@ This API doesn't support angular, for registering angular dev tools, bootstrap a
|Expression MetricVis plugin adds a metric renderer and function to the expression plugin. The renderer will display the metric chart.


|{kib-repo}blob/{branch}/src/plugins/chart_expressions/expression_pie/README.md[expressionPie]
|Expression Pie plugin adds a pie renderer and function to the expression plugin. The renderer will display the Pie chart.


|{kib-repo}blob/{branch}/src/plugins/expression_repeat_image/README.md[expressionRepeatImage]
|Expression Repeat Image plugin adds a repeatImage function to the expression plugin and an associated renderer. The renderer will display the given image in mutliple instances.

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 @@ -119,3 +119,4 @@ pageLoadAssetSize:
visTypeHeatmap: 25340
screenshotting: 17017
expressionGauge: 25000
expressionPie: 26338
9 changes: 9 additions & 0 deletions src/plugins/chart_expressions/expression_pie/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# expressionPie

Expression Pie plugin adds a `pie` renderer and function to the expression plugin. The renderer will display the `Pie` chart.

---

## Development

See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment.
16 changes: 16 additions & 0 deletions src/plugins/chart_expressions/expression_pie/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 PLUGIN_ID = 'expressionPie';
export const PLUGIN_NAME = 'expressionPie';

export const PIE_VIS_EXPRESSION_NAME = 'pie_vis';
export const PIE_LABELS_VALUE = 'pie_labels_value';
export const PIE_LABELS_FUNCTION = 'pie_labels';

export const DEFAULT_PERCENT_DECIMALS = 2;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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 { pieVisFunction } from './pie_vis_function';
export { pieLabelsFunction } from './pie_labels_function';
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
*/

import { i18n } from '@kbn/i18n';
import {
ExpressionFunctionDefinition,
Datatable,
ExpressionValueBoxed,
} from '../../../../expressions/public';
import { ExpressionFunctionDefinition, Datatable } from '../../../../expressions/common';
import { PIE_LABELS_FUNCTION, PIE_LABELS_VALUE } from '../constants';
import { ExpressionValuePieLabels } from '../types/expression_functions';

interface Arguments {
show: boolean;
Expand All @@ -23,84 +21,71 @@ interface Arguments {
percentDecimals: number;
}

export type ExpressionValuePieLabels = ExpressionValueBoxed<
'pie_labels',
{
show: boolean;
position: string;
values: boolean;
truncate: number | null;
valuesFormat: string;
last_level: boolean;
percentDecimals: number;
}
>;

export const pieLabels = (): ExpressionFunctionDefinition<
'pielabels',
export const pieLabelsFunction = (): ExpressionFunctionDefinition<
typeof PIE_LABELS_FUNCTION,
Datatable | null,
Arguments,
ExpressionValuePieLabels
> => ({
name: 'pielabels',
help: i18n.translate('visTypePie.function.pieLabels.help', {
name: PIE_LABELS_FUNCTION,
help: i18n.translate('expressionPie.pieLabels.function.help', {
defaultMessage: 'Generates the pie labels object',
}),
type: 'pie_labels',
type: PIE_LABELS_VALUE,
args: {
show: {
types: ['boolean'],
help: i18n.translate('visTypePie.function.pieLabels.show.help', {
help: i18n.translate('expressionPie.pieLabels.function.args.show.help', {
defaultMessage: 'Displays the pie labels',
}),
required: true,
},
position: {
types: ['string'],
default: 'default',
help: i18n.translate('visTypePie.function.pieLabels.position.help', {
help: i18n.translate('expressionPie.pieLabels.function.args.position.help', {
defaultMessage: 'Defines the label position',
}),
},
values: {
types: ['boolean'],
help: i18n.translate('visTypePie.function.pieLabels.values.help', {
help: i18n.translate('expressionPie.pieLabels.function.args.values.help', {
defaultMessage: 'Displays the values inside the slices',
}),
default: true,
},
percentDecimals: {
types: ['number'],
help: i18n.translate('visTypePie.function.pieLabels.percentDecimals.help', {
help: i18n.translate('expressionPie.pieLabels.function.args.percentDecimals.help', {
defaultMessage: 'Defines the number of decimals that will appear on the values as percent',
}),
default: 2,
},
lastLevel: {
types: ['boolean'],
help: i18n.translate('visTypePie.function.pieLabels.lastLevel.help', {
help: i18n.translate('expressionPie.pieLabels.function.args.lastLevel.help', {
defaultMessage: 'Show top level labels only',
}),
default: true,
},
truncate: {
types: ['number', 'null'],
help: i18n.translate('visTypePie.function.pieLabels.truncate.help', {
types: ['number'],
help: i18n.translate('expressionPie.pieLabels.function.args.truncate.help', {
defaultMessage: 'Defines the number of characters that the slice value will display',
}),
default: null,
},
valuesFormat: {
types: ['string'],
default: 'percent',
help: i18n.translate('visTypePie.function.pieLabels.valuesFormat.help', {
help: i18n.translate('expressionPie.pieLabels.function.args.valuesFormat.help', {
defaultMessage: 'Defines the format of the values',
}),
},
},
fn: (context, args) => {
return {
type: 'pie_labels',
type: PIE_LABELS_VALUE,
show: args.show,
position: args.position,
percentDecimals: args.percentDecimals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
* Side Public License, v 1.
*/

import { functionWrapper } from '../../../expressions/common/expression_functions/specs/tests/utils';
import { createPieVisFn } from './pie_fn';
import { PieVisConfig } from './types';
import { Datatable } from '../../../expressions/common/expression_types/specs';
import { EMPTY_SIZE_RATIOS } from './editor/constants';
import { functionWrapper } from '../../../../expressions/common/expression_functions/specs/tests/utils';
import { PieVisConfig, EmptySizeRatios } from '../types/expression_renderers';
import { pieVisFunction } from './pie_vis_function';
import { Datatable } from '../../../../expressions/common/expression_types/specs';

describe('interpreter/functions#pie', () => {
const fn = functionWrapper(createPieVisFn());
const fn = functionWrapper(pieVisFunction());
const context = {
type: 'datatable',
rows: [{ 'col-0-1': 0 }],
columns: [{ id: 'col-0-1', name: 'Count' }],
} as unknown as Datatable;

const visConfig = {
addTooltip: true,
addLegend: true,
legendPosition: 'right',
isDonut: true,
emptySizeRatio: EMPTY_SIZE_RATIOS.SMALL,
emptySizeRatio: EmptySizeRatios.SMALL,
nestedLegend: true,
truncateLegend: true,
maxLegendLines: true,
Expand Down
Loading