Skip to content

Commit

Permalink
feat(grid): enhance label containment logic to support directional co…
Browse files Browse the repository at this point in the history
…nstraints
  • Loading branch information
chengzhanli committed Nov 27, 2024
1 parent 6b9642d commit 72408f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/coord/cartesian/Grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ class Grid implements CoordinateSystemMaster {
// Minus label size
if (isContainLabel) {
each(axesList, function (axis) {
if (
(isContainLabel === 'horizontal' && !axis.isHorizontal())
|| (isContainLabel === 'vertical' && axis.isHorizontal())
) {
return;
}
if (!axis.model.get(['axisLabel', 'inside'])) {
const labelUnionRect = estimateLabelUnionRect(axis);
if (labelUnionRect) {
Expand Down
4 changes: 2 additions & 2 deletions src/coord/cartesian/GridModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface GridOption extends ComponentOption, BoxLayoutOptionMixin, Shado

show?: boolean;

// Whether grid size contain label.
containLabel?: boolean;
// Whether grid size contain label from which direction the labels are contained
containLabel?: boolean | 'horizontal' | 'vertical';

backgroundColor?: ZRColor;
borderWidth?: number;
Expand Down

0 comments on commit 72408f7

Please sign in to comment.