diff --git a/x-pack/plugins/lens/public/xy_visualization/__snapshots__/expression.test.tsx.snap b/x-pack/plugins/lens/public/xy_visualization/__snapshots__/expression.test.tsx.snap index 9a32f1c3311522..a2047b7bae669b 100644 --- a/x-pack/plugins/lens/public/xy_visualization/__snapshots__/expression.test.tsx.snap +++ b/x-pack/plugins/lens/public/xy_visualization/__snapshots__/expression.test.tsx.snap @@ -26,13 +26,6 @@ exports[`xy_expression XYChart component it renders area 1`] = ` "headerFormatter": [Function], } } - xDomain={ - Object { - "max": undefined, - "min": undefined, - "minInterval": 50, - } - } /> { }); }); - test('it does not use date range if the x is not a time scale', () => { + test('it has xDomain undefined if the x is not a time scale or a histogram', () => { const { data, args } = sampleArgs(); const component = shallow( @@ -571,15 +571,10 @@ describe('xy_expression', () => { /> ); const xDomain = component.find(Settings).prop('xDomain'); - expect(xDomain).toEqual( - expect.objectContaining({ - min: undefined, - max: undefined, - }) - ); + expect(xDomain).toEqual(undefined); }); - test('it uses min interval if passed in', () => { + test('it uses min interval if interval is passed in and visualization is histogram', () => { const { data, args } = sampleArgs(); const component = shallow( @@ -589,7 +584,9 @@ describe('xy_expression', () => { data={data} args={{ ...args, - layers: [{ ...args.layers[0], seriesType: 'line', xScaleType: 'linear' }], + layers: [ + { ...args.layers[0], seriesType: 'line', xScaleType: 'linear', isHistogram: true }, + ], }} /> ); diff --git a/x-pack/plugins/lens/public/xy_visualization/expression.tsx b/x-pack/plugins/lens/public/xy_visualization/expression.tsx index eda08715b394e9..c5e7b0af9654f5 100644 --- a/x-pack/plugins/lens/public/xy_visualization/expression.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/expression.tsx @@ -388,11 +388,15 @@ export function XYChart({ const isTimeViz = data.dateRange && filteredLayers.every((l) => l.xScaleType === 'time'); const isHistogramViz = filteredLayers.every((l) => l.isHistogram); - const xDomain = { - min: isTimeViz ? data.dateRange?.fromDate.getTime() : undefined, - max: isTimeViz ? data.dateRange?.toDate.getTime() : undefined, - minInterval, - }; + const xDomain = isTimeViz + ? { + min: data.dateRange?.fromDate.getTime(), + max: data.dateRange?.toDate.getTime(), + minInterval, + } + : isHistogramViz + ? { minInterval } + : undefined; const getYAxesTitles = ( axisSeries: Array<{ layer: string; accessor: string }>,