pissang commented on code in PR #16880:
URL: https://github.com/apache/echarts/pull/16880#discussion_r851727631


##########
src/coord/cartesian/Grid.ts:
##########
@@ -202,10 +200,32 @@ class Grid implements CoordinateSystemMaster {
                     }
                 }
             });
-
+            //Adjust grid.width to keep xAxis labels in dom
+            const [xAxis, yAxis] = axesList[0].isHorizontal() ? axesList : 
axesList.slice().reverse();

Review Comment:
   I think we don't need complex logic to check the first label and last label 
here.
   
   In the 
https://github.com/apache/echarts/blob/c8a490656f29aec8564b8142adf546058d612aab/src/coord/cartesian/Grid.ts#L193
 we only adjust `x`/`width`  based on the labels of yAxis. We can also check if 
the union rect of xAxis labels excced the canvas size. Then adjust `x`/`width` 
to avoid labels overflow.



##########
src/coord/axisHelper.ts:
##########
@@ -333,11 +335,16 @@ export function estimateLabelUnionRect(axis: Axis) {
         const label = labelFormatter(tick, i);
         const unrotatedSingleRect = axisLabelModel.getTextRect(label);
         const singleRect = rotateTextRect(unrotatedSingleRect, 
axisLabelModel.get('rotate') || 0);
-
+        if (i === 0) {
+            firstLabelRect = new BoundingRect(singleRect.x, singleRect.y, 
singleRect.width, singleRect.height);

Review Comment:
   `BoundingRect#clone` can do the work here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to