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

[Pie] New implementation of the vislib pie chart with es-charts #83929

Merged
merged 193 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 155 commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
749bfb0
es lint fix
stratoula Nov 12, 2020
a3dcef1
Add formatter on the buckets labels
stratoula Nov 12, 2020
86a24f6
Merge branch 'master' into vislib-pie-replacement
stratoula Nov 16, 2020
a8b20f3
Config the new plugin, toggle tooltip
stratoula Nov 16, 2020
5016150
Aff filtering on slice click
stratoula Nov 16, 2020
0d9bb2e
minor fixes
stratoula Nov 16, 2020
464d6a3
Merge branch 'master' into vislib-pie-replacement
stratoula Nov 17, 2020
e916ea5
fix eslint error
stratoula Nov 18, 2020
cae76e2
Merge branch 'master' into vislib-pie-replacement
stratoula Nov 18, 2020
bcbfd69
use legacy palette for now
stratoula Nov 18, 2020
342f103
Add color picker to legend colors
stratoula Nov 19, 2020
49d78a7
Merge branch 'master' into vislib-pie-replacement
stratoula Nov 19, 2020
5407deb
Fix ts error
stratoula Nov 19, 2020
3422453
Add legend actions
stratoula Nov 20, 2020
a639d08
Merge branch 'master' into vislib-pie-replacement
stratoula Nov 20, 2020
f1ee283
Fix bug on Color Picker and remove local state as it is unecessary
stratoula Nov 20, 2020
2fd26cc
Fix some bugs on colorPicker
stratoula Nov 20, 2020
f640160
Merge with master and resolve conflicts
stratoula Nov 24, 2020
d73a598
Merge branch 'master' into vislib-pie-replacement
kibanamachine Nov 25, 2020
e5cfa42
Add setting for the user to select between the legacy palette or the …
stratoula Nov 25, 2020
e0bfe8d
Merge branch 'master' into vislib-pie-replacement
kibanamachine Nov 26, 2020
9483b1c
small enhancements, treat empty labels with (empty)
stratoula Nov 26, 2020
2ddcf2f
Fix color picker bugs with multiple layers
stratoula Nov 26, 2020
4d50e21
Merge branch 'master' into vislib-pie-replacement
kibanamachine Nov 30, 2020
c43dbe2
fixes on internationalization
stratoula Nov 30, 2020
931557f
Create migration script for pie chart and legacy palette
stratoula Nov 30, 2020
85be4fe
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 1, 2020
ca1ffb1
Add unit tests (wip) and a small refactoring
stratoula Dec 1, 2020
b76a8a8
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 2, 2020
8390ff7
Add unit tests and move some things to utils, useMemo and useCallback…
stratoula Dec 2, 2020
538019d
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 3, 2020
c7c1c00
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 4, 2020
1d205c4
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 7, 2020
328ef0e
Add jest config file
stratoula Dec 7, 2020
5ef0f70
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 8, 2020
20a7ecb
Fix jest test
stratoula Dec 8, 2020
885b1e4
fix api integration failure
stratoula Dec 8, 2020
eed093a
Merge with master and resolve conflicts
stratoula Dec 10, 2020
3c5761d
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 14, 2020
37cfe4f
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 15, 2020
85ecefa
Fix to_ast_esaggs for new pie plugin
stratoula Dec 15, 2020
f96296c
Close legendColorPicker popover when user clicks outside
stratoula Dec 15, 2020
b256e8d
Fix warning
stratoula Dec 15, 2020
cdc2693
merge with master and resolve conflicts
stratoula Dec 15, 2020
f8c48f9
Remove getter/setters and refactor
stratoula Dec 16, 2020
25ed4eb
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 16, 2020
a680be2
Remove kibanaUtils from pie plugin as it is not needed
stratoula Dec 16, 2020
f64cd07
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 17, 2020
9142934
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 18, 2020
365cf08
Add new values to the migration script
stratoula Dec 18, 2020
a5d0eae
Fix bug on not changing color for expty string
stratoula Dec 18, 2020
d89527c
remove from migration script as they don't need it
stratoula Dec 18, 2020
609994d
resolve conflict
stratoula Dec 21, 2020
4010a92
Fix editor settings for old and new implementation
stratoula Dec 21, 2020
bad9e48
fix uistate type
stratoula Dec 21, 2020
259b132
Disable split chart for the new plugin for now
stratoula Dec 21, 2020
0d15ad9
Remove temp folder
stratoula Dec 21, 2020
00069dd
Move translations to the pie plugin
stratoula Dec 21, 2020
425d7c4
Fix CI failures
stratoula Dec 21, 2020
bfc3b1b
Add unit test for the editor config
stratoula Dec 21, 2020
b3efd32
Types cleanup
stratoula Dec 21, 2020
ab268f2
Fix types vol2
stratoula Dec 21, 2020
9fbe7ce
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 22, 2020
efa5628
Minor improvements
stratoula Dec 22, 2020
3257bb9
Display data on the inspector
stratoula Dec 22, 2020
873cd03
Merge with master and resolve conflicts
stratoula Dec 22, 2020
5277f99
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 22, 2020
1194884
Merge with master and resolve conflicts
stratoula Dec 24, 2020
9c37f8f
Cleanup translations
stratoula Dec 24, 2020
a681c4c
Add telemetry for new editor pie options
stratoula Dec 24, 2020
b52b9a1
Merge branch 'master' into vislib-pie-replacement
kibanamachine Dec 29, 2020
7ea2335
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 4, 2021
040807c
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 5, 2021
2c8d259
Merge with master and resolve conflicts
stratoula Jan 7, 2021
0c5622f
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 11, 2021
ed95218
Fix missing translation
stratoula Jan 11, 2021
c5fbe48
Merge with master and resolve conflicts
stratoula Jan 12, 2021
e64bc34
Use Eui component to detect click outside the color picker popover
stratoula Jan 13, 2021
fe9830f
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 13, 2021
b16a4bd
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 13, 2021
2072459
Retrieve color picker from editor and syncColors on dashboard
stratoula Jan 13, 2021
0ecc168
Lazy load palette service
stratoula Jan 13, 2021
4cef2bc
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 14, 2021
cd2f7bb
Add the new plugin to ts references, fix tests, refactor
stratoula Jan 14, 2021
0fbdd09
Fix ci failure
stratoula Jan 14, 2021
663f641
Move charts library switch to vislib plugin
stratoula Jan 14, 2021
e81c6da
Remove cyclic dependencies
stratoula Jan 14, 2021
0eb519c
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 18, 2021
43b6ab6
Merge with master and resolve conflicts
stratoula Jan 20, 2021
6cfed08
Modify license headers
stratoula Jan 20, 2021
6b9a7f2
Move charts library switch to visualizations plugin
stratoula Jan 20, 2021
af6f43b
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 25, 2021
6fe906c
Fix i18n on the switch moved to visualizations plugin
stratoula Jan 25, 2021
0305e7c
Merge with master and resolve conflicts
stratoula Jan 26, 2021
76c93e1
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jan 28, 2021
2661888
Merge branch 'master' into vislib-pie-replacement
kibanamachine Feb 1, 2021
b96c86c
Merge branch 'master' into vislib-pie-replacement
stratoula Feb 4, 2021
e6eb71c
Merge with master and resolve conflicts
stratoula Feb 4, 2021
724cd3c
Update license
stratoula Feb 4, 2021
93c23d8
Merge with master and resolve conflicts
stratoula Feb 5, 2021
135db99
Merge branch 'master' into vislib-pie-replacement
kibanamachine Feb 8, 2021
17ee329
Merge branch 'master' into vislib-pie-replacement
kibanamachine Feb 11, 2021
7cd58f9
Merge with master and resolve conflicts
stratoula Feb 15, 2021
ca8be9f
Fix tests
stratoula Feb 15, 2021
9f03f34
Merge branch 'master' into vislib-pie-replacement
kibanamachine Feb 17, 2021
92d0bca
Merge branch 'master' into vislib-pie-replacement
kibanamachine Feb 22, 2021
f19035f
Fix bugs created by new charts version
stratoula Feb 22, 2021
37a7c57
Merge branch 'master' into vislib-pie-replacement
kibanamachine Feb 24, 2021
120c487
Merge with master and resolve conflicts
stratoula Mar 1, 2021
02e9469
Merge with master, resolve conflicts
stratoula Mar 16, 2021
f5c6c82
Fix the i18n switch problem
stratoula Mar 16, 2021
0ad94ab
Merge with master and resolve conflicts
stratoula Mar 17, 2021
8c55c58
Update the migration script
stratoula Mar 17, 2021
da1e8e1
Identify if colorIsOverwritten or not
stratoula Mar 17, 2021
e048f26
Merge with master and resolve conflicts
stratoula Mar 26, 2021
65edcd4
Merge with master and resolve conflicts
stratoula Mar 31, 2021
cea3b37
Small multiples, missing the click event
stratoula Apr 1, 2021
8d74a3f
Fixes the UX for small multiples part1
stratoula Apr 1, 2021
e227e08
Distinct colors per slice implementation
stratoula Apr 2, 2021
b1bd649
Merge with master and resolve conflicts
stratoula Apr 2, 2021
724eb34
Fix ts references problem
stratoula Apr 2, 2021
92fa497
Merge branch 'master' into vislib-pie-replacement
kibanamachine Apr 5, 2021
2b881f0
Fix some small multiples bugs
stratoula Apr 5, 2021
287b915
Add unit tests
stratoula Apr 5, 2021
90cced2
Merge with master, resolve conflicts, move migration for 7.14
stratoula Apr 12, 2021
f5b1787
Fix ts ref problem
stratoula Apr 13, 2021
978ca9a
Merge branch 'master' into vislib-pie-replacement
kibanamachine Apr 13, 2021
0dc931d
Merge with master and resolve conflicts
stratoula Apr 19, 2021
b324340
Fix TS problems caused by es-charts new version
stratoula Apr 19, 2021
3673e93
Update the sample pie visualizations with the new eui palette
stratoula Apr 19, 2021
0f8a34b
Merge branch 'master' into vislib-pie-replacement
kibanamachine Apr 20, 2021
0784c05
Allows filtering by the small multiples value
stratoula Apr 20, 2021
284c1ed
Apply sortPredicate on partition layers
stratoula Apr 21, 2021
c8a3180
Fix vilib test
stratoula Apr 21, 2021
f2a3c87
Enable functional tests for new plugin
stratoula Apr 22, 2021
cbb2e7f
Fix some functional tests
stratoula Apr 22, 2021
18212f1
Minor fix
stratoula Apr 23, 2021
4de7656
Merge with master and resolve conflicts
stratoula Apr 23, 2021
3bceb73
Fix functional tests
stratoula Apr 23, 2021
318b730
Fix dashboard tests
stratoula Apr 23, 2021
17e388f
Fix all dashboard tests
stratoula Apr 23, 2021
909cc73
Merge branch 'master' into vislib-pie-replacement
kibanamachine Apr 26, 2021
101c7db
Apply some improvements
stratoula Apr 26, 2021
613b141
Explicit params instead of visConfig Json
stratoula Apr 26, 2021
848fd76
Fix i18n failure
stratoula Apr 26, 2021
7809b38
Add top level setting
stratoula Apr 27, 2021
d304030
Minor fix
stratoula Apr 27, 2021
5cf97e7
Fix jest tests
stratoula Apr 27, 2021
a237705
Address PR comments
stratoula Apr 28, 2021
146731a
Fix i18n error
stratoula Apr 28, 2021
bebe3f6
fix functional test
stratoula Apr 28, 2021
c5d2eb2
Merge branch 'master' into vislib-pie-replacement
kibanamachine Apr 28, 2021
5332852
Merge branch 'master' into vislib-pie-replacement
kibanamachine Apr 29, 2021
54e3181
Add an icon tip on the distinct colors per slice switch
stratoula Apr 29, 2021
cda3a4b
Fix some of the PR comments
stratoula Apr 29, 2021
9994ced
Address more PR comments
stratoula Apr 29, 2021
4d58be4
Small fix
stratoula Apr 29, 2021
fd4cc61
Functional test
stratoula Apr 29, 2021
87d49ae
Merge with master and resolve conflicts
stratoula May 5, 2021
12abdd2
address some PR comments
stratoula May 5, 2021
1543312
Add padding to the pie container
stratoula May 5, 2021
a0087ec
Add a max width to the container
stratoula May 5, 2021
8f94677
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 10, 2021
e99c2e0
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 10, 2021
a34230d
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 12, 2021
2fd302a
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 14, 2021
8c30732
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 17, 2021
e96a5a1
Improve dashboard functional test
stratoula May 17, 2021
b928ef9
Move the labels expression function to the pie plugin
stratoula May 17, 2021
97b8562
Fix i18n
stratoula May 17, 2021
521501c
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 19, 2021
639dc5e
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 24, 2021
6bece80
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 26, 2021
79f6f75
Merge with master and resolve conflicts
stratoula May 27, 2021
5bb1ef2
Fix functional test
stratoula May 27, 2021
86b2e82
Apply PR comments
stratoula May 28, 2021
78cba13
Fix migration script to run for the byvalue panels
stratoula May 28, 2021
785f373
Do not forget to also add the migration to them embeddable too :D
stratoula May 28, 2021
a9d96e0
Fix distinct colors for IP range layer
stratoula May 28, 2021
a7c4baf
Remove console errors
stratoula May 28, 2021
bd7e2d8
Fix small mulitples colors with multiple layers
stratoula May 28, 2021
48410bb
Fix lint problem
stratoula May 28, 2021
bbb2205
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 31, 2021
daa9896
Merge branch 'master' into vislib-pie-replacement
kibanamachine May 31, 2021
b2982f4
Fix problems created from merging with master
stratoula May 31, 2021
6fec9f0
Merge with master and resolve conflicts
stratoula May 31, 2021
8ea3f60
Address PR comments
stratoula Jun 1, 2021
f81ef7f
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jun 2, 2021
c59349a
Change the config in order the pie chart to not appear so huge on the…
stratoula Jun 3, 2021
5e58f17
Address PR comments
stratoula Jun 3, 2021
d9c98a3
Change the max percentage digits to 4
stratoula Jun 3, 2021
6facbb5
Change the max size to 1000
stratoula Jun 3, 2021
b8355e8
Merge branch 'master' into vislib-pie-replacement
kibanamachine Jun 3, 2021
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 .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/src/plugins/vis_type_vega/ @elastic/kibana-app
/src/plugins/vis_type_vislib/ @elastic/kibana-app
/src/plugins/vis_type_xy/ @elastic/kibana-app
/src/plugins/vis_type_pie/ @elastic/kibana-app
/src/plugins/visualize/ @elastic/kibana-app
/src/plugins/visualizations/ @elastic/kibana-app
/packages/kbn-tinymath/ @elastic/kibana-app
Expand Down
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"visTypeVega": "src/plugins/vis_type_vega",
"visTypeVislib": "src/plugins/vis_type_vislib",
"visTypeXy": "src/plugins/vis_type_xy",
"visTypePie": "src/plugins/vis_type_pie",
"visualizations": "src/plugins/visualizations",
"visualize": "src/plugins/visualize",
"apmOss": "src/plugins/apm_oss",
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 @@ -261,6 +261,10 @@ The plugin exposes the static DefaultEditorController class to consume.
|Contains the metric visualization.


