Skip to content

Commit 3cb5fed

Browse files
VladLasitsakibanamachinestratoula
authored
[Lens][Agg based XY] Convert to Lens Agg based XY. (#142936)
* Add conversion config for agg based XY * Fixed line stacked charts and buckets for layers * fixed bundle size * Fixed tests * Fixed tests, decreased bundle size * Add possibility to return several layers from getColumnsFromVis * Some refactoring * updated limits * Updated limits * Added tests for configuration * updated bundle size limit * Added tests for getCustomBucketColumns * Added some functional tests * Fix gauge/goal configurations * Fixed nits * Fixed parent pipeline aggregation, multi split series and respect Show values option * Added support of current time marker, use one layer for metrics with the same chart type and mode * Added support of assign color * Fix terms with order by column * Fixed sibling pipeline aggs * Fixed test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
1 parent 7ba6093 commit 3cb5fed

51 files changed

Lines changed: 1736 additions & 325 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/kbn-optimizer/limits.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ pageLoadAssetSize:
140140
visTypeTimeseries: 55203
141141
visTypeVega: 153573
142142
visTypeVislib: 242838
143-
visTypeXy: 30000
143+
visTypeXy: 31800
144144
visualizations: 90000
145145
watcher: 43598

src/plugins/chart_expressions/expression_xy/common/expression_functions/layered_xy_vis.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe('layeredXyVis', () => {
2828
args: { ...rest, layers: [sampleExtendedLayer] },
2929
syncColors: false,
3030
syncTooltips: false,
31+
canNavigateToLens: false,
3132
},
3233
});
3334
});

src/plugins/chart_expressions/expression_xy/common/expression_functions/layered_xy_vis_fn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const layeredXyVisFn: LayeredXyVisFn['fn'] = async (data, args, handlers)
6161
(handlers.variables?.embeddableTitle as string) ??
6262
handlers.getExecutionContext?.()?.description,
6363
},
64+
canNavigateToLens: Boolean(handlers.variables.canNavigateToLens),
6465
syncColors: handlers?.isSyncColorsEnabled?.() ?? false,
6566
syncTooltips: handlers?.isSyncTooltipsEnabled?.() ?? false,
6667
},

src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('xyVis', () => {
3838
},
3939
],
4040
},
41+
canNavigateToLens: false,
4142
syncColors: false,
4243
syncTooltips: false,
4344
},
@@ -346,6 +347,7 @@ describe('xyVis', () => {
346347
},
347348
],
348349
},
350+
canNavigateToLens: false,
349351
syncColors: false,
350352
syncTooltips: false,
351353
},

src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis_fn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export const xyVisFn: XyVisFn['fn'] = async (data, args, handlers) => {
136136
(handlers.variables?.embeddableTitle as string) ??
137137
handlers.getExecutionContext?.()?.description,
138138
},
139+
canNavigateToLens: Boolean(handlers.variables.canNavigateToLens),
139140
syncColors: handlers?.isSyncColorsEnabled?.() ?? false,
140141
syncTooltips: handlers?.isSyncTooltipsEnabled?.() ?? false,
141142
},

src/plugins/chart_expressions/expression_xy/common/types/expression_renderers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface XYChartProps {
1818
args: XYProps;
1919
syncTooltips: boolean;
2020
syncColors: boolean;
21+
canNavigateToLens?: boolean;
2122
}
2223

2324
export interface XYRender {

src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ declare global {
110110
}
111111
}
112112

113-
export type XYChartRenderProps = XYChartProps & {
113+
export type XYChartRenderProps = Omit<XYChartProps, 'canNavigateToLens'> & {
114114
chartsThemeService: ChartsPluginSetup['theme'];
115115
chartsActiveCursorService: ChartsPluginStart['activeCursor'];
116116
data: DataPublicPluginStart;

src/plugins/chart_expressions/expression_xy/public/expression_renderers/xy_chart_renderer.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ interface XyChartRendererDeps {
5252
const extractCounterEvents = (
5353
originatingApp: string,
5454
{ layers, yAxisConfigs }: XYChartProps['args'],
55+
canNavigateToLens: boolean,
5556
services: {
5657
getDataLayers: typeof getDataLayers;
5758
}
@@ -149,6 +150,7 @@ const extractCounterEvents = (
149150
(aggregateLayers.length === 1 && dataLayer.splitAccessors?.length)
150151
? 'aggregate_bucket'
151152
: undefined,
153+
canNavigateToLens ? `render_${byTypes.mixedXY ? 'mixed_xy' : type}_convertable` : undefined,
152154
]
153155
.filter(Boolean)
154156
.map((item) => `render_${originatingApp}_${item}`);
@@ -188,9 +190,14 @@ export const getXyChartRenderer = ({
188190
const visualizationType = extractVisualizationType(executionContext);
189191

190192
if (deps.usageCollection && containerType && visualizationType) {
191-
const uiEvents = extractCounterEvents(visualizationType, config.args, {
192-
getDataLayers,
193-
});
193+
const uiEvents = extractCounterEvents(
194+
visualizationType,
195+
config.args,
196+
Boolean(config.canNavigateToLens),
197+
{
198+
getDataLayers,
199+
}
200+
);
194201

195202
if (uiEvents) {
196203
deps.usageCollection.reportUiCounter(containerType, METRIC_TYPE.COUNT, uiEvents);

src/plugins/vis_types/gauge/public/convert_to_lens/configurations/goal.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('getConfiguration', () => {
6060
const metricAccessor = 'metric-id';
6161
const breakdownByAccessor = 'bucket-id';
6262
const metrics = [metricAccessor];
63-
const buckets = [breakdownByAccessor];
63+
const buckets = { all: [breakdownByAccessor], customBuckets: {} };
6464
const maxAccessor = 'max-accessor-id';
6565
const collapseFn = 'sum';
6666
expect(
@@ -69,7 +69,7 @@ describe('getConfiguration', () => {
6969
buckets,
7070
maxAccessor,
7171
columnsWithoutReferenced: [],
72-
bucketCollapseFn: { [metricAccessor]: collapseFn },
72+
bucketCollapseFn: { [collapseFn]: [breakdownByAccessor] },
7373
})
7474
).toEqual({
7575
breakdownByAccessor,

src/plugins/vis_types/gauge/public/convert_to_lens/configurations/goal.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,30 @@ export const getConfiguration = (
2222
bucketCollapseFn,
2323
}: {
2424
metrics: string[];
25-
buckets: string[];
25+
buckets: {
26+
all: string[];
27+
customBuckets: Record<string, string>;
28+
};
2629
maxAccessor: string;
2730
columnsWithoutReferenced: Column[];
28-
bucketCollapseFn?: Record<string, string | undefined>;
31+
bucketCollapseFn?: Record<string, string[]>;
2932
}
3033
): MetricVisConfiguration => {
3134
const [metricAccessor] = metrics;
32-
const [breakdownByAccessor] = buckets;
35+
const [breakdownByAccessor] = buckets.all;
36+
const collapseFn = bucketCollapseFn
37+
? Object.keys(bucketCollapseFn).find((key) =>
38+
bucketCollapseFn[key].includes(breakdownByAccessor)
39+
)
40+
: undefined;
3341
return {
3442
layerId,
3543
layerType: 'data',
3644
palette,
3745
metricAccessor,
3846
breakdownByAccessor,
3947
maxAccessor,
40-
collapseFn: Object.values(bucketCollapseFn ?? {})[0],
48+
collapseFn,
4149
subtitle: gauge.labels.show && gauge.style.subText ? gauge.style.subText : undefined,
4250
};
4351
};

0 commit comments

Comments
 (0)