Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Lens] Remove warning about ordinal x-domain (#93049) #93212

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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