woocommerce/plugins/woocommerce-admin/client/components/d3/charts
Robert Elliott da980328e2 move dummy js and add README 2018-07-10 16:09:47 +02:00
..
test move dummy js and add README 2018-07-10 16:09:47 +02:00
README.md move dummy js and add README 2018-07-10 16:09:47 +02:00
index.js move dummy js and add README 2018-07-10 16:09:47 +02:00
style.scss bar chart and example 2018-07-09 15:35:12 +02:00
utils.js refactor params to reduce recalculating scales each time + new tests 2018-07-09 15:35:25 +02:00

README.md

D3 Chart Component

A simple D3 line and bar chart component for timeseries data in React

Expected Data Format

This component accepts timeseries data prop in the following format:

[
	{
		date: 'YYYY-mm-dd', // string
		category1: value, // number
		category2: value, // number
		...
	},
	...
]

For example:

[
	{
		date: '2018-06-25',
		category1: 1234.56,
		category2: 9876.54,
		...
	},
	...
]

Sizing

The chart component will scale into the containing div; however, it is possible to additionally pass in a width and height, which will scale the viewport of the chart.

The component props can be passed in as (default values shown):

...
height={ 200 }
margin={ { bottom: 30, left: 40, right: 0, top: 20 } }
width={ 600 }
...

Type

Currently, the component only accepts 2 different types, namely line or bar. A bar chart with multiple categories will display the categories in bar groups per date. The line chart will display multiple lines, one for each category.

Axis Formats - tbc

Tooltip - tbc

Legend - tbc