Skip to content

Commit 1faf0c2

Browse files
committed
doc(candlestick): add doc for remap OHLC to OCLH (fix apache/echarts#21602)
1 parent 8cb1409 commit 1faf0c2

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

en/option/series/candlestick.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,39 @@ Every data item (each line in the example above) represents a box, which contain
180180
[open, close, lowest, highest] (namely: [opening value, closing value, lowest value, highest value])
181181
```
182182

183+
That means the default dimension order of `candlestick` is **OCLH**. If your source data is in the **OHLC** order (`[open, highest, lowest, close]`), you can explicitly remap dimensions via [series-candlestick.encode](~series-candlestick.encode). This applies to both [dataset](~dataset) and [series.data](~series-candlestick.data).
184+
185+
For example, if each item in `series.data` is `[open, high, low, close]`, you can configure:
186+
187+
```javascript
188+
series: [{
189+
type: 'candlestick',
190+
data: [
191+
// [date, open, high, low, close]
192+
['2025-05-01', 2320.26, 2362.94, 2287.3, 2320.26],
193+
['2025-05-02', 2300, 2308.38, 2288.26, 2291.3]
194+
],
195+
encode: {
196+
x: 0,
197+
y: [1, 4, 3, 2] // Remap OHLC to OCLH without reordering the source data array
198+
}
199+
}]
200+
```
201+
183202
### name(string)
184203

185204
Name of data item.
186205

187206
### value(Array)
188207

189-
Value of data item.
208+
Value of data item. Default dimension order is **OCLH**.
190209

191210
```javascript
192211
[open, close, lowest, highest] (namely: [opening value, closing value, lowest value, highest value])
193212
```
194213

214+
To adjust the default dimension order, see [series-candlestick.data](~series-candlestick.data) above.
215+
195216
{{ use: partial-data-group-id(
196217
prefix = '##'
197218
) }}

zh/option/series/candlestick.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,19 +369,39 @@ K 线图的选中状态。开启 [selectedMode](~series-candlestick.selectedMode
369369
[open, close, lowest, highest] (即:[开盘值, 收盘值, 最低值, 最高值])
370370
```
371371

372+
也就是说,`candlestick` 默认维度顺序是 **OCLH**。如果你的原始数据是 **OHLC**`[open, highest, lowest, close]`),可以通过 [series.encode](~series-candlestick.encode) 显式指定维度映射来调整。这对 [dataset](~dataset)[series.data](~series-candlestick.data) 两种写法都支持。
373+
374+
例如,OHLC 数据可这样映射:
375+
376+
```javascript
377+
series: [{
378+
type: 'candlestick',
379+
data: [
380+
// [date, open, high, low, close]
381+
['2025-05-01', 2320.26, 2362.94, 2287.3, 2320.26],
382+
['2025-05-02', 2300, 2308.38, 2288.26, 2291.3]
383+
],
384+
encode: {
385+
x: 0,
386+
y: [1, 4, 3, 2] // 不修改 data,而是通过 encode 将 OHLC 映射到 OCLH
387+
}
388+
}]
389+
```
390+
372391
### name(string)
373392

374393
数据项名称。
375394

376395
### value(Array)
377396

378-
数据项值。
379-
397+
数据项值。默认维度顺序为 **OCLH**
380398

381399
```javascript
382400
[open, close, lowest, highest] (即:[开盘值, 收盘值, 最低值, 最高值])
383401
```
384402

403+
如需调整默认维度顺序,参见上文 [series-candlestick.data](~series-candlestick.data)
404+
385405
{{ use: partial-data-group-id(
386406
prefix = '##'
387407
) }}

0 commit comments

Comments
 (0)