1.0.2 • Published 5 years ago

chart-race-react v1.0.2

Weekly downloads
18
License
MIT
Repository
github
Last release
5 years ago

chart-race-react

📊 Seamless & fully customizable bar chart race component for React.

https://www.npmjs.com/package/chart-race-react .

Quick Start

npm install --save chart-race-react
import BarChart from 'chart-race-react';

You should wrap BarChart inside a container div that acts as a sandbox. The width of the BarChart fits the container width.

<div style={{width: "500px"}}>
    <BarChart />
</div>

Demo

Colors
Style
Speed

Usage

Passing props.

You will need to pass your own props to the BarChart component. Refer to examples for more information.

PropTypeExplanation
startBooleanDefines whether the bar chart race has started. Default is true and the chart race will start as the component mounts.
dataObjectAn object with keys being the data field name and value being Array data. data[key].length should be equal to len.
timelineArrayAn array defining the time indices. Length should be equal to len.
labelsObjectAn object with keys being the data field name and value being a HTML element that acts as the data field's label.
colorsObjectAn object with keys being the data field name and value being the color the data bar.
timeoutIntegerTransition time between adjacent time indices (in ms).
delayIntegerWaiting time between adjacent time indices (in ms).
timelineStyleObjectCSS style objects for time indices.
textBoxStyleObjectCSS style objects for data text.
barStyleObjectCSS style object defining the style of all the bars. It is advised to use height to define the thickness and marginTop to define the distance between adjacent bars.
widthArrayDefines the width allocation for label, bar, and text box. Values in width should add up to 100.
maxItemsIntegerDefines the maximum number of items to show in the chart. Should be less or equal to Object.keys(data).length.

More Demo

Easibly define custom data, text styles, colors, duration, and layout.