Column Chart
A column chart is a data visualization where each category is represented by a rectangle, with the height of the rectangle being proportional to the values being plotted. Column charts are also known as vertical bar charts. Idea is to develop column charts in react-vis. React-vis is a charting library that provides chart components. In other words, the chart is composed of multiple sub-components like XYPlot, xAxis, yAxis. The following are the components that are used to develop a column chart.
Usage
2 . Add data or URL to ColumnChart component.
Examples
Basic ColumnChart With X and Y Axis: Demo
Basic ColumnChart with Labels: Demo
Stacked ColumnChart With Legends: Demo
Grouped ColumnChart With Legends: Demo
Props
Note: External props are mostly derived from react-vis & K2. All external props are linked. You can click highlighted props to get more details from official sites.
Property | Type | Required | Default value | Description |
---|---|---|---|---|
data | ColumnChartData[] | yes | Data for the chart. | |
xyPlot | XYPlotProps | no | None | Customize XYPlot. Inherited from "react-vis". |
xAxis | boolean | XAxisProps | no | true | Enable or customize XAxis. Inherited from "react-vis". |
yAxis | boolean | YAxisProps | no | true | Enable or customize YAxis. Inherited from "react-vis". |
verticalGridLines | boolean | VerticalGridLinesProps | no | false | Enable or customize VerticalGridLines. Inherited from "react-vis". |
horizontalGridLines | boolean | HorizontalGridLinesProps | no | false | Enable or customize HorizontalGridLines. Inherited from "react-vis". |
barWidth | number | no | 0.3 | Inherited from "react-vis" BarSeries |
title | string | JSX.Element | no | None | Title of the chart. |
animate | boolean | no | true | Enable the animation. |
colors | {[theme-name: e.g "light" or "dark"] : string[] | GradientColor[] | no | { dark: ["#5579ae", "#e5c238", "#CF7373", "#85BE50"], light: ["#5579ae", "#e5c238", "#CF7373", "#85BE50"], } | Colors of visual in different theme modes |
label | boolean | LabelComponent | no | true | Enable or customize the labels(Note: Labels appear only in case of single series). |
tooltip | boolean | TooltipProps | no | true | Enable or customize the tooltip. |
legends | boolean | LegendsProps | no | true | Enable or customize the legends. |
onClick | onClick?: (event: { data: VerticalBarSeriesPoint }) => void; | no | None | Callback for column click. |
style | CSSProperties | no | None | Styles applied to the root element of chart. |
className | string | no | None | Class applied to the root element of chart. |
classes | Classes | no | None | Classes of chart. |
ColumnChart is wrapped with fetchData HoC, to perform data handling tasks, which adds support for some additional props.
Custom Types
ColumnChartData
Here is the format of the data accepted by ColumnChart.
VerticalBarSeriesProps and VerticalBarSeriesPoint are derived from react-vis
LabelComponent
This is a type of custom label component. You can create a custom label component by this.
VerticalBarSeriesPoint is derived from react-vis
GradientColor
Type of GradientColor object.
Classes
Classes enable customization and styling of chart elements through their classes.
ClassName | Type | Required | Default value | Description |
---|---|---|---|---|
root | string | no | None | Applied to root element of chart. |
header | string | no | None | Applied to header of chart. |
title | string | no | None | Applied to title of chart. |
legends | string | no | None | Applied to legends of chart. |
tooltip | string | no | None | Applied to tooltip of chart. |
chart | string | no | None | Applied to svg component of chart. |
barSeries | string | no | None | Applied to bar series of chart. |
xAxis | string | no | None | Applied to x axis of chart. |
yAxis | string | no | None | Applied to y axis of chart. |
label | string | no | None | Applied to labels of chart. |
Please see Class Specificity for correctly defining it.