jiawulin001 commented on code in PR #16880:
URL: https://github.com/apache/echarts/pull/16880#discussion_r851975430
##########
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:
>The method estimateLabelUnionRect returns the union bounding box of all
labels, not the largest.
The logic of function
[`rect.union`](https://github.com/ecomfe/zrender/blob/67c46f39c208bb86df84c0afa63399755747f4ff/src/core/BoundingRect.ts#L48-L53)
is returning the union of bounding rect.
But here in echarts, if you trace the dataflow, every `singleRect` has `{x:
0, y: 0}`. So when you use `union` on two rects at the same position, you are
just returning the larger one. That's why I say it actually returns the largest
bounding rect of all labels.
https://github.com/apache/echarts/blob/4a52199842039d7fa6019ee8584d1a395fbc771a/src/coord/axisHelper.ts#L327-L338
This doesn't result in errors for now because only `x/height` and `y/width`
is used in older version, and they are the same for **union rect** and
**largest rect**.
However, thanks to your suggestion, I double-checked
[Axis.ts](https://github.com/apache/echarts/blob/master/src/coord/Axis.ts) and
found the function
[`getTicksCoords`](https://github.com/apache/echarts/blob/4a52199842039d7fa6019ee8584d1a395fbc771a/src/coord/Axis.ts#L169),
which returns all displayed labels' (or ticks', they bind each other)
coordinates. So I rewrite the changes and now I can accurately grab the first
and the last label and check whether they would exceed the dom. Please review
again.
P.S. Do you mind telling me how to get the dom size in Echarts? I struggled
to get dom attributes but failed.
--
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]