Skip to content

Commit

Permalink
Updated readme [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Oct 19, 2021
1 parent d583c51 commit b592c71
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,31 @@ data = [
<LineChart data={data} />
```

## Data

Pass data as an array or object

```jsx
<LineChart data={[["2021-01-01", 2], ["2021-01-02", 3]]} />
```

or

```jsx
<LineChart data={{"2021-01-01": 2, "2021-01-02": 3}} />
```

Data can also be a callback

```jsx
function fetchData(success, fail) {
success({"2021-01-01": 2, "2021-01-02": 3})
// or fail("Data not available")
}

<LineChart data={fetchData} />
```

### Say Goodbye To Timeouts

Make your pages load super fast and stop worrying about timeouts. Give each chart its own endpoint.
Expand All @@ -93,7 +118,7 @@ Make your pages load super fast and stop worrying about timeouts. Give each char
<LineChart data="/stocks" />
```

### Options
## Options

Id, width, and height

Expand Down Expand Up @@ -261,32 +286,6 @@ Chartkick.options = {
}
```

### Data

Pass data as an array or object

```jsx
<PieChart data={{"Blueberry": 44, "Strawberry": 23}} />
<PieChart data={[["Blueberry", 44], ["Strawberry", 23]]} />
```

Times can be a `Date` or a string (strings are parsed)

```jsx
<LineChart data={[[new Date(), 5], ["2021-01-01 00:00:00 UTC", 7]]} />
```

Data can also be a callback

```jsx
function fetchData(success, fail) {
success({"Blueberry": 44, "Strawberry": 23})
// or fail("Data not available")
}

<PieChart data={fetchData} />
```

### Multiple Series

You can pass a few options with a series:
Expand Down

0 comments on commit b592c71

Please sign in to comment.