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; }