Skip to content

Commit 84c343d

Browse files
committed
readme
1 parent 95a508c commit 84c343d

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,28 @@ yarn add uplot-react-native
2222

2323
## Usage
2424

25-
Create a uPlot chart via the `ChartUPlot` component, which takes in initial data and options as props. The data and options take the same form as when you call `new uPlot(options, data)`. You can update the chart via a `ref`.
25+
Create a uPlot chart via `ChartUPlot`. The `data` and `options` props it takes are structured the same as when you call `new uPlot(options, data)`. You update the chart via a `ref`.
2626

2727
```javascript
2828
import { useRef, useEffect } from 'react';
2929
import { ChartUPlot } from 'uplot-react-native';
3030

3131
var x = 6;
32+
const data = [
33+
[1, 2, 3, 4, 5],
34+
[5, 4, 3, 2, 1],
35+
];
36+
37+
const options = {
38+
id: 'chart',
39+
width: 300,
40+
height: 300,
41+
scales: { x: { time: false } },
42+
series: [{ label: 'X' }, { label: 'Value', stroke: 'blue', width: 2 }],
43+
axes: [{ scale: 'x' }, {}],
44+
};
3245

3346
const MyChart = () => {
34-
const data = [
35-
[1, 2, 3, 4, 5],
36-
[5, 4, 3, 2, 1],
37-
];
38-
39-
const options = {
40-
id: 'chart',
41-
width: 300,
42-
height: 300,
43-
scales: { x: { time: false } },
44-
series: [{ label: 'X' }, { label: 'Value', stroke: 'blue', width: 2 }],
45-
axes: [{ scale: 'x' }, {}],
46-
};
47-
4847
const chartRef = useRef(null);
4948

5049
useEffect(() => {
@@ -66,7 +65,7 @@ const MyChart = () => {
6665
};
6766
```
6867
69-
The ref exposes the following methods:
68+
The `ref` exposes the following methods:
7069
7170
- `createChart(options, data)`: Create a new chart. The initial render of ChartUPlot will automatically call this method with the initial options and data.
7271
- `setData(newData)`: Replace the data in the chart.

0 commit comments

Comments
 (0)