Skip to content

Commit 738686b

Browse files
committed
Update README
1 parent d4e2fec commit 738686b

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

README.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# @berryv/g2-react
22

3-
> WIP
4-
5-
The lightweight [React](https://react.dev/) component for [@antv/g2 5.0](https://github.com/antvis/G2).
3+
The lightweight [React](https://react.dev/) component for [@antv/g2 5.0](https://github.com/antvis/G2), which is based on the [Spec API](https://g2.antv.antgroup.com/manual/core/api).
64

75
## Installing
86

@@ -40,21 +38,23 @@ export function Demo() {
4038
| Property | Description | Type | Default |
4139
| -------- | --------------------------------------------------------------------------------------------------------------- | --------------------- | ------- |
4240
| options | the [options](https://g2.antv.antgroup.com/manual/core/api) for the visualization, say `chart.options(options)` | `G2options` \| `null` | - |
43-
| renderer | the [renderer](https://g.antv.antgroup.com/api/renderer/intro) of @antv/g canvas. | `ChartOptions` | - |
41+
| renderer | the [renderer](https://g.antv.antgroup.com/api/renderer/intro) of @antv/g canvas | `ChartOptions` | - |
4442
| style | the style of the container | `CSSProperties` | - |
4543
| onInit | the callback called after the chart instantiating | `Function` | - |
4644
| ref | the ref for the [chart instance](https://g2.antv.antgroup.com/manual/core/chart) | `ChartRef` | - |
4745

4846
## Examples
4947

5048
- [Creating Chart](#creating-chart)
51-
- [Fetching Data](#fetching-data)
49+
- [Fetching Data](#updating-data)
5250
- [Handling Events](#handling-events)
5351
- [Customizing Component](#customizing-component)
5452
- [Styling Container](#styling-container)
5553

5654
## Creating Chart
5755

56+
For more examples for `props.options`, see each [G2 example](https://g2.antv.antgroup.com/examples) and click the "Spec Tab".
57+
5858
```js
5959
import React from "react";
6060
import { Chart } from "@berryv/g2-react";
@@ -83,7 +83,9 @@ export function Demo() {
8383
}
8484
```
8585

86-
### Fetching Data
86+
### Updating Data
87+
88+
Using `useMemo` to define a computed options with data as a decency, this allows rerendering chart after the data updating.
8789

8890
```js
8991
import React, { useState, useMemo } from "react";
@@ -122,6 +124,8 @@ export function Demo() {
122124

123125
### Handling Events
124126

127+
`<Chart/>` exposes the ref for the G2 [chart instance](https://g2.antv.antgroup.com/manual/core/chart), which can be used to handle events or get some instances, such as scale, coordinate, etc,.
128+
125129
```js
126130
import React, { useRef, useEffect } from "react";
127131
import { ChartEvent } from "@antv/g2";
@@ -153,6 +157,8 @@ export function Demo() {
153157

154158
### Customizing Component
155159

160+
With the `register` API of G2, you can customize visual component and using it in options, such as customizing a triangle shape for bar chart:
161+
156162
```js
157163
import React, { useRef, useEffect } from "react";
158164
import { register } from "@antv/g2";
@@ -203,6 +209,8 @@ export function Demo() {
203209

204210
### Styling Container
205211

212+
Define the css styles of the container:
213+
206214
```js
207215
import React from "react";
208216
import { Chart } from "@berryv/g2-react";

0 commit comments

Comments
 (0)