Skip to content

Commit 934128f

Browse files
authored
Merge pull request #462 from apache/feat-cartesian-layout
Feat cartesian layout
2 parents 1a18eeb + a99907c commit 934128f

41 files changed

Lines changed: 348 additions & 80 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,6 @@ slides/webgl
188188
/tool/blocks-zh.json
189189

190190
/zh-src
191-
/en-src
191+
/en-src
192+
193+
/config/env.*-local.js

README.md

Lines changed: 111 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This project is part of the source of [The Apache ECharts Official Website](http
1515

1616
## Development
1717

18-
### Document content development
18+
### Document Content Development
1919

2020
Do not need other project.
2121

@@ -28,46 +28,59 @@ It will:
2828
+ Watch doc site src change and rebuild.
2929
+ Watch doc markdown change and rebuild.
3030

31+
### Local Config
3132

32-
## Tips about writing doc
33+
To customize the links of `echarts-examples` and other configurations, you can create a local config file `echarts-doc/config/env.dev-local.js`, which is not tracked by git. The content can be copied from `echarts-doc/config/env.dev.js`, and then modify it as needed. `npm run dev` will use this local config file, if it exists, to replace `echarts-doc/config/env.dev.js`.
3334

34-
### "Since version" is necessary in doc
35+
36+
## Tips About Writing Doc
37+
38+
### "Since Version"
39+
"Since Version" is necessary in doc.
3540
Marking "since version" indicates when a new feature was introduced.
3641
For example,
3742
```
3843
{{ use: partial-version(version = "6.0.0") }}
3944
```
4045

41-
### Global variables can be used in doc
46+
### Global Variables
47+
48+
These global variables can be used in doc:
49+
+ `${galleryViewPath}`
50+
+ `${galleryEditorPath}`
51+
+ `${websitePath}`
4252

43-
+ galleryViewPath
44-
+ galleryEditorPath
45-
+ websitePath
53+
See samples in "Reference of echarts-examples or other links"
4654

47-
For example:
48-
Embed a example in doc:
55+
### Reference of echarts-examples or Other Links
56+
57+
Embed an example in doc:
4958
```md
59+
~[700X300](${galleryEditorPath}pie-legend&edit=1&reset=1)
5060
~[700x300](${galleryViewPath}doc-example/aria-pie&edit=1&reset=1)
5161
```
52-
Provide a example link in doc:
62+
63+
Provide an example link in doc:
5364
```md
5465
[vertically scrollable legend](${galleryEditorPath}pie-legend&edit=1&reset=1)
66+
[aria pie](${galleryViewPath}doc-example/aria-pie&edit=1&reset=1)
5567
```
68+
5669
Provide a website link in doc:
5770
```md
5871
[Apache ECharts website](${websitePath}/en/download.html)
5972
```
6073

61-
### Reference of option
74+
### Reference of Other ECharts Option
6275

6376
A `~` can be used to refer to a option item in the same doc. For example:
64-
6577
```md
6678
[xAxis.name](~xAxis.name)
6779
```
6880

6981
If intending to reference an anchor in different doc, it can be:
7082
```md
83+
In api.html, reference
7184
[itemStyle](option.html#series.itemStyle)
7285
```
7386

@@ -112,6 +125,60 @@ It indicates the range of saturation (color alpha) {{ if: ${prefix} !== '#' }}fo
112125
113126
```
114127

128+
### Doc Structure
129+
130+
+ Entries:
131+
+ the entry in source code is like `en/api/api.md`, `en/api/option.md`, they will be compiled to webpage like `api.html`, `option.html`
132+
133+
+ Shared targets (text blocks):
134+
+ All of the shared targets should be put into the `partial` folder, such as, `en/api/partial/xxx`, `en/optino/partial/xxx`, and named with a prefix `partial-`.
135+
136+
+ Subtitles:
137+
+ The doc is structured by subtitles.
138+
+ For example:
139+
```
140+
# series.bar(Object)
141+
## propA(number|string) = null
142+
some desc xxx
143+
## propB(number|string) = null
144+
some desc yyy
145+
## propC(string) = ${defaultPropC|default("'auto'")}
146+
147+
#${prefix} someOtherProp(Object)
148+
some desc zzz
149+
```
150+
+ `(xxx|yyy)` is the data type in that subtitle:
151+
+ Can only be `number`, `string`, `boolean`, `Object`, `Array`, `Function`
152+
+ Can be an union, such as `number|string`.
153+
+ `= xxx` is the default value in that subtitle:
154+
+ Can be omitted.
155+
+ Typically be `null`, `undefined`, `true`, `false`, `90` (a literal number), `some literal string`, `[0, 90]` (an literal array).
156+
+ The default value can be specified by a template variable, such as, `= ${someVar}`, `= ${someVar|default(123)}`, `= ${someVar|default("'auto'")}`.
157+
+ The top level subtitles:
158+
+ For example, `# series.bar(Object)`, the dot symbol represents a special meaning: the component main type is `'series'` and the component sub-type is `'bar'`.
159+
+ The variable `${prefix}`
160+
+ It is commonly used in "target: partial-xxx", which serves different subtitle levels. The value of `${prefix}` is like `'#'`, `'##'`, `'###'`, ...
161+
+ Typical usage:
162+
```tpl
163+
When we define a "target"
164+
{{ target: partial-abc-1 }}
165+
#${prefix} propLayout(Object)
166+
All of the subtitles should uses that prefix variable.
167+
##${prefix} x(number)
168+
some desc
169+
##${prefix} y(number)
170+
some desc
171+
{{ /target }}
172+
{{ target: partial-target-2 }}
173+
```
174+
```tpl
175+
When we use that "partial-abc-1"
176+
{{ target: partial-def-2 }}
177+
#${prefix|default('#')} somePropA(Object)
178+
{{ use: partial-abc-1(
179+
prefix: ${prefix} + '#'
180+
) }}
181+
```
115182
116183
### Template Syntax
117184
@@ -120,11 +187,22 @@ The template syntax follows [etpl](https://github.com/ecomfe/etpl/blob/master/do
120187
121188
Summary of the commonly used syntax:
122189
```template
123-
VARIABLE:
124-
some text ${someVariable} some text
125-
126-
127-
IF ELSE:
190+
--- TEMPLATE VARIABLE ---
191+
Use a variable:
192+
some text ${someVariable} some text
193+
Variable scope:
194+
The scope of any variable is "target" (see below).
195+
Variable filter:
196+
Some predefined filters can be used in the template variable, e.g.,
197+
${someVariable|default("'auto'")} means using the string "'auto'"
198+
as the default if ${someVariable} is '' or null or undefined.
199+
Declaration or assignment of a target-local variable:
200+
{{ var: myVar = 'some' }}
201+
{{ var: myVar = 123 }}
202+
{{ var: myVar = ${someOtherStr} + 'some_str' }}
203+
204+
205+
--- IF ELSE ---
128206
{{ if: ${number1} > 0 }}
129207
some text xxx
130208
{{ elif: ${string1} === 'abc' }}
@@ -134,34 +212,40 @@ some text zzz
134212
{{ /if }}
135213
136214
137-
FOR LOOP:
215+
--- FOR LOOP ---
138216
{{ for: ${persons} as ${person}, ${index} }}
139217
some text ${index}: ${person.name}
140218
{{ /for }}
141219
142220
143-
TARGET (DEFINE A BLOCK):
221+
--- TARGET (DEFINE A TEXT BLOCK) ---
144222
{{ target: a_predefined_block_name_1 }}
145223
The input varA is ${varA}
146224
The input varB is ${varB}
147225
The input varC is ${varC}
148-
some other text xxx
149-
(The close target can be omitted, but not recommended.)
226+
Notice:
227+
- The scope of the "target name" is the entire webpage (such as, `option.html`, `api.html`), so name conflicts should be avoided.
228+
- "target" is not shared across webpage (such as, `option.html`, `api.html`).
229+
- The close tag of "target" can be omitted, but not recommended.
150230
{{ /target }}
151231
152232
153-
USE (USE A BLOCK):
154-
{{ use: a_predefined_block_name_1(
233+
--- USE (USE A PREDEFINED TEXT BLOCK) ---
234+
{{ use: a_predefined_block_name_1 }}
235+
{{ use: a_predefined_block_name_2(
155236
varA = ${myVarX},
156237
varB = 123,
157-
varC = 'some string'
158-
)}}
159-
{{ use: a_predefined_block_name_2 }}
238+
varC = 'some string',
239+
prefix: ${prefix} + '##'
240+
) }}
241+
Concatenation operator `+` can be used in that string.
160242
```
161243

162244

163245
### Document Embedded Examples
164246

247+
This is the embedded example that can be opened by clicking "try it" and then appears on the right side of the doc page.
248+
165249
Declare the base echarts options (`ExampleBaseOption`), whose scope is each echarts component or series. A `ExampleBaseOption` can be shared by multiple options. e.g.,
166250
```md
167251
<ExampleBaseOption name="cartesian-bar" title="直角坐标系上的柱状图" title-en="Bar on Cartesian">
@@ -199,7 +283,7 @@ npm run format
199283

200284
Make sure have a double review on the git diff after formatted.
201285

202-
## Sync docs between different languages.
286+
## Sync Docs Between Different Languages
203287

204288
After you finished editing doc of one language. You can use following script to sync it to another language.
205289

build.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ function initEnv() {
4646

4747
let config = require('./config/env.' + envType);
4848

49+
const localOverridePath = './config/env.' + envType + '-local.js';
50+
if (fs.existsSync(path.join(__dirname, localOverridePath))) {
51+
config = require(localOverridePath);
52+
}
53+
4954
assert(path.isAbsolute(config.releaseDestDir) && path.isAbsolute(config.ecWWWGeneratedDir));
5055

5156
config.envType = envType;

en/api/version.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{{ target: partial-version }}
22

3+
{{ if: ${deprecated} }}
4+
> Deprecated since `v${version}`. ${deprecated}
5+
{{ else }}
36
> Since `v${version}`
7+
{{ /if }}
48

59
{{ // this line break is necessary for md quote }}

en/option-gl/partial/version.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
{{ target: partial-version }}
33

4+
{{ if: ${deprecated} }}
5+
> Deprecated since{{ if: ${isECharts} }} ECharts{{ /if }} `v${version}`. ${deprecated}
6+
{{ else }}
47
> Since{{ if: ${isECharts} }} ECharts{{ /if }} `v${version}`
5-
8+
{{ /if }}

en/option/component/grid.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@ In ECharts 2.x, there could only be one single grid component at most in a singl
2222
Whether to show the grid in rectangular coordinate.
2323

2424
{{ use: partial-rect-layout-width-height(
25-
componentName = "grid ",
25+
componentName = "grid",
2626
defaultLeft = "'10%'",
2727
defaultTop = 60,
2828
defaultRight = "'10%'",
2929
defaultBottom = 60
3030
) }}
3131

3232
## containLabel(boolean) = false
33-
3433
<ExampleUIControlBoolean default="false" />
3534

35+
{{ use: partial-version(version = "6.0.0", deprecated = 'See [grid.outerBoundsMode](~grid.outerBoundsMode).') }}
36+
3637
Whether the grid region contains [axis tick label](~yAxis.axisLabel).
3738

3839
+ When containLabel is `false`:
@@ -42,6 +43,68 @@ Whether the grid region contains [axis tick label](~yAxis.axisLabel).
4243
+ `grid.left` `grid.right` `grid.top` `grid.bottom` `grid.width` `grid.height` decide the location and size of the rectangle that contains the axes, and the labels of the axes.
4344
+ Setting to `true` will help when the length of axis labels is dynamic and is hard to approximate. This will avoid labels from overflowing the container or overlapping other components.
4445

46+
## outerBoundsMode(string) = 'auto'
47+
{{ use: partial-version(version = "6.0.0") }}
48+
49+
The "outer bounds" is a constraint rectangle used to prevent axis labels and axis names from overflowing. `outerBoundsMode` defines the strategy for determining the "outer bounds".
50+
51+
In most cases, we do not need to specify [grid.outerBoundsMode](~grid.outerBoundsMode), [grid.outerBounds](~grid.outerBounds), [grid.outerBoundsContain](~grid.outerBoundsContain) and [grid.containLabel](~grid.containLabel), as the default settings can prevent axis labels and axis names from overflowing the canvas.
52+
53+
The grid component (Cartesian) layout strategy:
54+
+ First, lay out axis lines based on the rect defined by [grid.left](~grid.left)/[right](~grid.right)/[top](~grid.top)/[bottom](~grid.bottom)/[width](~grid.width)/[height](~grid.height). This can meet the requirement of aligning axis lines across multiple grids.
55+
+ Then, if axis labels and/or axis names overflow the "outer bounds", shrink the rectangle to prevent that overflow. [grid.outerBoundsContain](~grid.outerBoundsContain) determines whether axis label and axis name is confined by the "outer bounds".
56+
57+
Options of `outerBoundsMode`:
58+
- `'auto'`/`null`/`undefined` (default):
59+
- Behave the same as `outerBoundsMode: 'same'` when `grid.containLabel: true`.
60+
- Otherwise, the "outer bounds" is determined by [grid.outerBounds](~grid.outerBounds) if specified.
61+
- Otherwise, automatically determine the "outer bounds" - typically defaulting to the current canvas, or a assigned layout rectangle if this `grid` is laid out in another coordinate system (see [grid.coordinateSystem](~grid.coordinateSystem)).
62+
- `'none'`: Force the "outer bounds" to be infinity (i.e., no constraint), regardless of the specified [grid.outerBounds](~grid.outerBounds).
63+
- `'same'`: Force the "outer bounds" to be the same as the layout rectangle defined by [grid.left](~grid.left)/[right](~grid.right)/[top](~grid.top)/[bottom](~grid.bottom)/[width](~grid.width)/[height](~grid.height), regardless of the specified [grid.outerBounds](~grid.outerBounds).
64+
65+
> The "outer bounds" encompasses the functionality of [grid.containLabel](~grid.containLabel); therefore, [grid.containLabel](~grid.containLabel) is deprecated. `grid.containLabel: true` is equivalent to `grid: {outerBoundsMode: 'same', outerBoundsContain: 'axisLabel'}`.
66+
> The effect might be slightly different, but usually indiscernible. You can use the code below to enforce the previous effect, though it's unnecessary in most cases.
67+
> ```js
68+
> import {use} from 'echarts/core';
69+
> import {LegacyGridContainLabel} from 'echarts/features';
70+
> use([LegacyGridContainLabel]);
71+
> ```
72+
73+
**Demo**: [outerBounds example](${galleryEditorPath}doc-example/grid-outerBounds&edit=1&reset=1).
74+
75+
76+
## outerBounds(Object)
77+
{{ use: partial-version(version = "6.0.0") }}
78+
79+
See details in [grid.outerBoundsMode](~grid.outerBoundsMode).
80+
81+
See also [outerBounds example](${galleryEditorPath}doc-example/grid-outerBounds&edit=1&reset=1).
82+
83+
{{ use: partial-rect-layout-width-height(
84+
hostName = "`outerBounds`",
85+
noZ = true,
86+
prefix = '##',
87+
defaultLeft = 0,
88+
defaultTop = 0,
89+
defaultRight = 0,
90+
defaultBottom = 0
91+
) }}
92+
93+
## outerBoundsContain(boolean) = 'auto'
94+
{{ use: partial-version(version = "6.0.0") }}
95+
96+
Options:
97+
- `'auto'`/`null`/`undefined` (default):
98+
- Behave the same as `outerBoundsContain: 'axisLabel'` if `containLabel: true`.
99+
- Otherwise, behave the same as `outerBoundsContain: 'all'`.
100+
- `'all'`: The "outer bounds" constrain the grid (Cartesian) rectangle (determined by the x-axis and y-axis lines) and axis labels and axis names.
101+
- `'axisLabel'`: The "outer bounds" constrain the grid (Cartesian) rectangle (determined by the x-axis and y-axis lines) and axis labels, but exclude axis names.
102+
103+
For more details, see [grid.outerBoundsMode](~grid.outerBoundsMode).
104+
105+
See also [outerBounds example](${galleryEditorPath}doc-example/grid-outerBounds&edit=1&reset=1).
106+
107+
45108
{{ use: partial-component-common-style(
46109
componentName = "grid",
47110
prefix = '#',

en/option/component/parallel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
) }}
1414

1515
{{ use: partial-rect-layout-width-height(
16-
componentName = 'parallel ',
16+
componentName = 'parallel',
1717
defaultLeft = 80,
1818
defaultRight = 80,
1919
defaultTop = 60,

en/option/component/title.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Set this to `true` to enable triggering events
113113
The gap between the main title and subtitle.
114114

115115
{{ use: partial-rect-layout(
116-
componentName = "title "
116+
componentName = "title"
117117
) }}
118118

119119
{{ use: partial-component-common-style(

en/option/component/visual-map.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Define visual channels that will mapped from dataValues that are **out of select
358358
See available configurations in [${visualMapName}.inRange](~${visualMapName}.inRange)
359359

360360
{{ use: partial-rect-layout(
361-
componentName = "visualMap ",
361+
componentName = "visualMap",
362362
defaultZ = "4",
363363
defaultLeft = "0",
364364
defaultRight = "auto",

0 commit comments

Comments
 (0)