[Observability] [Exploratory View] only show y axis label for a single series (#113989)

This commit is contained in:
Dominique Clarke 2021-10-07 08:10:46 -04:00 committed by GitHub
parent d65715b6d7
commit 7f1adb8d95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -246,6 +246,24 @@ describe('Lens Attribute', () => {
});
});
it('should hide y axis when there are multiple series', function () {
const lensAttrWithMultiSeries = new LensAttributes([layerConfig, layerConfig]).getJSON() as any;
expect(lensAttrWithMultiSeries.state.visualization.axisTitlesVisibilitySettings).toEqual({
x: true,
yLeft: false,
yRight: false,
});
});
it('should show y axis when there is a single series', function () {
const lensAttrWithMultiSeries = new LensAttributes([layerConfig]).getJSON() as any;
expect(lensAttrWithMultiSeries.state.visualization.axisTitlesVisibilitySettings).toEqual({
x: true,
yLeft: true,
yRight: true,
});
});
it('should return first layer', function () {
expect(lnsAttr.getLayers()).toEqual({
layer0: {

View file

@ -98,6 +98,7 @@ export class LensAttributes {
layers: Record<string, PersistedIndexPatternLayer>;
visualization: XYState;
layerConfigs: LayerConfig[];
isMultiSeries: boolean;
constructor(layerConfigs: LayerConfig[]) {
this.layers = {};
@ -114,6 +115,7 @@ export class LensAttributes {
});
this.layerConfigs = layerConfigs;
this.isMultiSeries = layerConfigs.length > 1;
this.layers = this.getLayers();
this.visualization = this.getXyState();
}
@ -612,7 +614,11 @@ export class LensAttributes {
valueLabels: 'hide',
fittingFunction: 'Linear',
curveType: 'CURVE_MONOTONE_X' as XYCurveType,
axisTitlesVisibilitySettings: { x: true, yLeft: true, yRight: true },
axisTitlesVisibilitySettings: {
x: true,
yLeft: !this.isMultiSeries,
yRight: !this.isMultiSeries,
},
tickLabelsVisibilitySettings: { x: true, yLeft: true, yRight: true },
gridlinesVisibilitySettings: { x: true, yLeft: true, yRight: true },
preferredSeriesType: 'line',