This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch PR/plainheart_fix/alignTicks-precision
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 7a8d38bae90dce8af628bab58f6c186125876e89
Author: 100pah <[email protected]>
AuthorDate: Fri Feb 27 22:31:35 2026 +0800

    fix: Fix inappropriate impl introduced by the previous commits.
---
 src/chart/custom/CustomView.ts            |  4 ++--
 src/component/axis/AxisBuilder.ts         |  4 ++--
 src/component/toolbox/feature/DataView.ts |  2 +-
 src/coord/Axis.ts                         |  2 +-
 src/coord/axisBand.ts                     | 20 +++++++++++++-------
 src/coord/axisHelper.ts                   |  3 +--
 src/layout/barGrid.ts                     | 18 ++++++++++++++----
 src/model/Series.ts                       |  1 -
 8 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts
index 066d24b9e..fe50f12ce 100644
--- a/src/chart/custom/CustomView.ts
+++ b/src/chart/custom/CustomView.ts
@@ -27,7 +27,7 @@ import * as labelStyleHelper from '../../label/labelStyle';
 import {getDefaultLabel} from '../helper/labelHelper';
 import {
     BarGridLayoutOptionForCustomSeries, BarGridLayoutResultForCustomSeries,
-    getLayoutOnAxis
+    computeBarLayoutForCustomSeries
 } from '../../layout/barGrid';
 import DataDiffer from '../../data/DataDiffer';
 import Model from '../../model/Model';
@@ -924,7 +924,7 @@ function makeRenderItem(
     ): BarGridLayoutResultForCustomSeries {
         if (coordSys.type === 'cartesian2d') {
             const baseAxis = coordSys.getBaseAxis() as Axis2D;
-            return getLayoutOnAxis(defaults({axis: baseAxis}, opt));
+            return computeBarLayoutForCustomSeries(defaults({axis: baseAxis}, 
opt));
         }
     }
 
