From 9a9e703b2d04b141a59420f86bd37dc6d4fd29dd Mon Sep 17 00:00:00 2001 From: lichengzhan Date: Wed, 19 Mar 2025 20:36:57 +0800 Subject: [PATCH] fix: correct the width calculation of a axis label with show(Max|Min)Label false Fix an issue where the label width is calculated incorrectly when the axis showMinLabel and showMaxLabel work with containLabel --- src/coord/axisHelper.ts | 11 ++ test/axis-showMinMaxLabel.html | 188 +++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 test/axis-showMinMaxLabel.html diff --git a/src/coord/axisHelper.ts b/src/coord/axisHelper.ts index 76d42a8d16..a3a5709cd0 100644 --- a/src/coord/axisHelper.ts +++ b/src/coord/axisHelper.ts @@ -324,7 +324,18 @@ export function estimateLabelUnionRect(axis: Axis) { if (tickCount > 40) { step = Math.ceil(tickCount / 40); } + const showMinLabel = axisLabelModel.get('showMinLabel'); + const showMaxLabel = axisLabelModel.get('showMaxLabel'); for (let i = 0; i < tickCount; i += step) { + if (showMinLabel === false && i === 0) { + continue; + } + // If the showMaxLabel is set to false and the current index plus the step size + // is less than the total length of Computation of Large Label Compatible with + // Large Data Volume, skip + if (showMaxLabel === false && !(i + step < tickCount)) { + continue; + } const tick = realNumberScaleTicks ? realNumberScaleTicks[i] : { diff --git a/test/axis-showMinMaxLabel.html b/test/axis-showMinMaxLabel.html new file mode 100644 index 0000000000..95b501adbf --- /dev/null +++ b/test/axis-showMinMaxLabel.html @@ -0,0 +1,188 @@ + + + + + + + + + + + + +
+
测试坐标轴最大最小值标签显示
+
+
+
+
+
+ + + +