Skip to content

Commit

Permalink
[Exploratory view] Use series names as labels (#143458)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Oct 20, 2022
1 parent 8189348 commit dba19ee
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 26 deletions.
3 changes: 2 additions & 1 deletion x-pack/plugins/observability/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"kibanaReact",
"kibanaUtils",
"lens",
"usageCollection"
"usageCollection",
"visualizations"
],
"extraPublicDirs": [
"common"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('Lens Attribute', () => {
customLabel: true,
dataType: 'number',
isBucketed: false,
label: 'Pages loaded',
label: 'test-series',
operationType: 'formula',
params: {
format: {
Expand Down Expand Up @@ -427,7 +427,13 @@ describe('Lens Attribute', () => {
],
},
],
legend: { isVisible: true, showSingleSeries: true, position: 'right' },
legend: {
isVisible: true,
showSingleSeries: true,
position: 'right',
legendSize: 'large',
shouldTruncate: false,
},
preferredSeriesType: 'line',
tickLabelsVisibilitySettings: { x: true, yLeft: true, yRight: true },
valueLabels: 'hide',
Expand Down Expand Up @@ -545,7 +551,7 @@ describe('Lens Attribute', () => {
'transaction.type: page-load and processor.event: transaction and transaction.type : *',
},
isBucketed: false,
label: 'Pages loaded',
label: 'test-series',
operationType: 'formula',
params: {
format: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
} from '@kbn/lens-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/common';
import { PersistableFilter } from '@kbn/lens-plugin/common';
import { LegendSize } from '@kbn/visualizations-plugin/common/constants';
import { urlFiltersToKueryString } from '../utils/stringify_kueries';
import {
FILTER_RECORDS,
Expand Down Expand Up @@ -397,15 +398,14 @@ export class LensAttributes {
return {
...buildNumberColumn(sourceField),
label:
operationType === 'unique_count' || shortLabel
? label || seriesConfig.labels[sourceField]
: i18n.translate('xpack.observability.expView.columns.operation.label', {
defaultMessage: '{operationType} of {sourceField}',
values: {
sourceField: label || seriesConfig.labels[sourceField],
operationType: capitalize(operationType),
},
}),
label ??
i18n.translate('xpack.observability.expView.columns.operation.label', {
defaultMessage: '{operationType} of {sourceField}',
values: {
sourceField: seriesConfig.labels[sourceField],
operationType: capitalize(operationType),
},
}),
filter: columnFilter,
operationType,
params:
Expand Down Expand Up @@ -574,7 +574,7 @@ export class LensAttributes {
const { type: fieldType } = fieldMeta ?? {};

if (columnType === TERMS_COLUMN) {
return this.getTermsColumn(fieldName, columnLabel || label);
return this.getTermsColumn(fieldName, label || columnLabel);
}

if (fieldName === RECORDS_FIELD || columnType === FILTER_RECORDS) {
Expand Down Expand Up @@ -606,7 +606,7 @@ export class LensAttributes {
columnType,
columnFilter: columnFilters?.[0],
operationType,
label: columnLabel || label,
label: label || columnLabel,
seriesConfig: layerConfig.seriesConfig,
shortLabel,
});
Expand All @@ -615,7 +615,7 @@ export class LensAttributes {
return this.getNumberOperationColumn({
sourceField: fieldName,
operationType: 'unique_count',
label: columnLabel || label,
label: label || columnLabel,
seriesConfig: layerConfig.seriesConfig,
columnFilter: columnFilters?.[0],
});
Expand Down Expand Up @@ -687,8 +687,18 @@ export class LensAttributes {

getMainYAxis(layerConfig: LayerConfig, layerId: string, columnFilter: string) {
const { breakdown } = layerConfig;
const { sourceField, operationType, label, timeScale } =
layerConfig.seriesConfig.yAxisColumns[0];
const {
sourceField,
operationType,
label: colLabel,
timeScale,
} = layerConfig.seriesConfig.yAxisColumns[0];

let label = layerConfig.name || colLabel;

if (layerConfig.seriesConfig.reportType === ReportTypes.CORE_WEB_VITAL) {
label = colLabel;
}

if (sourceField === RECORDS_PERCENTAGE_FIELD) {
return [
Expand Down Expand Up @@ -1028,7 +1038,13 @@ export class LensAttributes {

getXyState(): XYState {
return {
legend: { isVisible: true, showSingleSeries: true, position: 'right' },
legend: {
isVisible: true,
showSingleSeries: true,
position: 'right',
legendSize: LegendSize.LARGE,
shouldTruncate: false,
},
valueLabels: 'hide',
fittingFunction: 'Linear',
curveType: 'CURVE_MONOTONE_X' as XYCurveType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const testMobileKPIAttr = {
},
'y-axis-column-layer0-0': {
isBucketed: false,
label: 'Median of System memory usage',
label: 'test-series',
operationType: 'median',
params: {},
scale: 'ratio',
Expand All @@ -58,7 +58,13 @@ export const testMobileKPIAttr = {
},
},
visualization: {
legend: { isVisible: true, showSingleSeries: true, position: 'right' },
legend: {
isVisible: true,
showSingleSeries: true,
position: 'right',
legendSize: 'large',
shouldTruncate: false,
},
valueLabels: 'hide',
fittingFunction: 'Linear',
curveType: 'CURVE_MONOTONE_X',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const sampleAttribute = {
'transaction.type: page-load and processor.event: transaction and transaction.type : *',
},
isBucketed: false,
label: 'Pages loaded',
label: 'test-series',
operationType: 'formula',
params: {
format: {
Expand Down Expand Up @@ -322,6 +322,8 @@ export const sampleAttribute = {
isVisible: true,
position: 'right',
showSingleSeries: true,
legendSize: 'large',
shouldTruncate: false,
},
preferredSeriesType: 'line',
tickLabelsVisibilitySettings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export const sampleAttributeCoreWebVital = {
isVisible: true,
showSingleSeries: true,
position: 'right',
shouldTruncate: false,
legendSize: 'large',
},
preferredSeriesType: 'line',
tickLabelsVisibilitySettings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const sampleAttributeKpi = {
query: 'transaction.type: page-load and processor.event: transaction',
},
isBucketed: false,
label: 'Page views',
label: 'test-series',
operationType: 'count',
scale: 'ratio',
sourceField: RECORDS_FIELD,
Expand Down Expand Up @@ -95,6 +95,8 @@ export const sampleAttributeKpi = {
isVisible: true,
showSingleSeries: true,
position: 'right',
legendSize: 'large',
shouldTruncate: false,
},
preferredSeriesType: 'line',
tickLabelsVisibilitySettings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const sampleAttributeWithReferenceLines = {
'transaction.type: page-load and processor.event: transaction and transaction.type : * and service.name: (elastic or kibana)',
},
isBucketed: false,
label: 'Pages loaded',
label: 'test-series',
operationType: 'formula',
params: {
format: {
Expand Down Expand Up @@ -322,6 +322,8 @@ export const sampleAttributeWithReferenceLines = {
isVisible: true,
position: 'right',
showSingleSeries: true,
legendSize: 'large',
shouldTruncate: false,
},
preferredSeriesType: 'line',
tickLabelsVisibilitySettings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ export function SeriesName({ series, seriesId }: Props) {
const onOutsideClick = (event: Event) => {
if (event.target !== buttonRef.current) {
setIsEditingEnabled(false);
onSave();
}
};

const onKeyDown: KeyboardEventHandler<HTMLInputElement> = (event) => {
if (event.key === 'Enter') {
setIsEditingEnabled(false);
onSave();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await PageObjects.header.waitUntilLoadingHasFinished();

expect(await find.existsByCssSelector('[title="Chrome Mobile iOS"]')).to.eql(true);
expect(await find.existsByCssSelector('[title="Mobile Safari"]')).to.eql(true);
expect(
await find.existsByCssSelector(
'[aria-label="Chrome Mobile iOS; Activate to hide series in graph"]'
)
).to.eql(true);
expect(
await find.existsByCssSelector(
'[aria-label="Mobile Safari; Activate to hide series in graph"]'
)
).to.eql(true);
});
});
}

0 comments on commit dba19ee

Please sign in to comment.