Skip to content

Commit

Permalink
[Lens] Remove warning about ordinal x-domain (#93049)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Mar 2, 2021
1 parent a7b50c1 commit cc0dd76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 63 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions x-pack/plugins/lens/public/xy_visualization/expression.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ describe('xy_expression', () => {
});
});

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(
Expand All @@ -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(
Expand All @@ -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 },
],
}}
/>
);
Expand Down
14 changes: 9 additions & 5 deletions x-pack/plugins/lens/public/xy_visualization/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>,
Expand Down

0 comments on commit cc0dd76

Please sign in to comment.