Skip to content

Commit

Permalink
Merge pull request #3507 from VisActor/docs/restorPosition
Browse files Browse the repository at this point in the history
docs: add docs for `restorePosition`
  • Loading branch information
xile611 authored Dec 6, 2024
2 parents 486f96f + 5a691ad commit 8e844b5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
38 changes: 26 additions & 12 deletions docs/assets/option/en/component/label.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,19 @@ Overlap avoidance strategy for labels, providing 4 avoidance strategies, respect
```ts
export type PositionStrategy = {
/**
* 可选位置策略。
* 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。
* Optional position strategy.
* If the default position does not have enough space to place the label, consider the alternative positions within the position.
*/
type: 'position';
/** position 根据图表类型支持不同支持不同的位置配置 **/
/** position supports different configurations depending on the chart type **/
position?: Functional<LabelPosition[]>;
/**
* When the alternative positions in position still cannot accommodate the label, whether the label is returned to its original position.
* The default is true, if false, the label will be placed in the last position of the position array.
* @since 1.12.15
* @default true
*/
restorePosition?: boolean;
};
```

Expand All @@ -183,12 +190,19 @@ Overlap avoidance strategy for labels, providing 4 avoidance strategies, respect
```ts
export type BoundStrategy = {
/**
* 标签配置在图形内部时使用。
* 当图形大小不足以放下标签,则考虑 position 内的备选位置。
* Used when configuring labels inside a graphic.
* If the graphic size is insufficient to accommodate the label, consider alternative positions within the position.
*/
type: 'bound';
/** position 根据图表类型支持不同支持不同的位置配置 **/
/** position supports different configurations depending on the chart type **/
position?: Functional<LabelPosition[]>;
/**
* When the alternative positions in position still cannot accommodate the label, whether the label is returned to its original position.
* The default is true, if false, the label will be placed in the last position of the position array.
* @since 1.12.15
* @default true
*/
restorePosition?: boolean;
};
```

Expand All @@ -197,12 +211,12 @@ Overlap avoidance strategy for labels, providing 4 avoidance strategies, respect
```ts
export type MoveYStrategy = {
/**
* y 方向散开策略。
* 若默认位置没有足够的空间放置标签,则根据 offset 在 y 方向上寻找位置。
* Y-direction dispersion strategy.
* If the default position does not have enough space to place the label, find a position in the y-direction based on the offset.
*/
type: 'moveY';
/**
* y 方向上的尝试的位置偏移量,可配置为函数。
* The position offset in the y-direction can be configured as a function.
*/
offset: Functional<number[]>; // number | (data: any) => number[];
};
Expand All @@ -213,12 +227,12 @@ Overlap avoidance strategy for labels, providing 4 avoidance strategies, respect
```ts
export type MoveYStrategy = {
/**
* x 方向散开策略。
* 若默认位置没有足够的空间放置标签,则根据 offset 在 x 方向上寻找位置。
* X-direction dispersion strategy.
* If the default position does not have enough space to place the label, find a position in the x-direction based on the offset.
*/
type: 'moveX';
/**
* x 方向上的尝试的位置偏移量,可配置为函数。
* The position offset in the x-direction can be configured as a function.
*/
offset: Functional<number[]>; // number | (data: any) => number[];
};
Expand Down
14 changes: 14 additions & 0 deletions docs/assets/option/zh/component/label.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ hover 状态样式配置。
type: 'position';
/** position 根据图表类型支持不同支持不同的位置配置 **/
position?: Functional<LabelPosition[]>;
/**
* 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。
* 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。
* @since 1.12.15
* @default true
*/
restorePosition?: boolean;
};
```

Expand All @@ -187,6 +194,13 @@ hover 状态样式配置。
type: 'bound';
/** position 根据图表类型支持不同支持不同的位置配置 **/
position?: Functional<LabelPosition[]>;
/**
* 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。
* 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。
* @since 1.12.15
* @default true
*/
restorePosition?: boolean;
};
```

Expand Down

0 comments on commit 8e844b5

Please sign in to comment.