Skip to content

Commit 393ba3a

Browse files
committed
Enhance coord sys doc.
1 parent 354d869 commit 393ba3a

8 files changed

Lines changed: 145 additions & 31 deletions

File tree

en/option/component/matrix.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Matrix coordinate system component.
88

99
The `matrix` coordinate system, like a table, can serve as the layout system of data items in a series, mainly used to display the relationship and interaction of multi-dimensional data. It presents data in the form of a rectangular grid, where each grid unit (or "cell") represents the value of a specific data point in series like `series.heatmap`, `series.scatter`, `series.custom`, etc. The entire layout is displayed in rows and columns to express the relationship of two-dimensional or higher-dimensional data.
1010

11-
The `matrix` coordinate system can also serve as the layout system of the box of series like `series.pie`, `series.tree`, etc., or another coordinate systems like `grid` (i.e., Cartesian coordinate system), `geo`, `polar`, etc., or plain components like `legend`, `dataZoom`, etc. This character enables tiny charts to be laid out in a table, or enables the layout approach like [CSS grid layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout). Currently all the series and components can be laid out within a matrix. `matrix` can also be used purely as table for data texts.
11+
The `matrix` coordinate system can also serve as the layout system of the box of series like `series.pie`, `series.tree`, etc., or another coordinate systems like `grid` (i.e., Cartesian coordinate system), `geo`, `polar`, etc., or plain components like `legend`, `dataZoom`, etc. This character enables [mini charts](${galleryEditorPath}matrix-sparkline&edit=1&reset=1) to be laid out in a table, or enables the layout approach like [CSS grid layout](${galleryEditorPath}matrix-grid-layout&edit=1&reset=1). Currently all the series and components can be laid out within a matrix. `matrix` can also be used purely as table for data texts.
1212

1313
Correlation heat map using heat map in matrix coordinate system:
1414
~[800x400](${galleryViewPath}matrix-correlation-heatmap&edit=1&reset=1)
@@ -25,8 +25,12 @@ Correlation pie chart using pie chart in matrix coordinate system. The example b
2525
Confusion matrix using custom series in matrix coordinate system:
2626
~[800x400](${galleryViewPath}matrix-confusion&edit=1&reset=1)
2727

28-
Tiny line charts are laid out in a table:
29-
~[800x600](${galleryViewPath}matrix-cartesian-tiny&edit=1&reset=1)
28+
Mini charts are laid out in a table:
29+
~[800x600](${galleryViewPath}matrix-sparkline&edit=1&reset=1)
30+
~[800x600](${galleryViewPath}matrix-mini-bar-geo&edit=1&reset=1)
31+
32+
And other **mini charts** examples: [matrix mini bar example](${galleryEditorPath}matrix-mini-bar-data-collection&edit=1&reset=1).
33+
3034

3135
By flexibly using the combination of chart series, coordinate systems, and APIs, richer effects can be achieved.
3236

@@ -52,7 +56,7 @@ X-axis header region.
5256

5357
{{ use: partial-matrix-header(
5458
name = 'x-axis cells',
55-
prefix = '##'
59+
matrixDim = 'x',
5660
) }}
5761

5862
## y(Object)
@@ -63,7 +67,7 @@ Y-axis header region.
6367

6468
{{ use: partial-matrix-header(
6569
name = 'y-axis cells',
66-
prefix = '##'
70+
matrixDim = 'y',
6771
) }}
6872

6973
## body(Object)

en/option/partial/coord-sys.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Options:
9191

9292
Lay out based on a [matrix coordinate system](~matrix). When multiple matrix coordinate systems exist within an ECharts instance, the corresponding system should be specified using [matrixIndex](~${componentNameInLink}.matrixIndex) or [matrixId](~${componentNameInLink}.matrixId).{{if: ${nonSeriesComponentMainType} === 'grid' }}
9393

94-
See example [tiny Cartesians in matrix](${galleryEditorPath}matrix-cartesian-tiny&edit=1&reset=1).
94+
See example [sparkline in matrix](${galleryEditorPath}matrix-sparkline&edit=1&reset=1).
9595
{{ /if }}
9696
{{ /if }}
9797

@@ -158,7 +158,7 @@ Options:
158158

