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

[XY] Support vis_dimension type for accessors #129612

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
9388bba
added xy plugin.
Kuznietsov Mar 8, 2022
8df9659
Merge branch 'main' into chart_expressions-xy
kibanamachine Mar 9, 2022
ab72728
Added expressionXY limits.
Kuznietsov Mar 9, 2022
5747322
Merge branch 'chart_expressions-xy' of github.com:Kunzetsov/kibana in…
Kuznietsov Mar 9, 2022
b4ee9c1
Added xy expression functions to the expression_xy plugin.
Kuznietsov Mar 10, 2022
400845d
Moved xy to a separate plugin.
Kuznietsov Mar 11, 2022
b2090f3
Small refactoring.
Kuznietsov Mar 11, 2022
33a06fa
Fixed types.
Kuznietsov Mar 14, 2022
d94fa4f
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 14, 2022
663e093
Fixed import of scss.
Kuznietsov Mar 14, 2022
cbffe77
Fixed imports.
Kuznietsov Mar 14, 2022
389f933
Added required plugins.
Kuznietsov Mar 14, 2022
90aa97a
Fixed import
Kuznietsov Mar 14, 2022
1d3a264
Fixed types.
Kuznietsov Mar 14, 2022
a78d45d
Changed expression names.
Kuznietsov Mar 14, 2022
35cab91
Fixed bugs, caused by the refactoring process.
Kuznietsov Mar 14, 2022
847b3c4
Merge branch 'main' into chart_expressions-xy
kibanamachine Mar 15, 2022
ed7f8ea
Fixed lens snapshots.
Kuznietsov Mar 15, 2022
b6daa5d
Removed new line.
Kuznietsov Mar 15, 2022
bda6524
Merge branch 'chart_expressions-xy' of github.com:Kunzetsov/kibana in…
Kuznietsov Mar 15, 2022
c8d40fe
Fixed xy_chart tests.
Kuznietsov Mar 15, 2022
5fed60c
Added lazy loading for xy chart.
Kuznietsov Mar 15, 2022
dc195b2
Fixed xy chart test.
Kuznietsov Mar 15, 2022
d39681f
Fixed broken chart selectors.
Kuznietsov Mar 16, 2022
b901d68
Fixed dashboard tests.
Kuznietsov Mar 16, 2022
d327dfe
dashboard test fixed.
Kuznietsov Mar 16, 2022
b500961
Fixed heatmap vis.
Kuznietsov Mar 16, 2022
7a25b74
Smokescreen test fixed.
Kuznietsov Mar 16, 2022
0004794
more fixes.
Kuznietsov Mar 16, 2022
fc8c0b3
async dashboard tests fixed.
Kuznietsov Mar 16, 2022
98454ad
Fixed xy smokescreen tests selectors.
Kuznietsov Mar 16, 2022
05cccac
fixed show_underlying_data tests.
Kuznietsov Mar 16, 2022
bcf5201
Updated snapshots.
Kuznietsov Mar 16, 2022
99dc773
updated limits.
Kuznietsov Mar 16, 2022
94a5850
Fixed more selectors
Kuznietsov Mar 16, 2022
bfea6f1
Fixed persistent context test.
Kuznietsov Mar 16, 2022
7cb4db4
Fixed some more test at ml.
Kuznietsov Mar 16, 2022
98e8661
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 16, 2022
5ea9cc5
Fixed types and imports
Kuznietsov Mar 16, 2022
4f72658
Fixed handlers.inspectorAdapters.tables.logDatatable
Kuznietsov Mar 16, 2022
ee4ec20
Fixed logDatatable
Kuznietsov Mar 17, 2022
e72005c
Translations fixed.
Kuznietsov Mar 17, 2022
902972d
Fixed "Visualize App ... cleans filters and query" test.
Kuznietsov Mar 17, 2022
05b0f8d
Fixed "lens disable auto-apply tests" test.
Kuznietsov Mar 17, 2022
cae1e75
Updated dashboard tests.
Kuznietsov Mar 17, 2022
00c7e28
Fixed translations.
Kuznietsov Mar 17, 2022
0ad3793
Expression tests fixed.
Kuznietsov Mar 17, 2022
2fbe81f
Cleaned up expression_xy.
Kuznietsov Mar 17, 2022
e9c497f
cleaned up lens xy_visualization.
Kuznietsov Mar 17, 2022
ea299ec
fixed more tests.
Kuznietsov Mar 17, 2022
9ea2cbb
Fix of tsvb.
Kuznietsov Mar 17, 2022
46edc6b
Fixed more tests.
Kuznietsov Mar 17, 2022
672885c
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 17, 2022
f109200
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 17, 2022
498b34e
Fixed xy chart limits.
Kuznietsov Mar 18, 2022
eeefc8b
Merge branch 'chart_expressions-xy' of github.com:Kunzetsov/kibana in…
Kuznietsov Mar 18, 2022
e00f089
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 18, 2022
4996ea6
Fixed new tests.
Kuznietsov Mar 18, 2022
97bb678
Fixed types.
Kuznietsov Mar 18, 2022
df91d70
Added extended layers expressions.
Kuznietsov Mar 18, 2022
f91c8d5
Merge branch 'main' into chart_expressions-xy
kibanamachine Mar 20, 2022
0b6db50
Merge branch 'main' into chart_expressions-xy
kibanamachine Mar 21, 2022
d3065be
Added support of tables at layers.
Kuznietsov Mar 21, 2022
f49d5f4
Fixed tests.
Kuznietsov Mar 22, 2022
f45c81c
Fixed more tests.
Kuznietsov Mar 22, 2022
eb78296
Fixed lens types.
Kuznietsov Mar 22, 2022
bb91aee
Added tables to layers.
Kuznietsov Mar 23, 2022
3e6d15a
Checks fixed.
Kuznietsov Mar 23, 2022
ac86ab9
updated tests.
Kuznietsov Mar 23, 2022
75b2e91
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 23, 2022
5c9f160
Merge branch 'chart_expressions-xy' into chart_expressions-xy-extende…
Kuznietsov Mar 24, 2022
fe16d49
Fixed types.
Kuznietsov Mar 24, 2022
902dae6
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 24, 2022
21e34b4
First try to fix merge conflicts.
Kuznietsov Mar 24, 2022
9cc22c8
Fixed annotatations.
Kuznietsov Mar 25, 2022
a99a223
Fixed types.
Kuznietsov Mar 25, 2022
b553456
Updated snapshots
Kuznietsov Mar 25, 2022
60f5645
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 25, 2022
dec0d18
Fixed tests.
Kuznietsov Mar 25, 2022
628ade6
Fixed dependencies.
Kuznietsov Mar 25, 2022
cc63956
Fixed i18n.
Kuznietsov Mar 25, 2022
0e4092d
Moved XY state types to lens.
Kuznietsov Mar 25, 2022
ef30205
Fixed more types.
Kuznietsov Mar 25, 2022
f29bdcf
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 28, 2022
8139986
Update src/plugins/chart_expressions/expression_xy/README.md
Kuznietsov Mar 28, 2022
8307b73
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Mar 28, 2022
27af05d
Merge branch 'chart_expressions-xy' into chart_expressions-xy-extende…
Kuznietsov Mar 28, 2022
500fb78
Removed yConfig from *Layers types
Kuznietsov Mar 28, 2022
839b023
Fixed styles.
Kuznietsov Mar 28, 2022
b61e59a
Fixed types.
Kuznietsov Mar 28, 2022
53a6659
Removed not used utils and styles.
Kuznietsov Mar 28, 2022
490159a
Merge branch 'main' into chart_expressions-xy
Kuznietsov Mar 28, 2022
38982d7
Merge branch 'chart_expressions-xy' into chart_expressions-xy-extende…
Kuznietsov Mar 29, 2022
73df8aa
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Mar 29, 2022
65f9520
Fixed types and tests.
Kuznietsov Mar 29, 2022
9a97062
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Mar 29, 2022
d7a014a
updated size.
Kuznietsov Mar 29, 2022
1563ea0
Added right behavior, related to the tables, comming from the express…
Kuznietsov Mar 30, 2022
363578b
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Mar 30, 2022
5e99314
Fixed reference lines.
Kuznietsov Mar 31, 2022
69eb3fd
Fixed jsdoc.
Kuznietsov Mar 31, 2022
a80a660
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Mar 31, 2022
ed03e2c
Added annotations to layeredXyVIs.
Kuznietsov Apr 1, 2022
c441652
Fixed limits.
Kuznietsov Apr 1, 2022
b200e37
Refactored the implementation to be reusable.
Kuznietsov Apr 1, 2022
27f44e2
Merge branch 'main' into chart_expressions-xy-extended_layers
kibanamachine Apr 4, 2022
8c2ea64
Fixed undefined layers.
Kuznietsov Apr 4, 2022
fb370d9
Fixed empty arrays problems.
Kuznietsov Apr 5, 2022
10c85fe
Fixed input translations and removed not used arguments.
Kuznietsov Apr 5, 2022
bb91cf8
Fixed missing required args error, and added required to arguments.
Kuznietsov Apr 5, 2022
a5d15e4
Simplified expression configuration.
Kuznietsov Apr 5, 2022
7bb36b0
Added strict to all the expressions.
Kuznietsov Apr 5, 2022
7979799
refactored code, according to the nit.
Kuznietsov Apr 5, 2022
8670649
Support visdimension type for accessors in data_layer and reference_l…
VladLasitsa Apr 6, 2022
0174908
Fix checks
VladLasitsa Apr 6, 2022
595ace3
Moved dataLayer to the separate component.
Kuznietsov Apr 6, 2022
1baee1b
Fixed jest tests.
Kuznietsov Apr 7, 2022
a78a466
Fixed tests.
Kuznietsov Apr 7, 2022
a77a034
Merge remote-tracking branch 'Kunzetsov/chart_expressions-xy-extended…
VladLasitsa Apr 7, 2022
f658bda
Some updates
VladLasitsa Apr 7, 2022
5c89811
Refactored dataLayers helpers and xy_chart.
Kuznietsov Apr 7, 2022
a97144b
Merge remote-tracking branch 'Kunzetsov/chart_expressions-xy-extended…
VladLasitsa Apr 7, 2022
b43a793
More fixes of the expression
Kuznietsov Apr 7, 2022
5f661b0
Fixed tests and snapshots.
Kuznietsov Apr 8, 2022
0b15a32
Icons at annotations and reference lines are strict.
Kuznietsov Apr 8, 2022
4ae62c6
Fix CI
VladLasitsa Apr 8, 2022
7bc0f95
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Apr 12, 2022
c17026f
axis extent validation added.
Kuznietsov Apr 12, 2022
17ea44f
Added checks to the legend config.
Kuznietsov Apr 12, 2022
3111467
fillOpacity usage validation is added.
Kuznietsov Apr 12, 2022
bd282eb
Fixed valueLabels argument options. Removed not used. Added validatio…
Kuznietsov Apr 12, 2022
d35c9eb
Removed not used tests and imports.
Kuznietsov Apr 12, 2022
2fb11f4
Fixed valueLabels and added migrations.
Kuznietsov Apr 13, 2022
54e1b66
Fixed type checks.
Kuznietsov Apr 13, 2022
dbd4a8f
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Apr 13, 2022
e4a40dc
Added test for the migrations.
Kuznietsov Apr 13, 2022
05f854f
Fixed imports.
Kuznietsov Apr 13, 2022
e50bc1f
Fixed types
Kuznietsov Apr 13, 2022
2f74299
Fixed i18n checks.
Kuznietsov Apr 14, 2022
786bbf1
Merge branch 'main' into chart_expressions-xy-extended_layers
kibanamachine Apr 14, 2022
6def533
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Apr 15, 2022
f5b4aee
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Apr 18, 2022
02ba394
Fixed imports and types.
Kuznietsov Apr 18, 2022
dfccec6
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 18, 2022
acabb8f
Update src/plugins/chart_expressions/expression_xy/common/expression_…
Kuznietsov Apr 19, 2022
435f89a
Removed extra extends.
Kuznietsov Apr 19, 2022
eec1c42
Update src/plugins/chart_expressions/expression_xy/common/expression_…
Kuznietsov Apr 19, 2022
471546e
Added guard.
Kuznietsov Apr 19, 2022
d19a331
Merge branch 'chart_expressions-xy-extended_layers' of github.com:Kun…
Kuznietsov Apr 19, 2022
b52c1b5
Fixed the code duplication.
Kuznietsov Apr 19, 2022
844c7b1
Removed table from the annotation layer.
Kuznietsov Apr 19, 2022
612ce22
Changed the `convertActiveDataFromIndexesToLayers` location.
Kuznietsov Apr 19, 2022
9d63b48
Added tests for convertActiveDataFromIndexesToLayers
Kuznietsov Apr 19, 2022
a947ff7
Reduced the bundle size a little bit.
Kuznietsov Apr 19, 2022
9eaecc1
Reused strings and args.
Kuznietsov Apr 19, 2022
7a8c452
Refactored expression functions. Added asynchronous behavior.
Kuznietsov Apr 19, 2022
3c4a3dd
Fixed tests.
Kuznietsov Apr 19, 2022
04c5e6d
Updated limits.
Kuznietsov Apr 19, 2022
1310c15
Updated the limit.
Kuznietsov Apr 19, 2022
6d62065
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Apr 19, 2022
e97b67c
Fixed types.
Kuznietsov Apr 19, 2022
822bf73
fixed types.
Kuznietsov Apr 19, 2022
acc63a9
Turned back layerIds.
Kuznietsov Apr 20, 2022
40ba7c0
Removed convertActiveData from Lens.
Kuznietsov Apr 20, 2022
cb25e61
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Apr 20, 2022
7cd49d0
Added test to the layerIds generator.
Kuznietsov Apr 20, 2022
6cd5376
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Apr 21, 2022
128643d
Fixed types.
Kuznietsov Apr 21, 2022
1b32193
Fixed problems with resetting of the inspector.
Kuznietsov Apr 21, 2022
d978efa
Fixed migrations.
Kuznietsov Apr 21, 2022
adb6d93
Removed types.
Kuznietsov Apr 21, 2022
6c05adb
Merge branch 'main' into chart_expressions-xy-extended_layers
Kuznietsov Apr 22, 2022
37c79b8
Merge branch 'main' into chart_expressions-xy-extended_layers
kibanamachine Apr 25, 2022
48ed45d
Merge branch 'main' into chart_expressions-xy-extended_layers
kibanamachine Apr 26, 2022
73d0442
Removed tones of `areFormatted` calculations.
Kuznietsov Apr 26, 2022
945c9e7
Fixed `isTimeViz` and `isHistogramViz` by replacing filteredLayers wi…
Kuznietsov Apr 26, 2022
083fd6b
Removed referenceLineLayers from the `groupAxesByType` fn.
Kuznietsov Apr 26, 2022
854e5ee
Added validation to the layeredXyVis.
Kuznietsov Apr 26, 2022
0612cad
Fixed extent validation.
Kuznietsov Apr 26, 2022
ad0533c
Removed comments.
Kuznietsov Apr 26, 2022
95a8ed2
Reduced limit.
Kuznietsov Apr 26, 2022
3806d78
Merge branch 'main' into chart_expressions-xy-extended_layers
kibanamachine Apr 26, 2022
7cc9b96
Added optimizations.
Kuznietsov Apr 27, 2022
d04a78b
Fixed floatingColumns error.
Kuznietsov Apr 27, 2022
867d3da
Fixed types.
Kuznietsov Apr 27, 2022
fa77166
Updated limits.
Kuznietsov Apr 27, 2022
5a1ce2a
Turned back extent validation.
Kuznietsov Apr 27, 2022
a73390e
Fixed stacked error.
Kuznietsov Apr 27, 2022
5a83b3d
Parallelized async import of functions.
Kuznietsov Apr 27, 2022
50ec457
Decreased the complexity of the algorithm.
Kuznietsov Apr 27, 2022
ac1553b
Fixed snapshot.
Kuznietsov Apr 27, 2022
c40890f
Merge remote-tracking branch 'Kunzetsov/chart_expressions-xy-extended…
VladLasitsa Apr 27, 2022
16c060f
Some fixes
VladLasitsa Apr 28, 2022
0c11af1
Fix checks
VladLasitsa Apr 28, 2022
7bd73f5
Fixed types
VladLasitsa Apr 28, 2022
0c1b95f
Fix types
VladLasitsa Apr 28, 2022
9f25e6f
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 28, 2022
b2e18b2
Merge remote-tracking branch 'upstream/main' into chart_expressions-x…
VladLasitsa May 4, 2022
6c7f2f5
Merge branch 'main' into chart_expressions-xy-support-visdimension
kibanamachine May 10, 2022
11838dd
Merge branch 'main' into chart_expressions-xy-support-visdimension
VladLasitsa May 10, 2022
8db166f
Merge branch 'main' into chart_expressions-xy-support-visdimension
Kuznietsov May 11, 2022
86a1201
Added validation to the accessors.
Kuznietsov May 11, 2022
dd89c68
Validated accessors at the referenceLineLayer and extendedReferenceLi…
Kuznietsov May 11, 2022
4124123
Fixed some style issues.
Kuznietsov May 11, 2022
1e3cb7b
Fixed imports.
Kuznietsov May 11, 2022
bf4da38
One more fix of import.
Kuznietsov May 11, 2022
2c01877
Merge remote-tracking branch 'upstream/main' into chart_expressions-x…
VladLasitsa May 11, 2022
d00ad46
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 11, 2022
9438722
Merge remote-tracking branch 'upstream/main' into chart_expressions-x…
VladLasitsa May 12, 2022
aec2d62
Merge branch 'main' into chart_expressions-xy-support-visdimension
kibanamachine May 12, 2022
e2f66ca
Move extended data layer fn in async file
VladLasitsa May 12, 2022
097f85c
Some improvements
VladLasitsa May 13, 2022
e114ceb
Fix checks
VladLasitsa May 13, 2022
c2d2525
Merge branch 'main' into chart_expressions-xy-support-visdimension
kibanamachine May 14, 2022
4277f42
Merge branch 'main' into chart_expressions-xy-support-visdimension
kibanamachine May 16, 2022
e40b368
Fix validation
VladLasitsa May 16, 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ type CommonDataLayerFnArgs = {
[key in keyof CommonDataLayerArgs]: ArgumentType<CommonDataLayerArgs[key]>;
};

