Skip to content

Commit ff97cae

Browse files
authored
Merge pull request #474 from apache/feat-break
doc: add break axis doc; jitter doc should be only displayed under xAxis and yAxis
2 parents 4f76ebb + 4bcad1c commit ff97cae

File tree

7 files changed

+247
-30
lines changed

7 files changed

+247
-30
lines changed

en/option/component/axis-common.md

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Parameters of the event include:
2525
}
2626
```
2727

28+
{{ if: ${hasJitter|default(false)} }}
2829
#${prefix} jitter(number) = 0
2930

3031
{{ use: partial-version(version = "6.0.0") }}
@@ -46,6 +47,114 @@ Whether allow overlaping with [jitter](~${componentType}.jitter). If `false`, it
4647
{{ use: partial-version(version = "6.0.0") }}
4748

4849
When setting [jitter](~${componentType}.jitter) and [jitterOverlap](~${componentType}.jitterOverlap) is `false`, the minimum distance between two scatters.
50+
{{ /if }}
51+
52+
53+
54+
{{ if: ${hasBreakAxis|default(false)} }}
55+
#${prefix} breaks(Array)
56+
57+
Break axis data, where each sub-element represents a segment of truncated space.
58+
59+
~[800x400](${galleryViewPath}intraday-breaks-2&edit=1&reset=1)
60+
61+
> Break axis is a technique that truncates portions of the coordinate axis to compress the display space of non-critical data segments in charts. Its core purposes are:
62+
>
63+
> + **Highlight differences**: When there are extreme differences between data values (such as one value being much larger than others), it prevents large value bars from overwhelmingly occupying space, making small value differences difficult to distinguish.
64+
> + **Save space**: Reduces blank areas caused by extreme values, making charts more compact.
65+
>
66+
> Please note that break axis should only be used when necessary to avoid misleading users. When using break axis, the truncated parts and corresponding values should usually be clearly indicated.
67+
>
68+
> Break axis cannot be used in category axes ([type](~${componentType}.type): `'category'`).
69+
70+
##${prefix} start(string|number|Date)
71+
72+
The start value for truncation.
73+
74+
+ For coordinate axes with [type](~${componentType}.type) as `'value'` or `'log'`, use `number` type values
75+
+ For coordinate axes with [type](~${componentType}.type) as `'time'`:
76+
+ `string` type time values (e.g., `'2024-04-09 13:00:00'`)
77+
+ `number` type timestamps (e.g., `(new Date('2024-04-09 13:00:00')).getTime()`)
78+
+ `Date` type time objects (e.g., `new Date('2024-04-09 13:00:00')`).
79+
80+
##${prefix} end(string|number|Date)
81+
82+
The end value for truncation.
83+
84+
+ For coordinate axes with [type](~${componentType}.type) as `'value'` or `'log'`, use `number` type values
85+
+ For coordinate axes with [type](~${componentType}.type) as `'time'`:
86+
+ `string` type time values (e.g., `'2024-04-09 13:00:00'`)
87+
+ `number` type timestamps (e.g., `(new Date('2024-04-09 13:00:00')).getTime()`)
88+
+ `Date` type time objects (e.g., `new Date('2024-04-09 13:00:00')`).
89+
90+
##${prefix} gap(number|string)
91+
92+
The display size of the break axis truncated area.
93+
94+
+ `number`: Same unit as `start` and `end`, not representing pixel size
95+
+ `string`:
96+
+ Supports percentage forms like `'35%'`, representing relative proportion to the coordinate axis data area size
97+
+ Supports strings like `'123'`, equivalent to `number` type `123`, note that it does not represent pixel size
98+
99+
##${prefix} isExpanded(boolean) = false
100+
101+
Whether this truncated area is expanded, default is `false`.
102+
103+
#${prefix} breakArea
104+
105+
Style of the break axis truncated area.
106+
107+
##${prefix} show(boolean) = true
108+
109+
Whether to show the truncated area.
110+
111+
##${prefix} itemStyle
112+
113+
Style of the truncated area.
114+
115+
{{ use: partial-item-style(
116+
prefix = '###',
117+
defaultColor = "#fff",
118+
defaultBorderColor = "'#b7b9be'",
119+
defaultBorderWidth = 1,
120+
defaultType = "[3, 3]",
121+
defaultOpacity = 0.6
122+
) }}
123+
124+
##${prefix} zigzagAmplitude(number) = 4
125+
126+
The amplitude (in the direction perpendicular to the coordinate axis) of the truncated zigzag. The size of the truncated zigzag in the direction perpendicular to the coordinate axis is always the same across different zigzags.
127+
128+
##${prefix} zigzagMinSpan(number) = 4
129+
130+
The minimum size of the truncated zigzag in the coordinate axis direction.
131+
132+
> The size of the truncated zigzag in the coordinate axis direction is a random number between `zigzagMinSpan` and `zigzagMaxSpan`. Randomness is used to simulate the effect of torn paper.
133+
134+
##${prefix} zigzagMaxSpan(number) = 20
135+
136+
The maximum size of the truncated zigzag in the coordinate axis direction.
137+
138+
> The size of the truncated zigzag in the coordinate axis direction is a random number between `zigzagMinSpan` and `zigzagMaxSpan`. Randomness is used to simulate the effect of torn paper.
139+
140+
##${prefix} zigzagZ(number) = 100
141+
142+
The `z` value of the truncated zigzag. Controls the front-to-back order of graphics. Graphics with smaller `z` values will be covered by graphics with larger `z` values.
143+
144+
##${prefix} expandOnClick(boolean) = true
145+
146+
Whether to expand the truncated area when clicking on the break axis truncated area.
147+
148+
#${prefix} breakLabelLayout(Object)
149+
150+
Break axis label layout.
151+
152+
##${prefix} moveOverlap(string|boolean) = 'auto'
153+
154+
When break axis labels overlap, whether to move labels to avoid overlap.
155+
156+
`'auto'` or `true` means moving labels to avoid overlap when overlapping occurs; `false` means not moving.
157+
{{ /if }}
49158

50159
#${prefix} axisLine(Object)
51160

@@ -803,7 +912,9 @@ To specify the start value of the axis.
803912

804913
{{ use: partial-axis-common-axis-line(
805914
prefix = ${prefix},
806-
componentType = ${componentType}
915+
componentType = ${componentType},
916+
hasJitter = ${hasJitter},
917+
hasBreakAxis = ${hasBreakAxis}
807918
) }}
808919

809920
{{ use: partial-axis-common-axis-tick(

en/option/component/x-axis.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,23 @@ options:
3737
+ `'top'`
3838
+ `'bottom'`
3939

40-
The first x axis in grid defaults to be on the bottom of the grid, and the second x axis is on the other side against the first x axis.
40+
The first x axis in grid defaults to be on the bottom of the grid, and the second x axis is on the other side against the first x axis.
4141
Notice: Set `xAxis.axisLine.onZero` to `false` to activate this option.
4242

4343
## offset(number) = 0
4444

4545
<ExampleUIControlNumber step="0.5" />
4646

47-
Offset of x axis relative to default position. Useful when multiple x axis has same [position](~xAxis.position) value.
47+
Offset of x axis relative to default position. Useful when multiple x axis has same [position](~xAxis.position) value.
4848
Notice: Set `xAxis.axisLine.onZero` to `false` to activate this option.
4949

5050
{{ use: axis-common(
5151
prefix = '#',
5252
componentType = 'xAxis',
5353
axisTypeDefault = "'category'",
54-
hasSplitLineAndArea = true
54+
hasSplitLineAndArea = true,
55+
hasJitter = true,
56+
hasBreakAxis = true
5557
) }}
5658

5759
{{ use: partial-z-zlevel(

en/option/component/y-axis.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ options:
3737
+ `'left'`
3838
+ `'right'`
3939

40-
The first y axis in grid defaults to be the left (`'left'`) of the grid, and the second y axis is on the other side against the first y axis.
40+
The first y axis in grid defaults to be the left (`'left'`) of the grid, and the second y axis is on the other side against the first y axis.
4141
Notice: Set `yAxis.axisLine.onZero` to `false` to activate this option.
4242

4343
## offset(number) = 0
@@ -51,7 +51,9 @@ Notice: Set `yAxis.axisLine.onZero` to `false` to activate this option.
5151
prefix = '#',
5252
componentType = 'yAxis',
5353
axisTypeDefault = "'value'",
54-
hasSplitLineAndArea = true
54+
hasSplitLineAndArea = true,
55+
hasJitter = true,
56+
hasBreakAxis = true
5557
) }}
5658

5759
{{ use: partial-z-zlevel(

src/style/mixin.scss

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,11 @@
1111
}
1212

1313
blockquote {
14-
font-size: 12px;
15-
color: #999;
16-
background-color: #fdfdfd;
14+
background-color: #f3f3f3;
1715
border-left: 2px solid #ddd;
1816
margin-left: 0px;
1917

20-
padding: 5px 10px;
21-
22-
p {
23-
margin: 0;
24-
font-size: 12px;
25-
}
26-
27-
pre {
28-
font-size: 12px;
29-
}
18+
padding: 10px 20px;
3019
}
3120

3221
iframe {

zh/option/component/axis-common.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
}
2424
```
2525

