mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Exploratory View] add a global filter to exploratory view when there is only one series (#122301) (#122611)
* add a global filter to exploratory view when there is only one series
* adjust types
* addjust sample lens attributes
* fix breakdown column order
* update tests
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: shahzad31 <shahzad.muhammad@elastic.co>
(cherry picked from commit 1d270503cb
)
Co-authored-by: Dominique Clarke <doclarke71@gmail.com>
This commit is contained in:
parent
4f6012d129
commit
355d9e6aee
5 changed files with 31 additions and 6 deletions
|
@ -482,6 +482,11 @@ describe('Lens Attribute', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not use global filters when there is more than one series', function () {
|
||||
const multiSeriesLensAttr = new LensAttributes([layerConfig, layerConfig]).getJSON();
|
||||
expect(multiSeriesLensAttr.state.query.query).toEqual('transaction.duration.us < 60000000');
|
||||
});
|
||||
|
||||
describe('Layer breakdowns', function () {
|
||||
it('should return breakdown column', function () {
|
||||
const layerConfig1: LayerConfig = {
|
||||
|
@ -521,8 +526,8 @@ describe('Lens Attribute', () => {
|
|||
|
||||
expect(lnsAttr.layers.layer0).toEqual({
|
||||
columnOrder: [
|
||||
'x-axis-column-layer0',
|
||||
'breakdown-column-layer0',
|
||||
'x-axis-column-layer0',
|
||||
'y-axis-column-layer0',
|
||||
'y-axis-column-layer0X0',
|
||||
'y-axis-column-layer0X1',
|
||||
|
|
|
@ -102,6 +102,7 @@ export class LensAttributes {
|
|||
visualization: XYState;
|
||||
layerConfigs: LayerConfig[];
|
||||
isMultiSeries: boolean;
|
||||
globalFilter?: { query: string; language: string };
|
||||
|
||||
constructor(layerConfigs: LayerConfig[]) {
|
||||
this.layers = {};
|
||||
|
@ -119,10 +120,27 @@ export class LensAttributes {
|
|||
|
||||
this.layerConfigs = layerConfigs;
|
||||
this.isMultiSeries = layerConfigs.length > 1;
|
||||
this.globalFilter = this.getGlobalFilter(this.isMultiSeries);
|
||||
this.layers = this.getLayers();
|
||||
this.visualization = this.getXyState();
|
||||
}
|
||||
|
||||
getGlobalFilter(isMultiSeries: boolean) {
|
||||
if (isMultiSeries) {
|
||||
return undefined;
|
||||
}
|
||||
const defaultLayerFilter = this.layerConfigs[0].seriesConfig.query
|
||||
? ` and ${this.layerConfigs[0].seriesConfig.query.query}`
|
||||
: '';
|
||||
return {
|
||||
query: `${this.getLayerFilters(
|
||||
this.layerConfigs[0],
|
||||
this.layerConfigs.length
|
||||
)}${defaultLayerFilter}`,
|
||||
language: 'kuery',
|
||||
};
|
||||
}
|
||||
|
||||
getBreakdownColumn({
|
||||
sourceField,
|
||||
layerId,
|
||||
|
@ -670,10 +688,10 @@ export class LensAttributes {
|
|||
|
||||
layers[layerId] = {
|
||||
columnOrder: [
|
||||
`x-axis-column-${layerId}`,
|
||||
...(breakdown && sourceField !== USE_BREAK_DOWN_COLUMN && breakdown !== PERCENTILE
|
||||
? [`breakdown-column-${layerId}`]
|
||||
: []),
|
||||
`x-axis-column-${layerId}`,
|
||||
`y-axis-column-${layerId}`,
|
||||
...Object.keys(this.getChildYAxises(layerConfig, layerId, columnFilter)),
|
||||
],
|
||||
|
@ -764,7 +782,7 @@ export class LensAttributes {
|
|||
new Set([...this.layerConfigs.map(({ indexPattern }) => indexPattern.id)])
|
||||
);
|
||||
|
||||
const query = this.layerConfigs[0].seriesConfig.query;
|
||||
const query = this.globalFilter || this.layerConfigs[0].seriesConfig.query;
|
||||
|
||||
return {
|
||||
title: 'Prefilled from exploratory view app',
|
||||
|
|
|
@ -155,7 +155,8 @@ export const sampleAttribute = {
|
|||
filters: [],
|
||||
query: {
|
||||
language: 'kuery',
|
||||
query: 'transaction.duration.us < 60000000',
|
||||
query:
|
||||
'transaction.type: page-load and processor.event: transaction and transaction.type : * and transaction.duration.us < 60000000',
|
||||
},
|
||||
visualization: {
|
||||
axisTitlesVisibilitySettings: {
|
||||
|
|
|
@ -95,7 +95,8 @@ export const sampleAttributeCoreWebVital = {
|
|||
filters: [],
|
||||
query: {
|
||||
language: 'kuery',
|
||||
query: 'transaction.type: "page-load"',
|
||||
query:
|
||||
'transaction.type: page-load and processor.event: transaction and transaction.type: "page-load"',
|
||||
},
|
||||
visualization: {
|
||||
axisTitlesVisibilitySettings: {
|
||||
|
|
|
@ -57,7 +57,7 @@ export const sampleAttributeKpi = {
|
|||
filters: [],
|
||||
query: {
|
||||
language: 'kuery',
|
||||
query: '',
|
||||
query: 'transaction.type: page-load and processor.event: transaction',
|
||||
},
|
||||
visualization: {
|
||||
axisTitlesVisibilitySettings: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue