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

sushuang pushed a commit to branch fix/contain-label-name
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 59e89af29baeae2cec922b39ba02b5db2e1dfa3f
Author: 100pah <[email protected]>
AuthorDate: Tue Jun 24 11:58:59 2025 +0800

    feat(grid layout): adapt to matrix layout.
---
 src/component/axis/AxisBuilder.ts | 12 ++++++++++--
 src/coord/cartesian/Grid.ts       | 12 ++++++++----
 src/util/layout.ts                |  2 +-
 test/matrix3.html                 |  3 ++-
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/component/axis/AxisBuilder.ts 
b/src/component/axis/AxisBuilder.ts
index 23fc61a90..e9fdbba89 100644
--- a/src/component/axis/AxisBuilder.ts
+++ b/src/component/axis/AxisBuilder.ts
@@ -21,6 +21,7 @@ import {
     retrieve, defaults, extend, each, isObject, isString, isNumber, 
isFunction, retrieve2,
     assert,
     map,
+    retrieve3,
 } from 'zrender/src/core/util';
 import * as graphic from '../../util/graphic';
 import {getECData} from '../../util/innerStore';
@@ -484,7 +485,14 @@ class AxisBuilder {
 
     private _resetCfgDetermined(raw: AxisBuilderCfg): void {
         const axisModel = this._axisModel;
-        const axisModelDefaultOption = axisModel.getDefaultOption();
+
+        // FIXME:
+        //  Currently there is no uniformed way to set default values if an 
option
+        //  is specified null/undefined by user (intentionally or 
unintentionally),
+        //  e.g. null/undefined is not a illegal value for `nameLocation`.
+        //  Try to use `getDefaultOption` to address it. But radar has no 
`getDefaultOption`.
+        const axisModelDefaultOption = axisModel.getDefaultOption ? 
axisModel.getDefaultOption() : {};
+
         // Default value
         const axisName = retrieve2(raw.axisName, axisModel.get('name'));
         const cfg = {
@@ -501,7 +509,7 @@ class AxisBuilder {
             silent: retrieve2(raw.silent, true),
 
             axisName: axisName,
-            nameLocation: retrieve2(axisModel.get('nameLocation'), 
axisModelDefaultOption.nameLocation),
+            nameLocation: retrieve3(axisModel.get('nameLocation'), 
axisModelDefaultOption.nameLocation, 'end'),
             shouldNameMoveOverlap: hasAxisName(axisName) && 
!!axisModel.get('nameMoveOverlap'),
             optionHideOverlap: axisModel.get(['axisLabel', 'hideOverlap']),
         };
diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts
index 49d708a63..52f61e09d 100644
--- a/src/coord/cartesian/Grid.ts
+++ b/src/coord/cartesian/Grid.ts
@@ -24,7 +24,7 @@
  */
 
 import {isObject, each, indexOf, retrieve3, keys, assert} from 
'zrender/src/core/util';
-import {createBoxLayoutReference, getLayoutRect, LayoutRect} from 
'../../util/layout';
+import {BoxLayoutReferenceResult, createBoxLayoutReference, getLayoutRect, 
LayoutRect} from '../../util/layout';
 import {
     createScaleByModel,
     ifAxisCrossZero,
@@ -233,7 +233,9 @@ class Grid implements CoordinateSystemMaster {
                 }
             }
             else {
-                const {outerBoundsRect, parsedOuterBoundsContain} = 
prepareOuterBounds(gridModel, gridRect, api);
+                const {outerBoundsRect, parsedOuterBoundsContain} = 
prepareOuterBounds(
+                    gridModel, gridRect, layoutRef, api
+                );
                 if (outerBoundsRect) {
                     // console.time('layOutGridByOuterBounds');
                     noPxChange = layOutGridByOuterBounds(outerBoundsRect, 
parsedOuterBoundsContain, gridRect, axesMap);
@@ -845,6 +847,7 @@ function createOrUpdateAxesView(
 function prepareOuterBounds(
     gridModel: GridModel,
     gridRect: BoundingRect,
+    layoutRef: BoxLayoutReferenceResult,
     api: ExtensionAPI
 ): {
     outerBoundsRect: BoundingRect | NullUndefined
@@ -856,8 +859,9 @@ function prepareOuterBounds(
         outerBoundsRect = gridRect.clone();
     }
     else if (optionOuterBoundsMode == null || optionOuterBoundsMode === 
'auto') {
-        const refContainer = {width: api.getWidth(), height: api.getHeight()};
-        outerBoundsRect = getLayoutRect(gridModel.get('outerBounds', true) || 
OUTER_BOUNDS_DEFAULT, refContainer);
+        outerBoundsRect = getLayoutRect(
+            gridModel.get('outerBounds', true) || OUTER_BOUNDS_DEFAULT, 
layoutRef.refContainer
+        );
     }
     else if (optionOuterBoundsMode !== 'none') {
         if (__DEV__) {
diff --git a/src/util/layout.ts b/src/util/layout.ts
index cb6d4c860..e008cec6d 100644
--- a/src/util/layout.ts
+++ b/src/util/layout.ts
@@ -444,7 +444,7 @@ export const BoxLayoutReferenceType = {
 } as const;
 export type BoxLayoutReferenceType = (typeof BoxLayoutReferenceType)[keyof 
typeof BoxLayoutReferenceType];
 
-type BoxLayoutReferenceResult<TEnableByCenter> = TEnableByCenter extends true
+export type BoxLayoutReferenceResult<TEnableByCenter extends boolean = false> 
= TEnableByCenter extends true
     ? (BoxLayoutReferenceRectResult | BoxLayoutReferencePointResult)
     : BoxLayoutReferenceRectResult;
 type BoxLayoutReferenceRectResult = {
diff --git a/test/matrix3.html b/test/matrix3.html
index ba219bed2..0120a6e12 100644
--- a/test/matrix3.html
+++ b/test/matrix3.html
@@ -322,6 +322,7 @@ under the License.
                     xAxis: [{
                         id: 'cartesian_a',
                         gridId: 'cartesian_a',
+                        axisLabel: {hideOverlap: true},
                     }, {
                         id: 'cartesian_b',
                         gridId: 'cartesian_b',
@@ -470,7 +471,7 @@ under the License.
                         type: 'scatter',
                         xAxisId: 'cartesian_a',
                         yAxisId: 'cartesian_a',
-                        data: [[12,56], [98,76], [37,82]],
+                        data: [[111212,23256], [98,76], [37,82]],
                     }, {
                         type: 'line',
                         name: 'line_a',


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

Reply via email to