Skip to content

Commit f3fce8b

Browse files
author
ian.lxl
committed
docs(tutorial): 更新数据文档和 CDN 引入路径
- 修正 Candlestick 组件数组格式说明 - 将 changeData API 更新为 update 方法 - 修正 CDN 路径为 index.min.js
1 parent ceb96b1 commit f3fce8b

File tree

4 files changed

+62
-16
lines changed

4 files changed

+62
-16
lines changed

site/docs/tutorial/data.en.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,27 @@ The array represents the minimum and maximum values of the interval: `[minimum,
9494

9595
### Candlestick Chart
9696

97-
Candlestick charts require open, close, high, and low prices:
97+
Candlestick charts require open, close, highest, and lowest prices, using array format:
9898

9999
```jsx
100100
const data = [
101-
{ date: '2023-01', open: 100, close: 110, high: 120, low: 95 },
102-
{ date: '2023-02', open: 110, close: 105, high: 115, low: 100 },
103-
{ date: '2023-03', open: 105, close: 120, high: 125, low: 102 },
101+
{ date: '2023-01', value: [100, 110, 95, 120] }, // [open, close, lowest, highest]
102+
{ date: '2023-02', value: [110, 105, 100, 115] },
103+
{ date: '2023-03', value: [105, 120, 102, 125] },
104104
];
105105

106106
<Chart data={data}>
107-
<Candlestick x="date" open="open" close="close" high="high" low="low" />
107+
<Axis field="date" type="timeCat" />
108+
<Candlestick x="date" y="value" />
108109
</Chart>
109110
```
110111

112+
**Array format:** `[open, close, lowest, highest]`
113+
- `open` - Opening price
114+
- `close` - Closing price
115+
- `lowest` - Lowest price
116+
- `highest` - Highest price
117+
111118
### Scatter Plot (Bubble Chart)
112119

113120
Scatter plots can include additional dimensions (such as size):
@@ -237,7 +244,15 @@ const data2 = [
237244
{ genre: 'Strategy', sold: 200 },
238245
];
239246

240-
chart.changeData(data2); // Automatically triggers animation
247+
const { props: newProps } = (
248+
<Canvas context={context}>
249+
<Chart data={data2}>
250+
<Interval x="genre" y="sold" />
251+
</Chart>
252+
</Canvas>
253+
);
254+
255+
chart.update(newProps); // Automatically triggers animation
241256
```
242257

243258
## Common Issues
@@ -392,7 +407,15 @@ Responsive to user interactions:
392407
function updateChart(userInput) {
393408
const data = processData(userInput);
394409

395-
chart.changeData(data);
410+
const { props: newProps } = (
411+
<Canvas context={context}>
412+
<Chart data={data}>
413+
<Interval x="category" y="value" />
414+
</Chart>
415+
</Canvas>
416+
);
417+
418+
chart.update(newProps);
396419
}
397420
```
398421

site/docs/tutorial/data.zh.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,27 @@ const data = [
9494

9595
### 股票图(K线图)
9696

97-
股票图需要包含开盘价、收盘价、最高价、最低价:
97+
股票图需要包含开盘价、收盘价、最高价、最低价,使用数组格式
9898

9999
```jsx
100100
const data = [
101-
{ date: '2023-01', open: 100, close: 110, high: 120, low: 95 },
102-
{ date: '2023-02', open: 110, close: 105, high: 115, low: 100 },
103-
{ date: '2023-03', open: 105, close: 120, high: 125, low: 102 },
101+
{ date: '2023-01', value: [100, 110, 95, 120] }, // [open, close, lowest, highest]
102+
{ date: '2023-02', value: [110, 105, 100, 115] },
103+
{ date: '2023-03', value: [105, 120, 102, 125] },
104104
];
105105

106106
<Chart data={data}>
107-
<Candlestick x="date" open="open" close="close" high="high" low="low" />
107+
<Axis field="date" type="timeCat" />
108+
<Candlestick x="date" y="value" />
108109
</Chart>
109110
```
110111

112+
**数组格式说明:** `[open, close, lowest, highest]`
113+
- `open` - 开盘价
114+
- `close` - 收盘价
115+
- `lowest` - 最低价
116+
- `highest` - 最高价
117+
111118
### 散点图(气泡图)
112119

113120
散点图可以包含额外的维度(如大小):
@@ -237,7 +244,15 @@ const data2 = [
237244
{ genre: 'Strategy', sold: 200 },
238245
];
239246

240-
chart.changeData(data2); // 自动触发动画
247+
const { props: newProps } = (
248+
<Canvas context={context}>
249+
<Chart data={data2}>
250+
<Interval x="genre" y="sold" />
251+
</Chart>
252+
</Canvas>
253+
);
254+
255+
chart.update(newProps); // 自动触发动画
241256
```
242257

243258
## 常见问题
@@ -392,7 +407,15 @@ fetchData();
392407
function updateChart(userInput) {
393408
const data = processData(userInput);
394409

395-
chart.changeData(data);
410+
const { props: newProps } = (
411+
<Canvas context={context}>
412+
<Chart data={data}>
413+
<Interval x="category" y="value" />
414+
</Chart>
415+
</Canvas>
416+
);
417+
418+
chart.update(newProps);
396419
}
397420
```
398421

site/docs/tutorial/getting-started.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ npm install @antv/f2 --save
3030
### Install via CDN
3131

3232
```html
33-
<script src="https://unpkg.com/@antv/f2/dist/f2.min.js"></script>
33+
<script src="https://unpkg.com/@antv/f2/dist/index.min.js"></script>
3434
```
3535

3636
## Configure JSX Transform

site/docs/tutorial/getting-started.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ npm install @antv/f2 --save
3030
### 通过 CDN 引入
3131

3232
```html
33-
<script src="https://unpkg.com/@antv/f2/dist/f2.min.js"></script>
33+
<script src="https://unpkg.com/@antv/f2/dist/index.min.js"></script>
3434
```
3535

3636
## 配置 JSX 转换

0 commit comments

Comments
 (0)