From d5d13fb652e2fe6055b6bd8c4052c37d76e3cf98 Mon Sep 17 00:00:00 2001 From: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> Date: Mon, 13 Oct 2025 12:34:19 -0400 Subject: [PATCH] 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> --- packages/chart/src/Axis.ts | 1 + packages/timeline/src/ReactTimeline.ts | 15 +++++++++++++-- packages/timeline/src/ReactTimelineSeries.ts | 15 +++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/chart/src/Axis.ts b/packages/chart/src/Axis.ts index 8ffd7f3753..7d852ebe98 100644 --- a/packages/chart/src/Axis.ts +++ b/packages/chart/src/Axis.ts @@ -676,6 +676,7 @@ export interface Axis { tickFormat(): string; tickFormat(_: string): this; tickFormat_exists(): boolean; + tickFormat_reset(): void; tickLength(): number; tickLength(_: number): this; tickLength_exists(): boolean; diff --git a/packages/timeline/src/ReactTimeline.ts b/packages/timeline/src/ReactTimeline.ts index 9e0f28c585..22bb07205a 100644 --- a/packages/timeline/src/ReactTimeline.ts +++ b/packages/timeline/src/ReactTimeline.ts @@ -42,11 +42,15 @@ export class ReactTimeline extends ReactAxisGantt { highDateStr = "" + n[2]; } }); + + const axisTickFormat = this._axisLabelFormatter + ? this._axisLabelFormatter + : (this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : undefined); + this._topAxis .type("time") .timePattern(this.timePattern()) .overlapMode("none") - .tickFormat(this._axisLabelFormatter) .low(lowDateStr) .high(highDateStr) ; @@ -54,10 +58,17 @@ export class ReactTimeline extends ReactAxisGantt { .type("time") .timePattern(this.timePattern()) .overlapMode("none") - .tickFormat(this._axisLabelFormatter) .low(lowDateStr) .high(highDateStr) ; + + if (axisTickFormat) { + this._topAxis.tickFormat(axisTickFormat); + this._bottomAxis.tickFormat(axisTickFormat); + } else { + this._topAxis.tickFormat_reset(); + this._bottomAxis.tickFormat_reset(); + } this._gantt._minStart = minTimestamp; this._gantt._maxEnd = maxTimestamp; } diff --git a/packages/timeline/src/ReactTimelineSeries.ts b/packages/timeline/src/ReactTimelineSeries.ts index be5635ee8e..310056fb7f 100644 --- a/packages/timeline/src/ReactTimelineSeries.ts +++ b/packages/timeline/src/ReactTimelineSeries.ts @@ -41,11 +41,15 @@ export class ReactTimelineSeries extends ReactAxisGanttSeries { highDateStr = "" + n[2]; } }); + + const axisTickFormat = this._axisLabelFormatter + ? this._axisLabelFormatter + : (this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : undefined); + this._topAxis .type("time") .timePattern(this.timePattern()) .overlapMode("none") - .tickFormat(this._axisLabelFormatter) .low(lowDateStr) .high(highDateStr) ; @@ -53,10 +57,17 @@ export class ReactTimelineSeries extends ReactAxisGanttSeries { .type("time") .timePattern(this.timePattern()) .overlapMode("none") - .tickFormat(this._axisLabelFormatter) .low(lowDateStr) .high(highDateStr) ; + + if (axisTickFormat) { + this._topAxis.tickFormat(axisTickFormat); + this._bottomAxis.tickFormat(axisTickFormat); + } else { + this._topAxis.tickFormat_reset(); + this._bottomAxis.tickFormat_reset(); + } this._gantt._minStart = minTimestamp; this._gantt._maxEnd = maxTimestamp; }