Skip to content

Commit 2da3404

Browse files
fix(config): add additional property to control extension
1 parent 43cd481 commit 2da3404

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Diff for: packages/core/src/components/axes/axis.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,20 @@ export class Axis extends Component {
148148

149149
if (axisOptions.scaleType === ScaleTypes.TIME) {
150150
if (Tools.getProperty(options, "timeScale", "addSpaceOnEdges")) {
151+
const timeRangeToExtend = Tools.getProperty(options, "timeScale", "timeRangeToExtend")
151152
const startDate = new Date(domain[0]);
152153
const endDate = new Date(domain[1]);
153-
if (differenceInYears(endDate, startDate) > 3) {
154+
if (differenceInYears(endDate, startDate) > timeRangeToExtend) {
154155
return [subYears(startDate, 1), addYears(endDate, 1)];
155156
}
156-
if (differenceInMonths(endDate, startDate) > 3) {
157+
if (differenceInMonths(endDate, startDate) > timeRangeToExtend) {
157158
return [subMonths(startDate, 1), addMonths(endDate, 1)];
158159
}
159-
if (differenceInDays(endDate, startDate) > 3) {
160+
if (differenceInDays(endDate, startDate) > timeRangeToExtend) {
160161
return [subDays(startDate, 1), addDays(endDate, 1)];
161-
} else if (differenceInHours(endDate, startDate) > 3) {
162+
} else if (differenceInHours(endDate, startDate) > timeRangeToExtend) {
162163
return [subHours(startDate, 1), addHours(endDate, 1)];
163-
} else if (differenceInMinutes(endDate, startDate) > 3) {
164+
} else if (differenceInMinutes(endDate, startDate) > timeRangeToExtend) {
164165
return [subMinutes(startDate, 1), addMinutes(endDate, 1)];
165166
}
166167
// Other

Diff for: packages/core/src/configuration.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export const barChartTooltip: BarTooltipOptions = Tools.merge({}, axisChartToolt
9595
const axes: AxesOptions = { };
9696

9797
const timeScale: TimeScaleOptions = {
98-
addSpaceOnEdges: true
98+
addSpaceOnEdges: true,
99+
// Only extends the axes if the timerange is greater than this amount
100+
timeRangeToExtend: 3
99101
};
100102

101103
/**

Diff for: packages/core/src/interfaces/axis-scales.ts

+1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ export interface AxesOptions {
5757
*/
5858
export interface TimeScaleOptions {
5959
addSpaceOnEdges?: boolean;
60+
timeRangeToExtend?: number;
6061
}

0 commit comments

Comments
 (0)