2018-07-11 15:23:16 +00:00
D3 Chart Component
===
A simple D3 line and bar chart component for timeseries data in React.
## Usage
```jsx
2018-09-05 21:22:34 +00:00
< Chart
2018-07-11 15:23:16 +00:00
data={ timeseries }
2018-09-05 21:22:34 +00:00
tooltipFormat={ 'Date is %Y-%m-%d' }
2018-07-11 15:23:16 +00:00
type={ 'bar' }
2018-09-05 21:22:34 +00:00
xFormat={ '%d' }
yFormat={ '.3s' }
2018-07-11 15:23:16 +00:00
/>
```
### Expected Data Format
This component accepts timeseries `data` prop in the following format (with dates following the [ISO 8601 format ](https://en.wikipedia.org/wiki/ISO_8601 )):
```
[
{
2018-09-05 21:22:34 +00:00
date: '%Y-%m-%dT%H:%M:%S', // string
2018-07-11 15:23:16 +00:00
category1: value, // number
category2: value, // number
...
},
...
]
```
For example:
```
[
{
2018-09-05 21:22:34 +00:00
date: '2018-06-25T00:00:00',
2018-07-11 15:23:16 +00:00
category1: 1234.56,
category2: 9876,
...
},
...
]
```
### Props
Required props are marked with `*` .
Name | Type | Default | Description
--- | --- | --- | ---
2018-09-05 21:22:34 +00:00
`data` * | `array` | none | An array of data as specified above(below)
2018-07-11 15:23:16 +00:00
`type` * | `string` | `line` | Chart type of either `line` or `bar`
2018-09-05 21:22:34 +00:00
`title` | `string` | none | Chart title
`tooltipFormat` | `string` | `%Y-%m-%d` | Title and format of the tooltip title
`xFormat` | `string` | `%Y-%m-%d` | d3TimeFormat of the x-axis values
`yFormat` | `string` | `.3s` | d3Format of the y-axis values