-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Observability] [Exploratory View] add percentile ranks, show legend always, and fix field labels #113765
Merged
dominiqueclarke
merged 9 commits into
elastic:master
from
dominiqueclarke:feature/observability-exploratory-view-percentile-breakdowns
Oct 12, 2021
Merged
[Observability] [Exploratory View] add percentile ranks, show legend always, and fix field labels #113765
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b12e20d
add percentile ranks, show legend always, and fix field labels
dominiqueclarke 9d054f8
add 50th percentile
dominiqueclarke 5620f14
replace hard coded values with constant
dominiqueclarke de573cb
Merge branch 'master' into feature/observability-exploratory-view-per…
kibanamachine d9ee593
Merge branch 'master' into feature/observability-exploratory-view-per…
kibanamachine 09dac71
Merge branch 'master' into feature/observability-exploratory-view-per…
kibanamachine 67c1b9e
merge master
dominiqueclarke b0c19b9
Merge branch 'feature/observability-exploratory-view-percentile-break…
dominiqueclarke 8ca9002
Merge branch 'master' into feature/observability-exploratory-view-per…
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ import { | |
REPORT_METRIC_FIELD, | ||
RECORDS_FIELD, | ||
RECORDS_PERCENTAGE_FIELD, | ||
PERCENTILE, | ||
PERCENTILE_RANKS, | ||
ReportTypes, | ||
} from './constants'; | ||
import { ColumnFilter, SeriesConfig, UrlFilter, URLReportDefinition } from '../types'; | ||
|
@@ -247,6 +249,30 @@ export class LensAttributes { | |
}; | ||
} | ||
|
||
getPercentileBreakdowns( | ||
layerConfig: LayerConfig, | ||
columnFilter?: string | ||
): Record<string, FieldBasedIndexPatternColumn> { | ||
const yAxisColumns = layerConfig.seriesConfig.yAxisColumns; | ||
const { sourceField: mainSourceField, label: mainLabel } = yAxisColumns[0]; | ||
const lensColumns: Record<string, FieldBasedIndexPatternColumn> = {}; | ||
|
||
// start at 1, because main y axis will have the first percentile breakdown | ||
for (let i = 1; i < PERCENTILE_RANKS.length; i++) { | ||
lensColumns[`y-axis-column-${i}`] = { | ||
...this.getColumnBasedOnType({ | ||
sourceField: mainSourceField!, | ||
operationType: PERCENTILE_RANKS[i], | ||
label: mainLabel, | ||
layerConfig, | ||
colIndex: i, | ||
}), | ||
filter: { query: columnFilter || '', language: 'kuery' }, | ||
}; | ||
} | ||
return lensColumns; | ||
} | ||
|
||
getPercentileNumberColumn( | ||
sourceField: string, | ||
percentileValue: string, | ||
|
@@ -256,7 +282,7 @@ export class LensAttributes { | |
...buildNumberColumn(sourceField), | ||
label: i18n.translate('xpack.observability.expView.columns.label', { | ||
defaultMessage: '{percentileValue} percentile of {sourceField}', | ||
values: { sourceField: seriesConfig.labels[sourceField], percentileValue }, | ||
values: { sourceField: seriesConfig.labels[sourceField]?.toLowerCase(), percentileValue }, | ||
}), | ||
operationType: 'percentile', | ||
params: { percentile: Number(percentileValue.split('th')[0]) }, | ||
|
@@ -326,6 +352,7 @@ export class LensAttributes { | |
layerConfig: LayerConfig; | ||
colIndex?: number; | ||
}) { | ||
const { breakdown, seriesConfig } = layerConfig; | ||
const { fieldMeta, columnType, fieldName, columnLabel, timeScale, columnFilters } = | ||
this.getFieldMeta(sourceField, layerConfig); | ||
|
||
|
@@ -346,6 +373,18 @@ export class LensAttributes { | |
if (fieldType === 'date') { | ||
return this.getDateHistogramColumn(fieldName); | ||
} | ||
|
||
if (fieldType === 'number' && breakdown === PERCENTILE) { | ||
return { | ||
...this.getPercentileNumberColumn( | ||
fieldName, | ||
operationType || PERCENTILE_RANKS[0], | ||
seriesConfig! | ||
), | ||
filter: colIndex !== undefined ? columnFilters?.[colIndex] : undefined, | ||
}; | ||
} | ||
|
||
if (fieldType === 'number') { | ||
return this.getNumberColumn({ | ||
sourceField: fieldName, | ||
|
@@ -393,6 +432,7 @@ export class LensAttributes { | |
} | ||
|
||
getMainYAxis(layerConfig: LayerConfig, layerId: string, columnFilter: string) { | ||
const { breakdown } = layerConfig; | ||
const { sourceField, operationType, label } = layerConfig.seriesConfig.yAxisColumns[0]; | ||
|
||
if (sourceField === RECORDS_PERCENTAGE_FIELD) { | ||
|
@@ -405,14 +445,15 @@ export class LensAttributes { | |
|
||
return this.getColumnBasedOnType({ | ||
sourceField, | ||
operationType, | ||
operationType: breakdown === PERCENTILE ? PERCENTILE_RANKS[0] : operationType, | ||
label, | ||
layerConfig, | ||
colIndex: 0, | ||
}); | ||
} | ||
|
||
getChildYAxises(layerConfig: LayerConfig, layerId?: string, columnFilter?: string) { | ||
const { breakdown } = layerConfig; | ||
const lensColumns: Record<string, FieldBasedIndexPatternColumn | SumIndexPatternColumn> = {}; | ||
const yAxisColumns = layerConfig.seriesConfig.yAxisColumns; | ||
const { sourceField: mainSourceField, label: mainLabel } = yAxisColumns[0]; | ||
|
@@ -422,7 +463,10 @@ export class LensAttributes { | |
.supportingColumns; | ||
} | ||
|
||
// 1 means there is only main y axis | ||
if (yAxisColumns.length === 1 && breakdown === PERCENTILE) { | ||
return this.getPercentileBreakdowns(layerConfig, columnFilter); | ||
} | ||
|
||
if (yAxisColumns.length === 1) { | ||
return lensColumns; | ||
} | ||
|
@@ -572,7 +616,7 @@ export class LensAttributes { | |
layers[layerId] = { | ||
columnOrder: [ | ||
`x-axis-column-${layerId}`, | ||
...(breakdown && sourceField !== USE_BREAK_DOWN_COLUMN | ||
...(breakdown && sourceField !== USE_BREAK_DOWN_COLUMN && breakdown !== 'percentile' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe move "percentile" into a constant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oooh, I did. I just missed this one. Thanks for catching it! |
||
? [`breakdown-column-${layerId}`] | ||
: []), | ||
`y-axis-column-${layerId}`, | ||
|
@@ -586,7 +630,7 @@ export class LensAttributes { | |
filter: { query: columnFilter, language: 'kuery' }, | ||
...(timeShift ? { timeShift } : {}), | ||
}, | ||
...(breakdown && sourceField !== USE_BREAK_DOWN_COLUMN | ||
...(breakdown && sourceField !== USE_BREAK_DOWN_COLUMN && breakdown !== 'percentile' | ||
? // do nothing since this will be used a x axis source | ||
{ | ||
[`breakdown-column-${layerId}`]: this.getBreakdownColumn({ | ||
|
@@ -608,7 +652,7 @@ export class LensAttributes { | |
|
||
getXyState(): XYState { | ||
return { | ||
legend: { isVisible: true, position: 'right' }, | ||
legend: { isVisible: true, showSingleSeries: true, position: 'right' }, | ||
valueLabels: 'hide', | ||
fittingFunction: 'Linear', | ||
curveType: 'CURVE_MONOTONE_X' as XYCurveType, | ||
|
@@ -630,6 +674,7 @@ export class LensAttributes { | |
], | ||
xAccessor: `x-axis-column-layer${index}`, | ||
...(layerConfig.breakdown && | ||
layerConfig.breakdown !== PERCENTILE && | ||
layerConfig.seriesConfig.xAxisColumn.sourceField !== USE_BREAK_DOWN_COLUMN | ||
? { splitAccessor: `breakdown-column-layer${index}` } | ||
: {}), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add 50th as well.