|{kib-repo}blob/{branch}/src/plugins/vis_type_pie/README.md[visTypePie]
|Contains the pie 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.


|{kib-repo}blob/{branch}/src/plugins/vis_type_table/README.md[visTypeTable]
|Contains the data table visualization, that allows presenting data in a simple table format.

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 @@ -89,6 +89,7 @@ pageLoadAssetSize:
visDefaultEditor: 50178
visTypeMarkdown: 30896
visTypeMetric: 42790
visTypePie: 34051
visTypeTable: 94934
visTypeTagcloud: 37575
visTypeTimelion: 68883
Expand Down
1 change: 1 addition & 0 deletions src/plugins/charts/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export { ChartsPluginSetup, ChartsPluginStart } from './plugin';

export * from './static';
export * from './services/palettes/types';
export { lightenColor } from './services/palettes/lighten_color';
export {
PaletteOutput,
CustomPaletteArguments,
Expand Down
31 changes: 23 additions & 8 deletions src/plugins/charts/public/static/components/color_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
EuiFlexGroup,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

import { lightenColor } from '../../services/palettes/lighten_color';
import './color_picker.scss';

export const legacyColors: string[] = [
Expand Down Expand Up @@ -105,6 +105,14 @@ interface ColorPickerProps {
* Callback for onKeyPress event
*/
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;
/**
* Optional define the series maxDepth
*/
maxDepth?: number;
/**
* Optional define the layer index
*/
layerIndex?: number;
}
const euiColors = euiPaletteColorBlind({ rotations: 4, order: 'group' });

Expand All @@ -115,6 +123,8 @@ export const ColorPicker = ({
useLegacyColors = true,
colorIsOverwritten = true,
onKeyDown,
maxDepth,
layerIndex,
}: ColorPickerProps) => {
const legendColors = useLegacyColors ? legacyColors : euiColors;

Expand Down Expand Up @@ -159,13 +169,18 @@ export const ColorPicker = ({
))}
</EuiFlexGroup>
</fieldset>
{legendColors.some((c) => c === selectedColor) && colorIsOverwritten && (
<EuiFlexItem grow={false}>
<EuiButtonEmpty size="s" onClick={(e: any) => onChange(null, e)}>
<FormattedMessage id="charts.colorPicker.clearColor" defaultMessage="Reset color" />
</EuiButtonEmpty>
</EuiFlexItem>
)}
{legendColors.some(
(c) =>
c === selectedColor ||
(layerIndex && maxDepth && lightenColor(c, layerIndex, maxDepth) === selectedColor)
) &&
colorIsOverwritten && (
<EuiFlexItem grow={false}>
<EuiButtonEmpty size="s" onClick={(e: any) => onChange(null, e)}>
<FormattedMessage id="charts.colorPicker.clearColor" defaultMessage="Reset color" />
</EuiButtonEmpty>
</EuiFlexItem>
)}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const getSavedObjects = (): SavedObject[] => [
defaultMessage: '[eCommerce] Sales by Gender',
}),
visState:
'{"title":"[eCommerce] Sales by Gender","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":true,"values":true,"last_level":true,"truncate":100}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"customer_gender","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
'{"title":"[eCommerce] Sales by Gender","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":true,"values":true,"last_level":true,"truncate":100},"palette":{"type":"palette","name":"default"}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"customer_gender","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
uiStateJSON: '{}',
description: '',
version: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const getSavedObjects = (): SavedObject[] => [
defaultMessage: '[Flights] Airline Carrier',
}),
visState:
'{"title":"[Flights] Airline Carrier","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":true,"values":true,"last_level":true,"truncate":100}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"Carrier","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
'{"title":"[Flights] Airline Carrier","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":true,"values":true,"last_level":true,"truncate":100},"palette":{"type":"palette","name":"default"}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"Carrier","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
uiStateJSON: '{"vis":{"legendOpen":false}}',
description: '',
version: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const getSavedObjects = (): SavedObject[] => [
defaultMessage: '[Logs] Visitors by OS',
}),
visState:
'{"title":"[Logs] Visitors by OS","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":true,"values":true,"last_level":true,"truncate":100}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"machine.os.keyword","otherBucket":true,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing","size":10,"order":"desc","orderBy":"1"}}]}',
'{"title":"[Logs] Visitors by OS","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":true,"values":true,"last_level":true,"truncate":100},"palette":{"type":"palette","name":"default"}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"machine.os.keyword","otherBucket":true,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing","size":10,"order":"desc","orderBy":"1"}}]}',
uiStateJSON: '{}',
description: '',
version: 1,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_type_pie/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Contains the pie 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
Expand Up @@ -6,6 +6,4 @@
* Side Public License, v 1.
*/

