Skip to content

Commit

Permalink
Turned back removed extentValidation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed May 4, 2022
1 parent b610f14 commit 4c8624f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
getAxesConfiguration,
GroupsConfiguration,
getLinesCausedPaddings,
validateExtent,
} from '../helpers';
import { getXDomain, XyEndzones } from './x_domain';
import { getLegendAction } from './legend_action';
Expand Down Expand Up @@ -321,8 +322,11 @@ export function XYChart({
let min: number = NaN;
let max: number = NaN;
if (extent.mode === 'custom') {
min = extent.lowerBound ?? NaN;
max = extent.upperBound ?? NaN;
const { inclusiveZeroError, boundaryError } = validateExtent(hasBarOrArea, extent);
if (!inclusiveZeroError && !boundaryError) {
min = extent.lowerBound ?? NaN;
max = extent.upperBound ?? NaN;
}
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import type { IFieldFormat, SerializedFieldFormat } from '@kbn/field-formats-plugin/common';
import { FormatFactory } from '../types';
import { CommonXYDataLayerConfig, ExtendedYConfig, YConfig } from '../../common';
import { AxisExtentConfig, CommonXYDataLayerConfig, ExtendedYConfig, YConfig } from '../../common';
import { isDataLayer } from './visualization';

export interface Series {
Expand Down Expand Up @@ -132,3 +132,17 @@ export function getAxesConfiguration(

return axisGroups;
}

export function validateExtent(hasBarOrArea: boolean, extent?: AxisExtentConfig) {
const inclusiveZeroError =
extent &&
hasBarOrArea &&
((extent.lowerBound !== undefined && extent.lowerBound > 0) ||
(extent.upperBound !== undefined && extent.upperBound) < 0);
const boundaryError =
extent &&
extent.lowerBound !== undefined &&
extent.upperBound !== undefined &&
extent.upperBound <= extent.lowerBound;
return { inclusiveZeroError, boundaryError };
}

0 comments on commit 4c8624f

Please sign in to comment.