diff --git a/src/plugins/vis_augmenter/public/utils/utils.test.ts b/src/plugins/vis_augmenter/public/utils/utils.test.ts index 250e17e8d595..06249cc088a6 100644 --- a/src/plugins/vis_augmenter/public/utils/utils.test.ts +++ b/src/plugins/vis_augmenter/public/utils/utils.test.ts @@ -239,6 +239,22 @@ describe('utils', () => { } as unknown) as Vis; expect(isEligibleForVisLayers(invalidVis)).toEqual(false); }); + it('vis is ineligible with no seriesParams', async () => { + const invalidVis = ({ + params: { + type: 'pie', + categoryAxes: [ + { + position: 'bottom', + }, + ], + }, + data: { + aggs: VALID_AGGS, + }, + } as unknown) as Vis; + expect(isEligibleForVisLayers(invalidVis)).toEqual(false); + }); it('vis is ineligible with valid type and disabled setting', async () => { uiSettingsMock.get.mockImplementation((key: string) => { return key !== PLUGIN_AUGMENTATION_ENABLE_SETTING; diff --git a/src/plugins/vis_augmenter/public/utils/utils.ts b/src/plugins/vis_augmenter/public/utils/utils.ts index 907867630cbe..702c83a6b59c 100644 --- a/src/plugins/vis_augmenter/public/utils/utils.ts +++ b/src/plugins/vis_augmenter/public/utils/utils.ts @@ -11,7 +11,6 @@ import { buildExpression, ExpressionAstFunctionBuilder, } from '../../../../plugins/expressions/public'; -import { SavedObjectLoader } from '../../../../plugins/saved_objects/public'; import { ISavedAugmentVis, SavedAugmentVisLoader, @@ -28,7 +27,7 @@ export const isEligibleForVisLayers = (vis: Vis): boolean => { // Only support date histogram and ensure there is only 1 x-axis and it has to be on the bottom. // Additionally to have a valid x-axis, there needs to be a segment aggregation const hasValidXaxis = - vis.data.aggs !== undefined && + vis.data?.aggs !== undefined && vis.data.aggs?.byTypeName('date_histogram').length === 1 && vis.params.categoryAxes.length === 1 && vis.params.categoryAxes[0].position === 'bottom' && @@ -37,12 +36,13 @@ export const isEligibleForVisLayers = (vis: Vis): boolean => { // multiple supported yaxis only. If there are other aggregation types, this is not // valid for augmentation const hasCorrectAggregationCount = - vis.data.aggs !== undefined && + vis.data?.aggs !== undefined && vis.data.aggs?.bySchemaName('metric').length > 0 && vis.data.aggs?.bySchemaName('metric').length === vis.data.aggs?.aggs.length - 1; const hasOnlyLineSeries = - vis.params.seriesParams.every((seriesParam: { type: string }) => seriesParam.type === 'line') && - vis.params.type === 'line'; + vis.params?.seriesParams?.every( + (seriesParam: { type: string }) => seriesParam.type === 'line' + ) && vis.params?.type === 'line'; // Checks if the augmentation setting is enabled const config = getUISettings(); const isAugmentationEnabled = config.get(PLUGIN_AUGMENTATION_ENABLE_SETTING); diff --git a/src/plugins/vis_type_vega/public/vega_view/vega_view.js b/src/plugins/vis_type_vega/public/vega_view/vega_view.js index cf49ed4a5470..9a1bc6bcb946 100644 --- a/src/plugins/vis_type_vega/public/vega_view/vega_view.js +++ b/src/plugins/vis_type_vega/public/vega_view/vega_view.js @@ -91,7 +91,11 @@ export class VegaView extends VegaBaseView { // to align the data / events. We do this by checking if padding is needed on the left // and/or right, and adding padding based on the y axis config. left: - leftValueAxisPadding && flyoutContext === VisFlyoutContext.EVENT_VIS ? yAxisPadding : 0, + leftValueAxisPadding && + (flyoutContext === VisFlyoutContext.EVENT_VIS || + flyoutContext === VisFlyoutContext.TIMELINE_VIS) + ? yAxisPadding + : 0, right: rightValueAxisPadding && flyoutContext === VisFlyoutContext.EVENT_VIS ? yAxisPadding