Skip to content

Commit 72408f7

Browse files
committed
feat(grid): enhance label containment logic to support directional constraints
1 parent 6b9642d commit 72408f7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/coord/cartesian/Grid.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ class Grid implements CoordinateSystemMaster {
187187
// Minus label size
188188
if (isContainLabel) {
189189
each(axesList, function (axis) {
190+
if (
191+
(isContainLabel === 'horizontal' && !axis.isHorizontal())
192+
|| (isContainLabel === 'vertical' && axis.isHorizontal())
193+
) {
194+
return;
195+
}
190196
if (!axis.model.get(['axisLabel', 'inside'])) {
191197
const labelUnionRect = estimateLabelUnionRect(axis);
192198
if (labelUnionRect) {

src/coord/cartesian/GridModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export interface GridOption extends ComponentOption, BoxLayoutOptionMixin, Shado
2828

2929
show?: boolean;
3030

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

3434
backgroundColor?: ZRColor;
3535
borderWidth?: number;

0 commit comments

Comments
 (0)