Bar Chart

A bar chart component is a visual representation using rectangular bars to compare quantities across different categories or time periods.

Props

BarChart

PropTypeDefaultDescription
datarequiredRecord<string, string | number>[]The data to be displayed in the chart.
allowDecimalsbooleanShow decimals on the y-axis.
animationDurationnumberAnimation duration in milliseconds.
barCategoryGapstring | numberGap between categories in pixels or percentage.
barGapstring | numberGap between bars in pixels or percentage.
categoriesstring[]The data keys to be displayed in the chart.
childrenstring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...>Children to render.
colorsstring[]The colors to use for each category.
heightResponsiveValue<number | "px" | (string & {}) | "max" | "min" | "auto" | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "-moz-max-content" | "-moz-min-content" | ... 56 more ... | "container.2xl">The height of the chart.
indexstring'date'The y-axis data key to use.
intervalTypetype ONLY_FOR_FORMAT = | number | "preserveStartEnd" | "equidistantPreserveStart" | "preserveStart" | "preserveEnd"If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically.
legendHeightnumberHeight of the legend.
radiusnumber | [number, number, number, number]Radius of the bars.
showAnimationbooleanWether to show the animation or not.
showGridbooleanWether to show the grid or not.
showLegendbooleanWether to show the legend or not.
showTooltipbooleanWether to show the tooltip or not.
showXAxisbooleanWether to show the x-axis or not.
showYAxisbooleanWether to show the y-axis or not.
stackbooleanWhether to stack the bars.
startEndOnlybooleanOnly show the start and end ticks on the x-axis.
tooltipContent(props: TooltipProps<any, any>) => ReactNodeRender custom tooltip content.
valueFormatter(value: number) => stringFormat the value of the x-axis.
variant"solid" | "gradient"gradientThe bar chart variant.
yAxisWidthnumberWidth of the y-axis labels.

Was this helpful?