2018-07-11 14:52:10 +00:00
D3 Chart Component
===
A simple D3 line and bar chart component for timeseries data in React.
## Usage
```jsx
< D3Chart
className="woocommerce-dashboard__*"
data={ timeseries }
height={ 200 }
margin={ { bottom: 30, left: 40, right: 0, top: 20 } }
type={ 'bar' }
width={ 600 }
/>
```
2018-07-10 12:46:57 +00:00
2018-07-11 14:52:10 +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-07-10 12:46:57 +00:00
```
[
{
date: 'YYYY-mm-dd', // string
category1: value, // number
category2: value, // number
...
},
...
]
```
For example:
```
[
{
date: '2018-06-25',
category1: 1234.56,
2018-07-11 14:52:10 +00:00
category2: 9876,
2018-07-10 12:46:57 +00:00
...
},
...
]
```
2018-07-11 14:52:10 +00:00
### Props
Required props are marked with `*` .
2018-07-10 12:46:57 +00:00
2018-07-11 14:52:10 +00:00
Name | Type | Default | Description
--- | --- | --- | ---
`data` * | `array` | none | An array of data as specified above
`height` | `number` | `200` | Relative viewpoirt height of the `svg`
`margin` | `object` | `{ bottom: 30, left: 40, right: 0, top: 20 }` | Margins for axis and chart padding
`type` * | `string` | `line` | Chart type of either `line` or `bar`
`width` | `number` | `600` | Relative viewport width of the `svg`