26+
{{ if: ${hasJitter|default(false)} }}
2627
#${prefix} jitter(number) = 0
2728

2829
{{ use: partial-version(version = "6.0.0") }}
@@ -44,6 +45,116 @@
4445
{{ use: partial-version(version = "6.0.0") }}
4546

4647
在设置了 [jitter](~${componentType}.jitter)[jitterOverlap](~${componentType}.jitterOverlap)`false` 的情况下,两个数据点之间的最小距离。
48+
{{ /if }}
49+
50+
51+
52+
{{ if: ${hasBreakAxis|default(false)} }}
53+
#${prefix} breaks(Array)
54+
55+
断轴的截断数据,每一个子元素表示一段截断的空间。
56+
57+
~[800x400](${galleryViewPath}intraday-breaks-2&edit=1&reset=1)
58+
59+
> 断轴是一种通过在坐标轴上截断部分区域,从而压缩图表中非关键数据段的展示空间的技术。其核心目的是:
60+
>
61+
> +**​突出差异**​​:当数据间存在极端差异时(如一个值远大于其他值),避免大数值柱子压倒性占据空间,导致小数值差异难以辨认。
62+
> + **​​节省空间​**​:减少因极值导致的空白区域,使图表更紧凑。
63+
>
64+
> 请注意仅在必要的时候使用断轴,以免给用户带来理解上的误导。当使用断轴时,通常应当明确示意截断部分和对应的数值。
65+
>
66+
> 断轴无法在类目轴([type](~${componentType}.type): `'category'`)中使用。
67+
68+
##${prefix} start(string|number|Date)
69+
70+
开始截断的值。
71+
72+
+ 对于 [type](~${componentType}.type)`'value'``'log'` 类型的坐标轴,使用 `number` 类型的值
73+
+ 对于 [type](~${componentType}.type)`'time'` 类型的坐标轴
74+
+ `string` 类型的时间值(例如 `'2024-04-09 13:00:00'`
75+
+ `number` 类型的时间戳(例如 `(new Date('2024-04-09 13:00:00')).getTime()`
76+
+ `Date` 类型的时间对象(例如 `new Date('2024-04-09 13:00:00')`)。
77+
78+
##${prefix} end(string|number|Date)
79+
80+
结束截断的值。
81+
82+
+ 对于 [type](~${componentType}.type)`'value'``'log'` 类型的坐标轴,使用 `number` 类型的值
83+
+ 对于 [type](~${componentType}.type)`'time'` 类型的坐标轴
84+
+ `string` 类型的时间值(例如 `'2024-04-09 13:00:00'`
85+
+ `number` 类型的时间戳(例如 `(new Date('2024-04-09 13:00:00')).getTime()`
86+
+ `Date` 类型的时间对象(例如 `new Date('2024-04-09 13:00:00')`)。
87+
88+
##${prefix} gap(number|string)
89+
90+
断轴截断区域展示的大小。
91+
92+
+ `number`:单位和 `start``end` 相同,而不表示像素大小
93+
+ `string`
94+
+ 支持例如 `'35%'` 的百分比形式,表示相对于坐标轴数据区域大小的相对比例
95+
+ 支持例如 `'123'` 的字符串,等同于 `number` 类型的 `123,注意不表示像素大小
96+
97+
##${prefix} isExpanded(boolean) = false
98+
99+
该截断区域是否已展开,默认为 `false`
100+
101+
#${prefix} breakArea
102+
103+
断轴截断区域的样式。
104+
105+
##${prefix} show(boolean) = true
106+
107+
是否显示截断区域。
108+
109+
##${prefix} itemStyle
110+
111+
截断区域样式。
112+
113+
{{ use: partial-item-style(
114+
prefix = '###',
115+
defaultColor = "#fff",
116+
defaultBorderColor = "'#b7b9be'",
117+
defaultBorderWidth = 1,
118+
defaultType = "[3, 3]",
119+
defaultOpacity = 0.6
120+
) }}
121+
122+
##${prefix} zigzagAmplitude(number) = 4
123+
124+
截断锯齿的振幅(垂直坐标轴方向上)大小。截断锯齿在垂直坐标轴的方向上的大小在不同锯齿上总是相同的。
125+
126+
##${prefix} zigzagMinSpan(number) = 4
127+
128+
截断锯齿在坐标轴方向上最小的大小。
129+
130+
> 截断锯齿在坐标轴方向上的大小是 `zigzagMinSpan``zigzagMaxSpan` 之间的随机数。通过随机来模拟纸片撕开的效果。
131+
132+
##${prefix} zigzagMaxSpan(number) = 20
133+
134+
截断锯齿在坐标轴方向上最大的大小。
135+
136+
> 截断锯齿在坐标轴方向上的大小是 `zigzagMinSpan``zigzagMaxSpan` 之间的随机数。通过随机来模拟纸片撕开的效果。
137+
138+
##${prefix} zigzagZ(number) = 100
139+
140+
截断锯齿的 `z` 值。控制图形的前后顺序。`z` 值小的图形会被 `z` 值大的图形覆盖。
141+
142+
##${prefix} expandOnClick(boolean) = true
143+
144+
点击断轴截断区域是否展开截断区域。
145+
146+
#${prefix} breakLabelLayout(Object)
147+
148+
断轴文字布局。
149+
150+
##${prefix} moveOverlap(string|boolean) = 'auto'
151+
152+
当断轴文字重叠时,是否移动文字来避免重叠。
153+
154+
`'auto'``true` 表示重叠时移动文字来避免重叠;`false` 表示不移动。
155+
{{ /if }}
156+
157+
47158

48159
#${prefix} axisLine(Object)
49160

@@ -800,7 +911,9 @@ max: function (value) {
800911

801912
{{ use: partial-axis-common-axis-line(
802913
prefix = ${prefix},
803-
componentType = ${componentType}
914+
componentType = ${componentType},
915+
hasJitter = ${hasJitter},
916+
hasBreakAxis = ${hasBreakAxis}
804917
) }}
805918

806919
{{ use: partial-axis-common-axis-tick(

zh/option/component/x-axis.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ x 轴的位置。
7474
+ `'top'`
7575
+ `'bottom'`
7676

77-
默认 grid 中的第一个 x 轴在 grid 的下方(`'bottom'`),第二个 x 轴视第一个 x 轴的位置放在另一侧。
78-
注:若未将 `xAxis.axisLine.onZero` 设为 `false` , 则该项无法生效
77+
默认 grid 中的第一个 x 轴在 grid 的下方(`'bottom'`),第二个 x 轴视第一个 x 轴的位置放在另一侧。注:若未将 `xAxis.axisLine.onZero` 设为 `false` , 则该项无法生效。
7978

8079
## offset(number) = 0
8180

8281
<ExampleUIControlNumber step="0.5" />
8382

84-
X 轴相对于默认位置的偏移,在相同的 `position` 上有多个 X 轴的时候有用。
85-
注:若未将 `xAxis.axisLine.onZero` 设为 `false` , 则该项无法生效
83+
X 轴相对于默认位置的偏移,在相同的 `position` 上有多个 X 轴的时候有用。注:若未将 `xAxis.axisLine.onZero` 设为 `false` , 则该项无法生效。
8684

8785
{{ use: axis-common(
8886
prefix = '#',
8987
componentType = 'xAxis',
9088
axisTypeDefault = "'category'",
91-
hasSplitLineAndArea = true
89+
hasSplitLineAndArea = true,
90+
hasJitter = true,
91+
hasBreakAxis = true
9292
) }}
9393

9494
{{ use: partial-z-zlevel(

zh/option/component/y-axis.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,23 @@ y 轴的位置。
118118
+ `'left'`
119119
+ `'right'`
120120

121-
默认 grid 中的第一个 y 轴在 grid 的左侧(`'left'`),第二个 y 轴视第一个 y 轴的位置放在另一侧。
122-
注:若未将 `yAxis.axisLine.onZero` 设为 `false` , 则该项无法生效
121+
默认 grid 中的第一个 y 轴在 grid 的左侧(`'left'`),第二个 y 轴视第一个 y 轴的位置放在另一侧。注:若未将 `yAxis.axisLine.onZero` 设为 `false` , 则该项无法生效。
123122

124123
## offset(number) = 0
125124

126125
<ExampleUIControlNumber step="0.5" />
127126

128-
Y 轴相对于默认位置的偏移,在相同的 `position` 上有多个 Y 轴的时候有用。
129-
注:若未将 `yAxis.axisLine.onZero` 设为 `false` , 则该项无法生效
127+
Y 轴相对于默认位置的偏移,在相同的 `position` 上有多个 Y 轴的时候有用。注:若未将 `yAxis.axisLine.onZero` 设为 `false` , 则该项无法生效。
130128

131129
需要配合其他配置项共同实现动态排序柱状图效果,具体参见[动态排序柱状图](${handbookPath}how-to/chart-types/bar/bar-race)教程。
132130

133131
{{ use: axis-common(
134132
prefix = '#',
135133
componentType = 'yAxis',
136134
axisTypeDefault = "'value'",
137-
hasSplitLineAndArea = true
135+
hasSplitLineAndArea = true,
136+
hasJitter = true,
137+
hasBreakAxis = true
138138
) }}
139139

140140
{{ use: partial-z-zlevel(

0 commit comments

Comments
 (0)