export const commonDataLayerArgs: CommonDataLayerFnArgs = {
export const commonDataLayerArgs: Omit<
CommonDataLayerFnArgs,
'accessors' | 'xAccessor' | 'splitAccessor'
> = {
hide: {
types: ['boolean'],
default: false,
help: strings.getHideHelp(),
},
xAccessor: {
types: ['string'],
help: strings.getXAccessorHelp(),
},
seriesType: {
aliases: ['_'],
types: ['string'],
Expand All @@ -51,15 +50,6 @@ export const commonDataLayerArgs: CommonDataLayerFnArgs = {
default: YScaleTypes.LINEAR,
strict: true,
},
splitAccessor: {
types: ['string'],
help: strings.getSplitAccessorHelp(),
},
accessors: {
types: ['string'],
help: strings.getAccessorsHelp(),
multi: true,
},
yConfig: {
types: [Y_CONFIG],
help: strings.getYConfigHelp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ import { ReferenceLineLayerFn, ExtendedReferenceLineLayerFn } from '../types';

type CommonReferenceLineLayerFn = ReferenceLineLayerFn | ExtendedReferenceLineLayerFn;

export const commonReferenceLineLayerArgs: CommonReferenceLineLayerFn['args'] = {
accessors: {
types: ['string'],
help: strings.getRLAccessorsHelp(),
multi: true,
},
export const commonReferenceLineLayerArgs: Omit<CommonReferenceLineLayerFn['args'], 'accessors'> = {
yConfig: {
types: [EXTENDED_Y_CONFIG],
help: strings.getRLYConfigHelp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
*/

import { ExtendedDataLayerFn } from '../types';
import { EXTENDED_DATA_LAYER, LayerTypes } from '../constants';
import { EXTENDED_DATA_LAYER } from '../constants';
import { strings } from '../i18n';
import { commonDataLayerArgs } from './common_data_layer_args';
import { getAccessors } from '../helpers';

export const extendedDataLayerFunction: ExtendedDataLayerFn = {
name: EXTENDED_DATA_LAYER,
Expand All @@ -20,6 +19,19 @@ export const extendedDataLayerFunction: ExtendedDataLayerFn = {
inputTypes: ['datatable'],
args: {
...commonDataLayerArgs,
xAccessor: {
types: ['string'],
help: strings.getXAccessorHelp(),
},
splitAccessor: {
types: ['string'],
help: strings.getSplitAccessorHelp(),
},
accessors: {
types: ['string'],
help: strings.getAccessorsHelp(),
multi: true,
},
table: {
types: ['datatable'],
help: strings.getTableHelp(),
Expand All @@ -29,14 +41,8 @@ export const extendedDataLayerFunction: ExtendedDataLayerFn = {
help: strings.getLayerIdHelp(),
},
},
fn(input, args) {
const table = args.table ?? input;
return {
type: EXTENDED_DATA_LAYER,
...args,
...getAccessors(args, table),
layerType: LayerTypes.DATA,
table,
};
async fn(input, args, context) {
const { extendedDataLayerFn } = await import('./extended_data_layer_fn');
return await extendedDataLayerFn(input, args, context);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 { validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { ExtendedDataLayerArgs, ExtendedDataLayerFn } from '../types';
import { EXTENDED_DATA_LAYER, LayerTypes } from '../constants';
import { getAccessors } from '../helpers';

export const extendedDataLayerFn: ExtendedDataLayerFn['fn'] = async (data, args, context) => {
const table = args.table ?? data;
const accessors = getAccessors<string, ExtendedDataLayerArgs>(args, table);

validateAccessor(accessors.xAccessor, table.columns);
validateAccessor(accessors.splitAccessor, table.columns);
accessors.accessors.forEach((accessor) => validateAccessor(accessor, table.columns));

return {
type: EXTENDED_DATA_LAYER,
...args,
layerType: LayerTypes.DATA,
...accessors,
table,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { LayerTypes, EXTENDED_REFERENCE_LINE_LAYER } from '../constants';
import { ExtendedReferenceLineLayerFn } from '../types';
import { strings } from '../i18n';
Expand All @@ -19,6 +20,11 @@ export const extendedReferenceLineLayerFunction: ExtendedReferenceLineLayerFn =
inputTypes: ['datatable'],
args: {
...commonReferenceLineLayerArgs,
accessors: {
types: ['string'],
help: strings.getRLAccessorsHelp(),
multi: true,
},
table: {
types: ['datatable'],
help: strings.getTableHelp(),
Expand All @@ -29,12 +35,16 @@ export const extendedReferenceLineLayerFunction: ExtendedReferenceLineLayerFn =
},
},
fn(input, args) {
const table = args.table ?? input;
const accessors = args.accessors ?? [];
accessors.forEach((accessor) => validateAccessor(accessor, table.columns));

return {
type: EXTENDED_REFERENCE_LINE_LAYER,
...args,
accessors: args.accessors ?? [],
layerType: LayerTypes.REFERENCELINE,
table: args.table ?? input,
table,
};
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { LayerTypes, REFERENCE_LINE_LAYER } from '../constants';
import { ReferenceLineLayerFn } from '../types';
import { strings } from '../i18n';
Expand All @@ -17,13 +18,23 @@ export const referenceLineLayerFunction: ReferenceLineLayerFn = {
type: REFERENCE_LINE_LAYER,
help: strings.getRLHelp(),
inputTypes: ['datatable'],
args: { ...commonReferenceLineLayerArgs },
args: {
...commonReferenceLineLayerArgs,
accessors: {
types: ['string', 'vis_dimension'],
help: strings.getRLAccessorsHelp(),
multi: true,
},
},
fn(table, args) {
const accessors = args.accessors ?? [];
accessors.forEach((accessor) => validateAccessor(accessor, table.columns));

return {
type: REFERENCE_LINE_LAYER,
...args,
accessors: args.accessors ?? [],
layerType: LayerTypes.REFERENCELINE,
accessors,
table,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ export const xyVisFunction: XyVisFn = {
args: {
...commonXYArgs,
...commonDataLayerArgs,
xAccessor: {
types: ['string', 'vis_dimension'],
help: strings.getXAccessorHelp(),
},
splitAccessor: {
types: ['string', 'vis_dimension'],
help: strings.getSplitAccessorHelp(),
},
accessors: {
types: ['string', 'vis_dimension'],
help: strings.getAccessorsHelp(),
multi: true,
},
referenceLineLayers: {
types: [REFERENCE_LINE_LAYER],
help: strings.getReferenceLineLayerHelp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
validateAccessor,
} from '@kbn/visualizations-plugin/common/utils';
import type { Datatable } from '@kbn/expressions-plugin/common';
import { ExpressionValueVisDimension } from '@kbn/visualizations-plugin/common/expression_functions';
import { LayerTypes, XY_VIS_RENDERER, DATA_LAYER } from '../constants';
import { appendLayerIds, getAccessors } from '../helpers';
import { DataLayerConfigResult, XYLayerConfig, XyVisFn, XYArgs } from '../types';
Expand All @@ -37,7 +38,7 @@ const createDataLayer = (args: XYArgs, table: Datatable): DataLayerConfigResult
yConfig: args.yConfig,
layerType: LayerTypes.DATA,
table,
...getAccessors(args, table),
...getAccessors<string | ExpressionValueVisDimension, XYArgs>(args, table),
});

export const xyVisFn: XyVisFn['fn'] = async (data, args, handlers) => {
Expand All @@ -64,6 +65,10 @@ export const xyVisFn: XyVisFn['fn'] = async (data, args, handlers) => {

const dataLayers: DataLayerConfigResult[] = [createDataLayer(args, data)];

validateAccessor(dataLayers[0].xAccessor, data.columns);
validateAccessor(dataLayers[0].splitAccessor, data.columns);
dataLayers[0].accessors.forEach((accessor) => validateAccessor(accessor, data.columns));

const layers: XYLayerConfig[] = [
...appendLayerIds(dataLayers, 'dataLayers'),
...appendLayerIds(referenceLineLayers, 'referenceLineLayers'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Datatable, PointSeriesColumnNames } from '@kbn/expressions-plugin/common';
import { WithLayerId, DataLayerArgs } from '../types';
import { WithLayerId } from '../types';

function isWithLayerId<T>(layer: T): layer is T & WithLayerId {
return (layer as T & WithLayerId).layerId ? true : false;
Expand All @@ -27,10 +27,13 @@ export function appendLayerIds<T>(
}));
}

export function getAccessors(args: DataLayerArgs, table: Datatable) {
let splitAccessor = args.splitAccessor;
let xAccessor = args.xAccessor;
let accessors = args.accessors ?? [];
export function getAccessors<T, U extends { splitAccessor?: T; xAccessor?: T; accessors: T[] }>(
args: U,
table: Datatable
) {
let splitAccessor: T | string | undefined = args.splitAccessor;
let xAccessor: T | string | undefined = args.xAccessor;
let accessors: Array<T | string> = args.accessors ?? [];
if (!splitAccessor && !xAccessor && !(accessors && accessors.length)) {
const y = table.columns.find((column) => column.id === PointSeriesColumnNames.Y)?.id;
xAccessor = table.columns.find((column) => column.id === PointSeriesColumnNames.X)?.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import type { PaletteOutput } from '@kbn/coloring';
import { Datatable, ExpressionFunctionDefinition } from '@kbn/expressions-plugin';
import { LegendSize } from '@kbn/visualizations-plugin/public';
import { EventAnnotationOutput } from '@kbn/event-annotation-plugin/common';
import { ExpressionValueVisDimension } from '@kbn/visualizations-plugin/common';

import type { ExpressionValueVisDimension } from '@kbn/visualizations-plugin/common/expression_functions';
import {
AxisExtentModes,
FillStyles,
Expand Down Expand Up @@ -96,11 +95,11 @@ export interface YConfig {
}

export interface DataLayerArgs {
accessors: string[];
accessors: Array<ExpressionValueVisDimension | string>;
seriesType: SeriesType;
xAccessor?: string;
xAccessor?: string | ExpressionValueVisDimension;
hide?: boolean;
splitAccessor?: string;
splitAccessor?: string | ExpressionValueVisDimension;
columnToLabel?: string; // Actually a JSON key-value pair
yScaleType: YScaleType;
xScaleType: XScaleType;
Expand Down Expand Up @@ -276,7 +275,7 @@ export type ExtendedAnnotationLayerConfigResult = ExtendedAnnotationLayerArgs &
};

export interface ReferenceLineLayerArgs {
accessors: string[];
accessors: Array<ExpressionValueVisDimension | string>;
columnToLabel?: string;
yConfig?: ExtendedYConfigResult[];
}
Expand Down Expand Up @@ -385,7 +384,7 @@ export type ExtendedDataLayerFn = ExpressionFunctionDefinition<
typeof EXTENDED_DATA_LAYER,
Datatable,
ExtendedDataLayerArgs,
ExtendedDataLayerConfigResult
Promise<ExtendedDataLayerConfigResult>
>;

export type ReferenceLineLayerFn = ExpressionFunctionDefinition<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import type {
CommonXYAnnotationLayerConfig,
CollectiveConfig,
} from '../../common';

import { AnnotationIcon, hasIcon, Marker, MarkerBody } from '../helpers';
import { mapVerticalToHorizontalPlacement, LINES_MARKER_SIZE } from '../helpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import React, { FC } from 'react';
import { PaletteRegistry } from '@kbn/coloring';
import { FormatFactory } from '@kbn/field-formats-plugin/common';
import { getAccessorByDimension } from '@kbn/visualizations-plugin/common/utils';

import {
CommonXYDataLayerConfig,
EndValue,
Expand Down Expand Up @@ -71,7 +73,8 @@ export const DataLayers: FC<Props> = ({
<>
{layers.flatMap((layer) =>
layer.accessors.map((accessor, accessorIndex) => {
const { seriesType, columnToLabel, layerId } = layer;
const { seriesType, columnToLabel, layerId, table } = layer;
const yColumnId = getAccessorByDimension(accessor, table.columns);
const columnToLabelMap: Record<string, string> = columnToLabel
? JSON.parse(columnToLabel)
: {};
Expand All @@ -84,12 +87,12 @@ export const DataLayers: FC<Props> = ({
const isPercentage = seriesType.includes('percentage');

const yAxis = yAxesConfiguration.find((axisConfiguration) =>
axisConfiguration.series.find((currentSeries) => currentSeries.accessor === accessor)
axisConfiguration.series.find((currentSeries) => currentSeries.accessor === yColumnId)
);

const seriesProps = getSeriesProps({
layer,
accessor,
accessor: yColumnId,
chartHasMoreThanOneBarSeries,
colorAssignments,
formatFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import React from 'react';
import type { LegendAction, XYChartSeriesIdentifier } from '@elastic/charts';
import { getAccessorByDimension } from '@kbn/visualizations-plugin/common/utils';
import type { FilterEvent } from '../types';
import type { CommonXYDataLayerConfig } from '../../common';
import type { FormatFactory } from '../types';
Expand All @@ -23,7 +24,11 @@ export const getLegendAction = (
React.memo(({ series: [xySeries] }) => {
const series = xySeries as XYChartSeriesIdentifier;
const layerIndex = dataLayers.findIndex((l) =>
series.seriesKeys.some((key: string | number) => l.accessors.includes(key.toString()))
series.seriesKeys.some((key: string | number) =>
l.accessors.some(
(accessor) => getAccessorByDimension(accessor, l.table.columns) === key.toString()
)
)
);

if (layerIndex === -1) {
Expand All @@ -36,11 +41,12 @@ export const getLegendAction = (
}

const splitLabel = series.seriesKeys[0] as string;
const accessor = layer.splitAccessor;

const { table } = layer;
const splitColumn = table.columns.find(({ id }) => id === layer.splitAccessor);
const formatter = formatFactory(splitColumn && getFormat(splitColumn.meta));
const accessor = getAccessorByDimension(layer.splitAccessor, table.columns);
const formatter = formatFactory(
accessor ? getFormat(table.columns, layer.splitAccessor) : undefined
);

const rowIndex = table.rows.findIndex((row) => {
if (formattedDatatables[layer.layerId]?.formattedColumns[accessor]) {
Expand Down
Loading