From 67c0f7b5154b12f40fc27c56460ec6061a4c92ce Mon Sep 17 00:00:00 2001 From: Andrew Tate Date: Wed, 1 Dec 2021 09:03:59 -0600 Subject: [PATCH] Preserve color state when generating XY suggestions --- .../lens/public/xy_visualization/xy_suggestions.test.ts | 5 +++++ .../plugins/lens/public/xy_visualization/xy_suggestions.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.test.ts b/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.test.ts index d7b48553ce73a..d16227d0b23d8 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.test.ts +++ b/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.test.ts @@ -637,6 +637,7 @@ describe('xy_suggestions', () => { valueLabels: 'hide', fittingFunction: 'None', axisTitlesVisibilitySettings: { x: true, yLeft: true, yRight: true }, + axisColors: { x: '#123456', yLeft: '#123456', yRight: '#123456' }, gridlinesVisibilitySettings: { x: true, yLeft: true, yRight: true }, tickLabelsVisibilitySettings: { x: true, yLeft: false, yRight: false }, labelsOrientation: { x: 0, yLeft: -45, yRight: -45 }, @@ -681,6 +682,7 @@ describe('xy_suggestions', () => { preferredSeriesType: 'bar', fittingFunction: 'None', axisTitlesVisibilitySettings: { x: true, yLeft: true, yRight: true }, + axisColors: { x: '#123456', yLeft: '#123456', yRight: '#123456' }, gridlinesVisibilitySettings: { x: true, yLeft: true, yRight: true }, tickLabelsVisibilitySettings: { x: true, yLeft: false, yRight: false }, labelsOrientation: { x: 0, yLeft: -45, yRight: -45 }, @@ -800,6 +802,7 @@ describe('xy_suggestions', () => { preferredSeriesType: 'bar', fittingFunction: 'None', axisTitlesVisibilitySettings: { x: true, yLeft: true, yRight: true }, + axisColors: { x: '#123456', yLeft: '#123456', yRight: '#123456' }, gridlinesVisibilitySettings: { x: true, yLeft: true, yRight: true }, tickLabelsVisibilitySettings: { x: true, yLeft: false, yRight: false }, labelsOrientation: { x: 0, yLeft: -45, yRight: -45 }, @@ -845,6 +848,7 @@ describe('xy_suggestions', () => { preferredSeriesType: 'bar', fittingFunction: 'None', axisTitlesVisibilitySettings: { x: true, yLeft: true, yRight: true }, + axisColors: { x: '#123456', yLeft: '#123456', yRight: '#123456' }, gridlinesVisibilitySettings: { x: true, yLeft: true, yRight: true }, tickLabelsVisibilitySettings: { x: true, yLeft: false, yRight: false }, labelsOrientation: { x: 0, yLeft: -45, yRight: -45 }, @@ -891,6 +895,7 @@ describe('xy_suggestions', () => { preferredSeriesType: 'bar', fittingFunction: 'None', axisTitlesVisibilitySettings: { x: true, yLeft: true, yRight: true }, + axisColors: { x: '#123456', yLeft: '#123456', yRight: '#123456' }, gridlinesVisibilitySettings: { x: true, yLeft: true, yRight: true }, tickLabelsVisibilitySettings: { x: true, yLeft: false, yRight: false }, labelsOrientation: { x: 0, yLeft: -45, yRight: -45 }, diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts b/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts index 2e275c455a4d0..3ae587fdd52da 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts +++ b/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts @@ -20,6 +20,7 @@ import { State, XYState, visualizationTypes } from './types'; import type { SeriesType, XYLayerConfig } from '../../common/expressions'; import { layerTypes } from '../../common'; import { getIconForSeries } from './state_helpers'; +import { defaultAxisLineColor } from './color_assignment'; const columnSortOrder = { document: 0, @@ -540,6 +541,11 @@ function buildSuggestion({ yLeft: true, yRight: true, }, + axisColors: currentState?.axisColors || { + x: defaultAxisLineColor, + yLeft: defaultAxisLineColor, + yRight: defaultAxisLineColor, + }, tickLabelsVisibilitySettings: currentState?.tickLabelsVisibilitySettings || { x: true, yLeft: true,