Skip to content

Commit 5d257a9

Browse files
committed
feat(labelMargin): uniform minMargin and textMargin.
1 parent db69b8c commit 5d257a9

38 files changed

+243
-116
lines changed

en/option/component/geo-common.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Selected mode decides whether multiple selecting is supported. By default, `fals
241241
{{ use: partial-label(
242242
prefix = "#" + ${prefix},
243243
formatter = true,
244-
minMargin = ${labelMinMargin}
244+
labelMargin = ${labelMargin}
245245
) }}
246246

247247
#${prefix} itemStyle(Object)

en/option/partial/label.md

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,11 @@ See: [label rotation](${galleryEditorPath}bar-label-rotation).
5151

5252
Whether to move text slightly. For example: `[30, 40]` means move `30` horizontally and move `40` vertically.
5353

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}
5957
) }}
6058

61-
Minimal margin between labels. Used when label has [layout](~series.labelLayout).
62-
{{ /if }}
63-
6459
{{ if: ${formatter} }}
6560
#${prefix} formatter(string|Function)
6661

@@ -93,6 +88,59 @@ Minimal margin between labels. Used when label has [layout](~series.labelLayout)
9388

9489

9590

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).
138+
{{ /if }}
139+
140+
141+
142+
143+
96144
{{ target: partial-label-position }}
97145

98146
Label position.

en/option/series/bar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Label style configurations of single data.
332332
defaultPosition = "'inside'",
333333
noPosition = true,
334334
formatter = ${topLevel},
335-
minMargin = ${state} === 'normal'
335+
labelMargin = ${state} === 'normal'
336336
) }}
337337

338338
##${prefix} position(string|Array) = 'inside'

en/option/series/effectScatter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ The brush type for ripples. options: `'stroke'` and `'fill'`.
104104
prefix = "##",
105105
defaultPosition = "'inside'",
106106
formatter = true,
107-
minMargin = true
107+
labelMargin = true
108108
) }}
109109

110110
## labelLine(Object)
@@ -220,7 +220,7 @@ Configurations of select state. Available when [selectedMode](~series-effectScat
220220
{{ use: partial-label(
221221
prefix = "###",
222222
defaultPosition = "inside",
223-
minMargin = true
223+
labelMargin = true
224224
) }}
225225

226226
### labelLine(Object)

en/option/series/funnel.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Horizontal align. Defaults to align center. Can be 'left', 'right', 'center'.
8888
prefix = "##",
8989
position = true,
9090
formatter = true,
91-
minMargin = true
91+
labelMargin = true
9292
) }}
9393

9494
## labelLine(Object)
@@ -221,7 +221,7 @@ The label configuration of a single data item.
221221
prefix = "###",
222222
position = true,
223223
formatter = false,
224-
minMargin = true
224+
labelMargin = true
225225
) }}
226226

227227
### labelLine(Object)
@@ -344,15 +344,12 @@ Label position.
344344
[labelLine](~series-funnel.labelLine) can be used to guide to the corresponding trapezoid when label is not inside.
345345
{{ /if }}
346346

347-
{{ if: ${minMargin} }}
348-
#${prefix} minMargin(number)
349347

350-
{{ use: partial-version(
351-
version = "5.0.0"
348+
{{ use: partial-label-margin(
349+
prefix = ${prefix},
350+
labelMargin = ${labelMargin}
352351
) }}
353352

354-
Minimal margin between labels. Used when label has [layout](~series-funnel.labelLayout).
355-
{{ /if }}
356353

357354
{{ if: ${formatter} }}
358355
#${prefix} formatter(string|Function)

en/option/series/graph.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ The style of edge line. [lineStyle.color](~series-graph.lineStyle.color) can be
210210
prefix = "##",
211211
defaultPosition = "'inside'",
212212
formatter = true,
213-
minMargin = true
213+
labelMargin = true
214214
) }}
215215

216216
## edgeLabel(Object)
@@ -434,7 +434,7 @@ The label style of this node.
434434

435435
{{ use: partial-label(
436436
prefix = "###",
437-
minMargin = true
437+
labelMargin = true
438438
) }}
439439

440440
### emphasis(Object)

en/option/series/heatmap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Work for [coordinateSystem](~series-heatmap.coordinateSystem): 'cartesian2d'.
5858
{{ use: partial-label(
5959
prefix = "##",
6060
defaultPosition = "inside",
61-
minMargin = true
61+
labelMargin = true
6262
) }}
6363

6464
## labelLayout(Object|Function)
@@ -166,7 +166,7 @@ It is valid with [coordinateSystem](~series-heatmap.coordinateSystem) of 'cartes
166166
{{ use: partial-label(
167167
prefix = "###",
168168
defaultPosition = "inside",
169-
minMargin = true
169+
labelMargin = true
170170
) }}
171171

172172
### itemStyle(Object)

en/option/series/line.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ See the example using different `step` options:
131131
prefix = "##",
132132
defaultPosition = "'top'",
133133
formatter = true,
134-
minMargin = true
134+
labelMargin = true
135135
) }}
136136

137137
## endLabel(Object)
@@ -146,7 +146,7 @@ Label on the end of line.
146146
prefix = "##",
147147
formatter = true,
148148
noPosition = true,
149-
minMargin = true
149+
labelMargin = true
150150
) }}
151151

152152
### valueAnimation(boolean)
@@ -371,7 +371,7 @@ The style of the text of single data point.
371371
{{ use: partial-label(
372372
prefix = "###",
373373
defaultPosition = "top",
374-
minMargin = true
374+
labelMargin = true
375375
) }}
376376

377377
### labelLine(Object)

en/option/series/lines.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Label settings. Does not work when [polyline](~series-lines.polyline) is `true`.
133133

134134
{{ use: lines-label(
135135
prefix = "##",
136-
minMargin = true
136+
labelMargin = true
137137
) }}
138138

139139
## labelLayout(Object|Function)
@@ -232,7 +232,7 @@ Label of a single line. Available when [polyline](~series-lines.polyline) is not
232232

233233
{{ use: lines-label(
234234
prefix = "###",
235-
minMargin = true
235+
labelMargin = true
236236
) }}
237237

238238
### emphasis(Object)
@@ -317,15 +317,12 @@ the position of label, options:
317317
+ `'middle'`
318318
+ `'end'`
319319

320-
{{ if: ${minMargin} }}
321-
#${prefix} minMargin(number)
322320

323-
{{ use: partial-version(
324-
version = "5.0.0"
321+
{{ use: partial-label-margin(
322+
prefix = ${prefix},
323+
labelMargin = ${labelMargin}
325324
) }}
326325

327-
Minimal margin between labels. Used when label has [layout](~series-lines.labelLayout).
328-
{{ /if }}
329326

330327
#${prefix} formatter(string|Function)
331328

en/option/series/map.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Series of same [map type](~series-map.map) will show in one map. At this point,
2222
{{ use: geo-common(
2323
prefix = '#',
2424
inMap = true,
25-
labelMinMargin = true
25+
labelMargin = true
2626
) }}
2727

2828
## center(Array)
@@ -142,7 +142,7 @@ Color of the area.
142142
formatter = true,
143143
noAlign = true,
144144
noVerticalAlign = true,
145-
minMargin = true
145+
labelMargin = true
146146
) }}
147147

148148
### labelLine(Object)

0 commit comments

Comments
 (0)