-
Notifications
You must be signed in to change notification settings - Fork 19.7k
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
Changes from all commits
945abd8
a50b1c1
e90526c
1422365
ad4d68a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,18 @@ import Axis2D from './Axis2D'; | |
import { AxisBaseOption } from '../axisCommonTypes'; | ||
import GridModel from './GridModel'; | ||
import { AxisBaseModel } from '../AxisBaseModel'; | ||
import {OrdinalSortInfo} from '../../util/types'; | ||
import { OrdinalSortInfo } from '../../util/types'; | ||
import { SINGLE_REFERRING } from '../../util/model'; | ||
|
||
export type CartesianAxisPosition = 'top' | 'bottom' | 'left' | 'right'; | ||
|
||
export const inverseCartesianAxisPositionMap = { | ||
left: 'right', | ||
right: 'left', | ||
top: 'bottom', | ||
bottom: 'top' | ||
} as const; | ||
|
||
export type CartesianAxisOption = AxisBaseOption & { | ||
gridIndex?: number; | ||
gridId?: string; | ||
|
@@ -53,6 +60,12 @@ export class CartesianAxisModel extends ComponentModel<CartesianAxisOption> | |
|
||
axis: Axis2D; | ||
|
||
/** | ||
* The gap between the axis and the name gap. | ||
* Injected outside. | ||
*/ | ||
axisToNameGapStartGap: number = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you further explain what is the gap between the axis and the name gap? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are 4 potential properties for each axis reducing the space of the grid. These are in order from the axis to the grid boundary: |
||
|
||
getCoordSysModel(): GridModel { | ||
return this.getReferringComponents('grid', SINGLE_REFERRING).models[0] as GridModel; | ||
} | ||
|
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.
Can you explain the basic idea of these lines?
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.
Important to understand lines 527 to 548 are also lines 489-493 where the case for
nameLocation: center
is handled. That means, lines 527 to 548 are only valid fornameLocation: start | end
.The main reason for these conditions is the different anchoring of the axis names based on the rotation quadrant.
On a horizontal axis, all multiples of 90 degrees are anchored at their mid point, why it is necessary to reserve half of the length of the name. Additionally we need to remove the space needed by the labels since the grid will later be reduced by the sum of
axisLabel.margin
, axis label size,nameGap
, and the axis name size. But, e.g., fornameLocation: start
and axisposition: left
, the space needed for the labels to the left and the name to the left overlaps, since the labels are to the left of the axis and half of the name is left of the axis. (E.g. the name needs 50px left of the axis and the labels 30px. Since we sum up the reserved space, it would be 80px in total. However, the farthest point left of the axis is still the start of the name 50px to the left. So the name only needs an additional space of 50px-30px.)The
else if
contains all conditions for having the name rotation in different quadrants (excluding multiples of 90°). The different quadrants on different axes have different anchors resulting in a different reserved space. E.g. for axis withposition: left