Skip to content

Commit 8d970df

Browse files
authored
Merge pull request #4463 from jeclrsg/fix-eclwatch-timeline-formatting
fix(timeline): fix tickFormat being ignored
2 parents 9635092 + d5d13fb commit 8d970df

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

packages/chart/src/Axis.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ export interface Axis {
676676
tickFormat(): string;
677677
tickFormat(_: string): this;
678678
tickFormat_exists(): boolean;
679+
tickFormat_reset(): void;
679680
tickLength(): number;
680681
tickLength(_: number): this;
681682
tickLength_exists(): boolean;

packages/timeline/src/ReactTimeline.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,33 @@ 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+
} else {
69+
this._topAxis.tickFormat_reset();
70+
this._bottomAxis.tickFormat_reset();
71+
}
6172
this._gantt._minStart = minTimestamp;
6273
this._gantt._maxEnd = maxTimestamp;
6374
}

packages/timeline/src/ReactTimelineSeries.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,33 @@ 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+
} else {
68+
this._topAxis.tickFormat_reset();
69+
this._bottomAxis.tickFormat_reset();
70+
}
6071
this._gantt._minStart = minTimestamp;
6172
this._gantt._maxEnd = maxTimestamp;
6273
}

0 commit comments

Comments
 (0)