Skip to content

Commit bda790a

Browse files
committed
fix(timeline): fix tickFormat being ignored
Fixes an issue where tickFormat called by consumers of this component was being ignored / overwritten by _axisLabelFormatter. This resulted in d3-time-format defaulting back to it's 12-hour "AM/PM" notation Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com>
1 parent 9635092 commit bda790a

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

packages/timeline/src/ReactTimeline.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,30 @@ export class ReactTimeline extends ReactAxisGantt {
4242
highDateStr = "" + n[2];
4343
}
4444
});
45+
46+
const axisTickFormat = this._axisLabelFormatter
47+
? this._axisLabelFormatter
48+
: (this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : undefined);
49+
4550
this._topAxis
4651
.type("time")
4752
.timePattern(this.timePattern())
4853
.overlapMode("none")
49-
.tickFormat(this._axisLabelFormatter)
5054
.low(lowDateStr)
5155
.high(highDateStr)
5256
;
5357
this._bottomAxis
5458
.type("time")
5559
.timePattern(this.timePattern())
5660
.overlapMode("none")
57-
.tickFormat(this._axisLabelFormatter)
5861
.low(lowDateStr)
5962
.high(highDateStr)
6063
;
64+
65+
if (axisTickFormat) {
66+
this._topAxis.tickFormat(axisTickFormat);
67+
this._bottomAxis.tickFormat(axisTickFormat);
68+
}
6169
this._gantt._minStart = minTimestamp;
6270
this._gantt._maxEnd = maxTimestamp;
6371
}

packages/timeline/src/ReactTimelineSeries.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,30 @@ export class ReactTimelineSeries extends ReactAxisGanttSeries {
4141
highDateStr = "" + n[2];
4242
}
4343
});
44+
45+
const axisTickFormat = this._axisLabelFormatter
46+
? this._axisLabelFormatter
47+
: (this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : undefined);
48+
4449
this._topAxis
4550
.type("time")
4651
.timePattern(this.timePattern())
4752
.overlapMode("none")
48-
.tickFormat(this._axisLabelFormatter)
4953
.low(lowDateStr)
5054
.high(highDateStr)
5155
;
5256
this._bottomAxis
5357
.type("time")
5458
.timePattern(this.timePattern())
5559
.overlapMode("none")
56-
.tickFormat(this._axisLabelFormatter)
5760
.low(lowDateStr)
5861
.high(highDateStr)
5962
;
63+
64+
if (axisTickFormat) {
65+
this._topAxis.tickFormat(axisTickFormat);
66+
this._bottomAxis.tickFormat(axisTickFormat);
67+
}
6068
this._gantt._minStart = minTimestamp;
6169
this._gantt._maxEnd = maxTimestamp;
6270
}

0 commit comments

Comments
 (0)