-
Notifications
You must be signed in to change notification settings - Fork 19.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 9265: Axis names overlap with labels #19534
base: master
Are you sure you want to change the base?
Conversation
Thanks for your contribution! Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the |
bca793e
to
1422365
Compare
@gooroodev review |
Summary of Changes
Issues, Bugs, and Typos
Proposed Improvement: -import {isObject, each, indexOf, retrieve3, keys, reduce, map} from 'zrender/src/core/util';
+import {isObject, each, indexOf, retrieve3, keys, map} from 'zrender/src/core/util';
Proposed Improvement: -function isNameLocationCenter(nameLocation: string) {
- return nameLocation === 'middle' || nameLocation === 'center';
-} General Review of Code Quality and Style
Overall, the pull request addresses the issue effectively and maintains high code quality. The proposed improvements are minor and would enhance the clarity and efficiency of the code. Yours, Gooroo.dev. To receive reviews automatically, install Github App |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply and thanks for your contribution!
I feel the changes are somewhat too complicated. Could we add the following code to the end of axisHelper.ts#estimateLabelUnionRect
?
...
const axisName = axisModel.get('name');
if (axisName) {
const nameLocation = axisModel.get('nameLocation');
const nameGap = axisModel.get('nameGap') || 0;
const nameRotate = axisModel.get('nameRotate') || 0;
const nameTruncate = axisModel.get('nameTruncate');
const textStyle = axisModel.getModel('nameTextStyle');
const unrotatedSingleRect = textStyle.getTextRect(axisName);
if (nameTruncate.maxWidth) {
unrotatedSingleRect.width = Math.min(unrotatedSingleRect.width, nameTruncate.maxWidth);
}
const singleRect = rotateTextRect(unrotatedSingleRect, nameRotate);
rect.union(singleRect);
// TODO: also consider nameLocation, nameGap and etc. to control the rect
}
return rect;
}
Follow-up of #16825 and #12236
Brief Information
This pull request is in the type of:
What does this PR do?
This PR shrinks the grid size such that the axis labels and names are completely contained (Option (B) of #9265 (comment)).
Fixed issues
Details
Before: What was the problem?
When
grid.containLabel
is set to true, the axis names overlap with the labels, when there is no magical number fornameGap
specified. Furthermore, the names may be not visible when specifying thenameGap
, because the names get pushed out of the grid. Therefore, also the distance between the grid and the container needs to be adjusted.After: How does it behave after the fixing?
When
grid.containLabel
is set to true, the axis names do not overlap with labels and the grid size is shrinked such that the names are completely visible without the need to specify the grid to container distance ornameGap
.Document Info
One of the following should be checked.
Misc
ZRender Changes
Related test cases or examples to use the new APIs
N.A.
Others
Merging options
Other information