diff --git a/packages/core/src/components/axes/axis.ts b/packages/core/src/components/axes/axis.ts index 0766bf83a1..89357eb6ce 100644 --- a/packages/core/src/components/axes/axis.ts +++ b/packages/core/src/components/axes/axis.ts @@ -147,22 +147,22 @@ export class Axis extends Component { } if (axisOptions.scaleType === ScaleTypes.TIME) { - if (Tools.getProperty(options, "timeScale", "addSpaceOnEdges")) { - const timeRangeToExtend = Tools.getProperty(options, "timeScale", "timeRangeToExtend"); + const spaceToAddToEdges = Tools.getProperty(options, "timeScale", "addSpaceOnEdges"); + if (spaceToAddToEdges) { const startDate = new Date(domain[0]); const endDate = new Date(domain[1]); - if (differenceInYears(endDate, startDate) > timeRangeToExtend) { - return [subYears(startDate, 1), addYears(endDate, 1)]; + if (differenceInYears(endDate, startDate) > 1) { + return [subYears(startDate, spaceToAddToEdges), addYears(endDate, spaceToAddToEdges)]; } - if (differenceInMonths(endDate, startDate) > timeRangeToExtend) { - return [subMonths(startDate, 1), addMonths(endDate, 1)]; + if (differenceInMonths(endDate, startDate) > 1) { + return [subMonths(startDate, spaceToAddToEdges), addMonths(endDate, spaceToAddToEdges)]; } - if (differenceInDays(endDate, startDate) > timeRangeToExtend) { - return [subDays(startDate, 1), addDays(endDate, 1)]; - } else if (differenceInHours(endDate, startDate) > timeRangeToExtend) { - return [subHours(startDate, 1), addHours(endDate, 1)]; - } else if (differenceInMinutes(endDate, startDate) > timeRangeToExtend) { - return [subMinutes(startDate, 1), addMinutes(endDate, 1)]; + if (differenceInDays(endDate, startDate) > 1) { + return [subDays(startDate, spaceToAddToEdges), addDays(endDate, spaceToAddToEdges)]; + } else if (differenceInHours(endDate, startDate) > 1) { + return [subHours(startDate, spaceToAddToEdges), addHours(endDate, spaceToAddToEdges)]; + } else if (differenceInMinutes(endDate, startDate) > 1) { + return [subMinutes(startDate, spaceToAddToEdges), addMinutes(endDate, spaceToAddToEdges)]; } // Other return [startDate, endDate]; diff --git a/packages/core/src/configuration.ts b/packages/core/src/configuration.ts index 92695d5645..fc44641a8c 100644 --- a/packages/core/src/configuration.ts +++ b/packages/core/src/configuration.ts @@ -95,9 +95,7 @@ export const barChartTooltip: BarTooltipOptions = Tools.merge({}, axisChartToolt const axes: AxesOptions = { }; const timeScale: TimeScaleOptions = { - addSpaceOnEdges: true, - // Only extends the axes if the timerange is greater than this amount - timeRangeToExtend: 3 + addSpaceOnEdges: 1, }; /** diff --git a/packages/core/src/interfaces/axis-scales.ts b/packages/core/src/interfaces/axis-scales.ts index a8d4252b4d..13b21787e2 100644 --- a/packages/core/src/interfaces/axis-scales.ts +++ b/packages/core/src/interfaces/axis-scales.ts @@ -56,6 +56,5 @@ export interface AxesOptions { * customize time series scales */ export interface TimeScaleOptions { - addSpaceOnEdges?: boolean; - timeRangeToExtend?: number; + addSpaceOnEdges?: number; }