import { VisTypeXyServerPlugin } from './plugin';

export const plugin = () => new VisTypeXyServerPlugin();
export const DEFAULT_PERCENT_DECIMALS = 2;
13 changes: 13 additions & 0 deletions src/plugins/vis_type_pie/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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_type_pie'],
};
8 changes: 8 additions & 0 deletions src/plugins/vis_type_pie/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "visTypePie",
"version": "kibana",
"ui": true,
"requiredPlugins": ["charts", "data", "expressions", "visualizations", "usageCollection"],
"requiredBundles": ["visDefaultEditor"]
}

73 changes: 73 additions & 0 deletions src/plugins/vis_type_pie/public/__snapshots__/pie_fn.test.ts.snap

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

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

15 changes: 15 additions & 0 deletions src/plugins/vis_type_pie/public/chart.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.pieChart__wrapper,
.pieChart__container {
display: flex;
flex: 1 1 auto;
min-height: 0;
min-width: 0;
}

.pieChart__container {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
67 changes: 67 additions & 0 deletions src/plugins/vis_type_pie/public/components/chart_split.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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 React from 'react';
import { Accessor, AccessorFn, GroupBy, GroupBySort, SmallMultiples } from '@elastic/charts';
import { DatatableColumn } from '../../../expressions/public';
import { SplitDimensionParams } from '../types';

interface ChartSplitProps {
splitColumnAccessor?: Accessor | AccessorFn;
splitRowAccessor?: Accessor | AccessorFn;
splitDimension?: DatatableColumn;
}

const CHART_SPLIT_ID = '__pie_chart_split__';
export const SMALL_MULTIPLES_ID = '__pie_chart_sm__';

export const ChartSplit = ({
splitColumnAccessor,
splitRowAccessor,
splitDimension,
}: ChartSplitProps) => {
if (!splitColumnAccessor && !splitRowAccessor) return null;
let sort: GroupBySort = 'alphaDesc';
if (splitDimension?.meta?.params?.id === 'terms') {
const params = splitDimension?.meta?.sourceParams?.params as SplitDimensionParams;
sort = params?.order === 'asc' ? 'alphaAsc' : 'alphaDesc';
}

return (
<>
<GroupBy
id={CHART_SPLIT_ID}
by={(spec, datum) => {
const splitTypeAccessor = splitColumnAccessor || splitRowAccessor;
if (splitTypeAccessor) {
return typeof splitTypeAccessor === 'function'
? splitTypeAccessor(datum)
: datum[splitTypeAccessor];
}
return spec.id;
}}
sort={sort}
/>
<SmallMultiples
id={SMALL_MULTIPLES_ID}
splitVertically={splitRowAccessor ? CHART_SPLIT_ID : undefined}
splitHorizontally={splitColumnAccessor ? CHART_SPLIT_ID : undefined}
style={{
verticalPanelPadding: {
outer: 0.1,
inner: 0.1,
},
horizontalPanelPadding: {
outer: 0.1,
inner: 0.1,
},
}}
/>
</>
);
};
40 changes: 40 additions & 0 deletions src/plugins/vis_type_pie/public/editor/collections.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { LabelPositions, ValueFormats } from '../types';

export const getLabelPositions = [
{
text: i18n.translate('visTypePie.labelPositions.insideText', {
defaultMessage: 'Inside',
}),
value: LabelPositions.INSIDE,
},
{
text: i18n.translate('visTypePie.labelPositions.insideOrOutsideText', {
defaultMessage: 'Inside or outside',
}),
value: LabelPositions.DEFAULT,
},
];

export const getValuesFormats = [
{
text: i18n.translate('visTypePie.valuesFormats.percent', {
defaultMessage: 'Show percent',
}),
value: ValueFormats.PERCENT,
},
{
text: i18n.translate('visTypePie.valuesFormats.value', {
defaultMessage: 'Show value',
}),
value: ValueFormats.VALUE,
},
];
26 changes: 26 additions & 0 deletions src/plugins/vis_type_pie/public/editor/components/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 React, { lazy } from 'react';
import { VisEditorOptionsProps } from '../../../../visualizations/public';
import { PieVisParams, PieTypeProps } from '../../types';

const PieOptionsLazy = lazy(() => import('./pie'));

export const getPieOptions = ({
showElasticChartsOptions,
palettes,
trackUiMetric,
}: PieTypeProps) => (props: VisEditorOptionsProps<PieVisParams>) => (
<PieOptionsLazy
{...props}
palettes={palettes}
showElasticChartsOptions={showElasticChartsOptions}
trackUiMetric={trackUiMetric}
/>
);
Loading