159159
The entire series or component is laid out as a whole based on the specified coordinate system - that is, the overall bounding rect or basic anchor point is calculated relative to the system.
160160

161-
- For example, a [grid component](~grid) can be laid out in a [matrix coordinate system](~matrix) or a [calendar coordinate system](~calendar), where its layout rectangle is calculated by the specified [${componentNameInLink}.coords](~${componentNameInLink}.coords) in that system. See example [tiny Cartesians in matrix](${galleryEditorPath}matrix-cartesian-tiny&edit=1&reset=1).
161+
- For example, a [grid component](~grid) can be laid out in a [matrix coordinate system](~matrix) or a [calendar coordinate system](~calendar), where its layout rectangle is calculated by the specified [${componentNameInLink}.coords](~${componentNameInLink}.coords) in that system. See example [sparkline in matrix](${galleryEditorPath}matrix-sparkline&edit=1&reset=1).
162162
- For example, a [pie series](~series-pie) or a [chord series](~series-chord) can be laid out in a [geo coordinate system](~geo) or a [cartesian2d coordinate system](~grid), where the center is calculated by the specified [series-pie.coords](~series-pie.coords) or [series-pie.center](~series-pie.center) in that system. See example [pie in geo](${galleryEditorPath}map-iceland-pie&edit=1&reset=1).
163163