diff --git a/src/component/axis/AxisBuilder.ts 
b/src/component/axis/AxisBuilder.ts
index 78fc96ea6..40783f067 100644
--- a/src/component/axis/AxisBuilder.ts
+++ b/src/component/axis/AxisBuilder.ts
@@ -1148,7 +1148,7 @@ function syncLabelIgnoreToMajorTicks(
     tickEls: graphic.Line[],
 ) {
     if (cfg.showMinorTicks) {
-        // It probably unreaasonable to hide major ticks when show minor ticks.
+        // It probably unreasonable to hide major ticks when show minor ticks.
         return;
     }
     each(labelLayoutList, labelLayout => {
@@ -1481,8 +1481,8 @@ function buildAxisLabel(
             eventData.value = rawLabel;
             eventData.tickIndex = index;
             const labelItemTickBreak = labelItem.tick.break;
-            const labelItemTickBreakParsedBreak = 
labelItemTickBreak.parsedBreak;
             if (labelItemTickBreak) {
+                const labelItemTickBreakParsedBreak = 
labelItemTickBreak.parsedBreak;
                 eventData.break = {
                     // type: labelItem.break.type,
                     start: labelItemTickBreakParsedBreak.vmin,
diff --git a/src/component/toolbox/feature/DataView.ts 
b/src/component/toolbox/feature/DataView.ts
index 391699197..def839af5 100644
--- a/src/component/toolbox/feature/DataView.ts
+++ b/src/component/toolbox/feature/DataView.ts
@@ -75,7 +75,7 @@ function groupSeries(ecModel: GlobalModel) {
         const coordSys = seriesModel.coordinateSystem;
 
         if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 
'polar')) {
-            // TODO: TYPE Consider polar? Include polar may increase 
unecessary bundle size.
+            // TODO: TYPE Consider polar? Include polar may increase 
unnecessary bundle size.
             const baseAxis = (coordSys as Cartesian2D).getBaseAxis();
             if (baseAxis.type === 'category') {
                 const key = getCartesianAxisHashKey(baseAxis);
diff --git a/src/coord/Axis.ts b/src/coord/Axis.ts
index b0370028f..ce36ee005 100644
--- a/src/coord/Axis.ts
+++ b/src/coord/Axis.ts
@@ -245,7 +245,7 @@ class Axis {
      * NOTICE: Can only be called after `adoptBandWidth` being called in 
`CoordinateSystem#update` stage.
      */
     getBandWidth(): number {
-        calcBandWidth(tmpOutBandWidth, this);
+        calcBandWidth(tmpOutBandWidth, this, true);
         // NOTICE: Do not add logic here. Implement everthing in 
`calcBandWidth`.
         return tmpOutBandWidth.bandWidth;
     }
diff --git a/src/coord/axisBand.ts b/src/coord/axisBand.ts
index 95edb208f..b90abc2ed 100644
--- a/src/coord/axisBand.ts
+++ b/src/coord/axisBand.ts
@@ -31,7 +31,8 @@ import { getScaleLinearSpanForMapping } from 
'../scale/scaleMapper';
 const SINGULAR_BAND_WIDTH_RATIO = 0.7;
 
 export type AxisBandWidthResult = {
-    // In px. May be NaN/null/undefined if no meaningfull bandWidth.
+    // In px. After the calling of `calcBandWidth`, it may be NaN if no 
meaningfull bandWidth,
+    // but never be null/undefined any more.
     bandWidth?: number | NullUndefined;
     kind?: AxisBandWidthKind;
     // If `AXIS_BAND_WIDTH_KIND_NORMAL`, this is a ratio from px span to data 
span, exists only if not singular.
@@ -66,15 +67,22 @@ export const AXIS_BAND_WIDTH_KIND_NORMAL = 2;
  */
 export function calcBandWidth(
     out: AxisBandWidthResult,
-    axis: Axis
+    axis: Axis,
+    useFallback: boolean
 ): void {
     // Clear out.
-    out.bandWidth = out.ratio = out.kind = undefined;
+    out.ratio = out.kind = undefined;
+    out.bandWidth = NaN;
 
     const scale = axis.scale;
 
     if (isOrdinalScale(scale)
-        || !calcBandWidthForNumericAxisIfPossible(out, axis, scale)
+        || (
+            !calcBandWidthForNumericAxisIfPossible(out, axis, scale)
+            // The fallback is only reasonable in several special cases (e.g., 
axis number is interger).
+            // So it is used only for backward compatibility.
+            && useFallback
+        )
     ) {
         calcBandWidthForCategoryAxisOrFallback(out, axis, scale);
     }
@@ -98,9 +106,7 @@ function calcBandWidthForCategoryAxisOrFallback(
     // Fix #2728, avoid NaN when only one data.
     len === 0 && (len = 1);
 
-    const size = Math.abs(axisExtent[1] - axisExtent[0]);
-
-    out.bandWidth = Math.abs(size) / len;
+    out.bandWidth = mathAbs(axisExtent[1] - axisExtent[0]) / len;
 }
 
 function calcBandWidthForNumericAxisIfPossible(
diff --git a/src/coord/axisHelper.ts b/src/coord/axisHelper.ts
index 8739c5ebf..455338964 100644
--- a/src/coord/axisHelper.ts
+++ b/src/coord/axisHelper.ts
@@ -38,7 +38,6 @@ import {
     AxisLabelFormatterExtraParams,
     OptionAxisType,
     AXIS_TYPES,
-    AxisShowMinMaxLabelOption,
 } from './axisCommonTypes';
 import SeriesData from '../data/SeriesData';
 import { getStackedDimension } from '../data/helper/dataStackHelper';
@@ -52,8 +51,8 @@ import {
 } from '../scale/helper';
 import { AxisModelExtendedInCreator } from './axisModelCreator';
 import { initExtentForUnion, makeInner } from '../util/model';
-import { ComponentModel } from '../echarts.simple';
 import { SCALE_EXTENT_KIND_EFFECTIVE, SCALE_MAPPER_DEPTH_OUT_OF_BREAK } from 
'../scale/scaleMapper';
+import ComponentModel from '../model/Component';
 
 
 const axisInner = makeInner<{
diff --git a/src/layout/barGrid.ts b/src/layout/barGrid.ts
index 6d1616fc1..9cd2c44b3 100644
--- a/src/layout/barGrid.ts
+++ b/src/layout/barGrid.ts
@@ -111,12 +111,22 @@ type BarGridLayoutResultItem = 
BarGridLayoutResultItemInternal & {
 export type BarGridLayoutResultForCustomSeries = BarGridLayoutResultItem[] | 
NullUndefined;
 
 /**
- * @return If axis.type is not 'category', return undefined.
+ * Return null/undefined if not 'category' axis.
+ *
+ * PENDING: The layout on non-'category' axis relies on `bandWidth`, which is 
calculated
+ * based on the `linearPositiveMinGap` of series data. This strategy is 
somewhat heuristic
+ * and will not be public to custom series until required in future. 
Additionally, more ec
+ * options may be introduced for that, because it requires 
`requireAxisStatistics` to be
+ * called on custom series that requires this feature.
  */
-export function getLayoutOnAxis(opt: BarGridLayoutOption): 
BarGridLayoutResultForCustomSeries {
+export function computeBarLayoutForCustomSeries(opt: BarGridLayoutOption): 
BarGridLayoutResultForCustomSeries {
+    if (!isOrdinalScale(opt.axis.scale)) {
+        return;
+    }
+
     const params: BarGridLayoutAxisSeriesInfo[] = [];
     const bandWidthResult: AxisBandWidthResult = {};
-    calcBandWidth(bandWidthResult, opt.axis);
+    calcBandWidth(bandWidthResult, opt.axis, false);
 
     for (let i = 0; i < opt.count || 0; i++) {
         params.push(defaults({
@@ -162,7 +172,7 @@ function createLayoutInfoListOnAxis(
 
     const seriesInfoOnAxis: BarGridLayoutAxisSeriesInfo[] = [];
     const bandWidthResult: AxisBandWidthResult = {};
-    calcBandWidth(bandWidthResult, baseAxis);
+    calcBandWidth(bandWidthResult, baseAxis, false);
     const bandWidth = bandWidthResult.bandWidth;
 
     eachCollectedSeries(baseAxis, axisStatKey(seriesType), function 
(seriesModel: BaseBarSeriesModel) {
diff --git a/src/model/Series.ts b/src/model/Series.ts
index f4fe5fb8d..5446cdccd 100644
--- a/src/model/Series.ts
+++ b/src/model/Series.ts
@@ -434,7 +434,6 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> 
extends ComponentMode
      */
     getBaseAxis(): Axis {
         const coordSys = this.coordinateSystem;
-        // @ts-ignore
         return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to