From 0c908241d8cf6ee2e3daf26c0582fae40061179f Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 10 May 2024 14:53:21 +0800 Subject: [PATCH] fix: fix failed test cases and improve code --- src/coord/axisTickLabelBuilder.ts | 12 +----------- test/axis-customTicks.html | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/coord/axisTickLabelBuilder.ts b/src/coord/axisTickLabelBuilder.ts index dcd9febd7e..e7f7bbb088 100644 --- a/src/coord/axisTickLabelBuilder.ts +++ b/src/coord/axisTickLabelBuilder.ts @@ -61,17 +61,7 @@ type InnerStore = { const inner = makeInner(); function tickValuesToNumbers(axis: Axis, values: (number | string | Date)[]) { - const nums = values.map(val => { - if (zrUtil.isString(val)) { - return axis.model.get('data').indexOf(val); - } - else if (val instanceof Date) { - return val.getTime(); - } - else { - return val; - } - }); + const nums = zrUtil.map(values, val => axis.scale.parse(val)); if (axis.type === 'time' && nums.length > 0) { // Time axis needs duplicate first/last tick (see TimeScale.getTicks()) // The first and last tick/label don't get drawn diff --git a/test/axis-customTicks.html b/test/axis-customTicks.html index d11ec2972c..24f9c7dc97 100644 --- a/test/axis-customTicks.html +++ b/test/axis-customTicks.html @@ -23,7 +23,7 @@ - +