164164
{{ if: ${seriesType} }}
@@ -175,7 +175,7 @@ See also [${componentNameInLink}.coordinateSystem](~${componentNameInLink}.coord
175175

176176
When [coordinateSystemUsage](~${componentNameInLink}.coordinateSystemUsage) is `'box'`, `coord` is used as the input to the coordinate system and calculate the layout rectangle or anchor point.
177177

178-
Examples: [tiny Cartesians in matrix](${galleryEditorPath}matrix-cartesian-tiny&edit=1&reset=1), [grpah in matrix](${galleryEditorPath}doc-example/matrix-graph-box&edit=1&reset=1).
178+
Examples: [sparkline in matrix](${galleryEditorPath}matrix-sparkline&edit=1&reset=1), [grpah in matrix](${galleryEditorPath}doc-example/matrix-graph-box&edit=1&reset=1).
179179

180180
{{ if: ${seriesType} === 'pie' }}
181181
[series-pie.center](~series-pie.center) and [series-pie.coord](~series-pie.coord) can be used interchangably in this case.

en/option/partial/matrix-header.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ data: ['A', 'B', 'C', 'D', 'E']
1919

2020
// Or if column/row names is not of concern, simply
2121
data: Array(5).fill(null) // Five columns or rows
22+
// Note: DO NOT support array with empty slots:
23+
// data: Array(5) // ❌
2224

2325
// Data in a tree structure
2426
data: [{
@@ -42,13 +44,37 @@ data: [{
4244
}]
4345
```
4446

47+
If [matrix.${matrixDim}.data](~matrix.${matrixDim}.data) is not provided, it will be collected from `series.data` or `dataset.soruce`.
48+
49+
See [matrix data collection example](${galleryEditorPath}matrix-mini-bar-data-collection&edit=1&reset=1).
50+
51+
And in this case [series.encode](~series-scatter.encode) can be used to specify the dimension from which value is collected. For example,
52+
```js
53+
var option = {
54+
// no matrix.x/y.data is specified;
55+
// so collect from series.data or dataset.source (if any)
56+
matrix: {},
57+
series: {
58+
type: 'scatter',
59+
coordinateSystem: 'matrix',
60+
// Collect values from dimension index 3 and 2.
61+
encode: {x: 3, y: 2},
62+
data: [
63+
// 0 1 2 3 (dimension index)
64+
[100, 111, 122, 133],
65+
[200, 211, 222, 233],
66+
]
67+
}
68+
}
69+
```
70+
4571
#### value(string|number)
4672
{{ use: partial-version(version = "6.0.0") }}
4773
The text in the header cell. Can also be used as a index of this column or row. Optional. If not specified, auto generate a text.
4874

4975
#### children(Array)
5076
{{ use: partial-version(version = "6.0.0") }}
51-
See [matrix.x/y.data](~matrix.x.data).
77+
See [matrix.${matrixDim}.data](~matrix.${matrixDim}.data).
5278

5379
#### size(number)
5480
{{ use: partial-version(version = "6.0.0") }}

en/option/partial/view-coord-sys.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ center: ['50%', '50%']
9090

9191
> The percentage string is introduced since `v5.3.3`. It is initially based on canvas width/height. But that is not reasonable, and then changed to be based on the bounding rect since `v6.0.0`.
9292

93+
{{ use: partial-view-coord-sys-indicator-example-link(
94+
componentNameInLink = ${componentNameInLink}
95+
) }}
9396

9497
#${prefix} zoom(number) = 1
9598

@@ -103,6 +106,10 @@ Zoom rate of current viewport.
103106

104107
When [roaming](~${componentNameInLink}.roam), the values in [center](~${componentNameInLink}.center) and `zoom` will be modified correspondingly.
105108

109+
{{ use: partial-view-coord-sys-indicator-example-link(
110+
componentNameInLink = ${componentNameInLink}
111+
) }}
112+
106113
#${prefix} scaleLimit(Object)
107114

108115
{{ use: partial-scale-limit-desc(
@@ -131,9 +138,11 @@ Options:
131138

132139
{{ if: ${supportClip} }}If `clip: true`, the roaming can only be triggered at any position within the clipped area. Otherwise it can be triggered in canvas globally.{{ else }}The roaming can be triggered in canvas globally.{{ /if }}
133140

134-
{{ if: ${isGeoOrMap} }}
135-
**See example:** [geo roam indicator](${galleryEditorPath}doc-example/geo-roam-indicator&edit=1&reset=1).
136-
{{ /if }}
141+
{{ use: partial-view-coord-sys-indicator-example-link(
142+
componentNameInLink = ${componentNameInLink}
143+
) }}
144+
145+
137146

138147
{{ target: partial-preserve-aspect }}
139148

@@ -166,10 +175,12 @@ Options of `preserveAspect`:
166175

167176
{{ if: ${isGeoOrMap} }}
168177
Notice: When using [layoutCenter](~${componentNameInLink}.layoutCenter) and [layoutSize](~${componentNameInLink}.layoutSize), the `aspect radio` is always preserved, regardless of this `preserveAspect`.
169-
170-
**See example:** [geo roam indicator](${galleryEditorPath}doc-example/geo-roam-indicator&edit=1&reset=1).
171178
{{ /if }}
172179

180+
{{ use: partial-view-coord-sys-indicator-example-link(
181+
componentNameInLink = ${componentNameInLink}
182+
) }}
183+
173184
#${prefix} preserveAspectAlign(string) = 'center'
174185

175186
<ExampleUIControlEnum options="left,right,center" default="center" />
@@ -180,7 +191,9 @@ Options: `'left'` | `'right'` | `'center'`.
180191

181192
See [preserveAspect](~${componentNameInLink}.preserveAspect).
182193

183-
See example [geo roam indicator](${galleryEditorPath}doc-example/geo-roam-indicator&edit=1&reset=1).
194+
{{ use: partial-view-coord-sys-indicator-example-link(
195+
componentNameInLink = ${componentNameInLink}
196+
) }}
184197

185198
#${prefix} preserveAspectVerticalAlign(string) = 'middle'
186199

@@ -192,7 +205,19 @@ Options: `'top'` | `'bottom'` | `'middle'`.
192205

193206
See [preserveAspect](~${componentNameInLink}.preserveAspect).
194207

195-
See example [geo roam indicator](${galleryEditorPath}doc-example/geo-roam-indicator&edit=1&reset=1).
208+
{{ use: partial-view-coord-sys-indicator-example-link(
209+
componentNameInLink = ${componentNameInLink}
210+
) }}
211+
212+
213+
214+
{{ target: partial-view-coord-sys-indicator-example-link }}
215+
216+
{{ if: ${componentNameInLink} === 'geo' || ${componentNameInLink} === 'series-map' }}
217+
**See [geo roam indicator example](${galleryEditorPath}doc-example/geo-roam-indicator&edit=1&reset=1)** to understand the concept.
218+
{{ elif: ${componentNameInLink} === 'series-graph' }}
219+
**See [graph roam indicator example](${galleryEditorPath}doc-example/graph-roam-indicator&edit=1&reset=1)** to understand the concept.
220+
{{ /if }}
196221

197222

198223

zh/option/component/matrix.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
矩阵坐标系(`matrix`)类似表格,可作为系列(`series`)中数据项的布局系统,主要用于展示多维数据的关系与交互。它以矩形网格形式呈现数据,每个网格单元(或"单元格")代表 `series.heatmap``series.scatter``series.custom` 等系列中某个数据点的值。整体布局以行列形式展示,用于表达二维或高维数据之间的关系。
1010

11-
矩阵坐标系(`matrix`)还可作为盒布局系统,布局各个系列、其他坐标系(如 `grid`(即笛卡尔坐标系)、`geo``polar` 等)和普通组件(如 `legend``dataZoom` 等)。该特性支持在表格中布局微型图表,或使用类似 [CSS grid layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout) 的布局方式进行排版。目前,所有系列和组件均可在 `matrix` 中布局。`matrix` 也可纯用作文字数据表。
11+
矩阵坐标系(`matrix`)还可作为盒布局系统,布局各个系列、其他坐标系(如 `grid`(即笛卡尔坐标系)、`geo``polar` 等)和普通组件(如 `legend``dataZoom` 等)。该特性支持在表格中布局 [微型图表](${galleryEditorPath}matrix-sparkline&edit=1&reset=1),或使用类似 [CSS grid layout](${galleryEditorPath}matrix-grid-layout&edit=1&reset=1) 的布局方式进行排版。目前,所有系列和组件均可在 `matrix` 中布局。`matrix` 也可纯用作文字数据表。
1212

1313
在矩阵坐标系中使用热力图的相关矩阵图:
1414
~[800x400](${galleryViewPath}matrix-correlation-heatmap&edit=1&reset=1)
@@ -25,6 +25,13 @@
2525
在矩阵坐标系中使用自定义系列的混淆矩阵图:
2626
~[800x400](${galleryViewPath}matrix-confusion&edit=1&reset=1)
2727

28+
矩阵中的微型图表:
29+
~[800x600](${galleryViewPath}matrix-sparkline&edit=1&reset=1)
30+
~[800x600](${galleryViewPath}matrix-mini-bar-geo&edit=1&reset=1)
31+
32+
以及其他 **微型图** 的例子:[矩阵中的微型柱状图和地图](${galleryEditorPath}matrix-mini-bar-data-collection&edit=1&reset=1)
33+
34+
2835
灵活利用图表系列、坐标系、API 的组合,可以实现更丰富的效果。
2936

3037
引用:
@@ -48,7 +55,8 @@
4855
x 轴表头区。
4956

5057
{{ use: partial-matrix-header(
51-
name: 'x 轴表头区单元格'
58+
name: 'x 轴表头区单元格',
59+
matrixDim = 'x',
5260
) }}
5361

5462
## y(Object)
@@ -58,7 +66,8 @@ x 轴表头区。
5866
y 轴表头区。
5967

6068
{{ use: partial-matrix-header(
61-
name: 'y 轴表头区单元格'
69+
name: 'y 轴表头区单元格',
70+
matrixDim = 'y',
6271
) }}
6372

6473
## body(Object)

zh/option/partial/coord-sys.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191

9292
布局在一个 [矩阵坐标系](~matrix)中。当一个 ECharts 实例中存在多个矩阵坐标系时,须通过 [matrixIndex](~${componentNameInLink}.matrixIndex)[matrixId](~${componentNameInLink}.matrixId) 指定所使用的矩阵坐标系。{{if: ${nonSeriesComponentMainType} === 'grid' }}
9393

94-
参见示例 [矩阵坐标系中直角坐标系](${galleryEditorPath}matrix-cartesian-tiny&edit=1&reset=1)
94+
参见示例 [矩阵坐标系中的微型折线图](${galleryEditorPath}matrix-sparkline&edit=1&reset=1)
9595
{{ /if }}
9696
{{ /if }}
9797

@@ -159,7 +159,7 @@
159159

160160
此系列或组件作为一个整体,在指定的坐标系中进行布局——即根据坐标系计算整体的包围盒或基础锚点。
161161

162-
- 例如,[grid 组件](~grid) 可以布局在 [matrix 坐标系](~matrix)[calendar 坐标系](~calendar) 中,这时其布局矩形是由 [${componentNameInLink}.coords](~${componentNameInLink}.coords) 在坐标系中计算出来的。参见示例:[矩阵中的小型直角坐标系](${galleryEditorPath}matrix-cartesian-tiny&edit=1&reset=1)
162+
- 例如,[grid 组件](~grid) 可以布局在 [matrix 坐标系](~matrix)[calendar 坐标系](~calendar) 中,这时其布局矩形是由 [${componentNameInLink}.coords](~${componentNameInLink}.coords) 在坐标系中计算出来的。参见示例:[矩阵中的微型折线图](${galleryEditorPath}matrix-sparkline&edit=1&reset=1)
163163
- 又如,[饼图系列](~series-pie)[和弦图系列](~series-chord) 可以布局在 [geo 坐标系](~geo)[cartesian2d 坐标系](~grid) 中,这时其中心点是由 [series-pie.coords](~series-pie.coords)[series-pie.center](~series-pie.center) 在坐标系中计算出来的。参见示例:[地理坐标系中的饼图](${galleryEditorPath}map-iceland-pie&edit=1&reset=1)
164164

165165
{{ if: ${seriesType} }}
@@ -178,7 +178,7 @@
178178

179179
[coordinateSystemUsage](~${componentNameInLink}.coordinateSystemUsage)`'box'` 时, `coord` 被输入给坐标系,计算得到布局位置(布局盒或者中心点)。
180180

181-
例子:[微型直角坐标系矩阵](${galleryEditorPath}matrix-cartesian-tiny&edit=1&reset=1), [矩阵中的关系图](${galleryEditorPath}doc-example/matrix-graph-box&edit=1&reset=1).
181+
例子:[矩阵中的微型折线图](${galleryEditorPath}matrix-sparkline&edit=1&reset=1), [矩阵中的关系图](${galleryEditorPath}doc-example/matrix-graph-box&edit=1&reset=1).
182182

183183
{{ if: ${seriesType} === 'pie' }}
184184
在此场景下,[series-pie.center](~series-pie.center)[series-pie.coord](~series-pie.coord) 起同样作用。

zh/option/partial/matrix-header.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ data: ['A', 'B', 'C', 'D', 'E']
1919

2020
// 或者如果不关心列/行名称,可以直接
2121
data: Array(5).fill(null) // 五列或五行
22+
// 注:不支持未初始化数组项的数组:
23+
// data: Array(5) // ❌
2224

2325
// 树状结构的数据
2426
data: [{
@@ -42,6 +44,31 @@ data: [{
4244
}]
4345
```
4446

47+
如果 [matrix.${matrixDim}.data](~matrix.${matrixDim}.data) 没有提供,它会从 `series.data` 或者 `dataset.source` 中自动收集。
48+
49+
参见 [示例](${galleryEditorPath}matrix-mini-bar-data-collection&edit=1&reset=1)
50+
51+
在这种情况下,[series.encode](~series-scatter.encode) 可指定从哪个维度收集数据。例如:
52+
```js
53+
var option = {
54+
// matrix.x/y.data 没有指定。
55+
// 于是从 series.data or dataset.source 收集。
56+
matrix: {},
57+
series: {
58+
type: 'scatter',
59+
coordinateSystem: 'matrix',
60+
// 指定从 dimension index 为 3 和 2 的列收集数据。
61+
encode: {x: 3, y: 2},
62+
data: [
63+
// 0 1 2 3 (dimension index)
64+
[100, 111, 122, 133],
65+
[200, 211, 222, 233],
66+
]
67+
}
68+
}
69+
```
70+
71+
4572
#### value(string|number)
4673
{{ use: partial-version(version = "6.0.0") }}
4774

@@ -50,7 +77,7 @@ data: [{
5077
#### children(Array)
5178
{{ use: partial-version(version = "6.0.0") }}
5279

53-
[matrix.x/y.data](~matrix.x.data).
80+
[matrix.${matrixDim}.data](~matrix.${matrixDim}.data).
5481

5582
#### size(number)
5683
{{ use: partial-version(version = "6.0.0") }}

0 commit comments

Comments
 (0)