You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whether to move text slightly. For example: `[30, 40]` means move `30` horizontally and move `40` vertically.
53
53
54
-
{{ if: ${minMargin} }}
55
-
#${prefix} minMargin(number)
56
-
57
-
{{ use: partial-version(
58
-
version = "5.0.0"
54
+
{{ use: partial-label-margin(
55
+
prefix = ${prefix},
56
+
labelMargin = ${labelMargin}
59
57
) }}
60
58
61
-
Minimal margin between labels. Used when label has [layout](~series.labelLayout).
62
-
{{ /if }}
63
-
64
59
{{ if: ${formatter} }}
65
60
#${prefix} formatter(string|Function)
66
61
@@ -93,6 +88,59 @@ Minimal margin between labels. Used when label has [layout](~series.labelLayout)
93
88
94
89
95
90
91
+
92
+
{{ target: partial-label-margin }}
93
+
{{ if: ${labelMargin} }}
94
+
#${prefix} textMargin(number|Array)
95
+
96
+
{{ use: partial-version(
97
+
version = "6.0.0"
98
+
) }}
99
+
100
+
The space around the label to escape from overlapping. The unit is px.
101
+
102
+
Notice: `textMargin` is applied on the label's local bounding rect, that is, if there is a `rotate` specified on the label, apply `textMargin` on the non-rotated label first, and then apply the rotation.
103
+
104
+
> The name is `textMargin` because historically the name `margin` has been used for a different purpose.
105
+
106
+
107
+
Examples:
108
+
```ts
109
+
// Set margin to be 5, means [5, 5, 5, 5]
110
+
textMargin: 5
111
+
// Set the top and bottom margin to be 5, and left and right margin to be 10
112
+
textMargin: [5, 10]
113
+
// Set each of the four margin separately
114
+
textMargin: [
115
+
5, // up
116
+
10, // right
117
+
5, // down
118
+
10, // left
119
+
]
120
+
```
121
+
122
+
#${prefix} minMargin(number)
123
+
124
+
{{ use: partial-version(
125
+
version = "5.0.0"
126
+
) }}
127
+
128
+
Minimal margin between labels. Used when label has [layout](~series.labelLayout).
129
+
130
+
`minMargin` conveys a similar meaning to `textMargin`, but with a different nuance. If unsure, just use `textMargin`; it basically covers `minMargin` and can provide a more compact layout for rotated labels in some scenarios.
131
+
132
+
> TL;DR: The difference:
133
+
> + The minimal gap (if applicable) between two labels is `label1.minMargin/2 + label2.minMargin/2`, or `label1.textMargin[number] + label2.textMargin[number]`.
134
+
> + If `rotate` is specified on a label,
135
+
> +`minMargin`: first rotate the label, forming a new rect by the min/max of x/y from the four corner points (that is a expanded bounding rect), and finally `minMargin` is applied on the new rect.
136
+
> +`textMargin`: first applied on the label's local bounding rect, and then rotate.
137
+
> + Data type: `minMargin` should be only `number`, `textMargin` can be `number | number[]` (follow CSS margin).
0 commit comments