AdminKitDocs
Charts

React Column Chart

A React column chart with ApexCharts in AdminKit PRO: vertical bars that compare three series per month, with a formatted tooltip and theme colors.

Pro

This component is only available in AdminKit PRO. Learn more.

Use a column chart to compare values across categories, such as months. Each value is a vertical bar, and several series stand side by side: this example shows three per month.

In AdminKit for React you draw it with ApexChart, the ApexCharts component from Chart setup. For ApexCharts, a column chart is a bar chart with vertical bars.

Example

import { ApexChart } from "@/components/plugins/apexcharts";

export function FinanceColumnChart() {
  return (
    <div className="position-relative" style={{ minHeight: 365 }}>
      <ApexChart
        options={() => ({
          chart: { height: 350, type: "bar" },
          plotOptions: {
            bar: { horizontal: false, borderRadius: 4, columnWidth: "55%" },
          },
          dataLabels: { enabled: false },
          stroke: { show: true, width: 2, colors: ["transparent"] },
          series: [
            { name: "Net Profit", data: [44, 55, 57, 56, 61, 58, 63, 60, 66] },
            { name: "Revenue", data: [76, 85, 101, 98, 87, 105, 91, 114, 94] },
            { name: "Free Cash Flow", data: [35, 41, 36, 26, 45, 48, 52, 53, 41] },
          ],
          xaxis: {
            categories: ["Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct"],
          },
          yaxis: { title: { text: "$ (thousands)" } },
          fill: { opacity: 1 },
          tooltip: {
            y: { formatter: (val: number) => "$ " + val + " thousands" },
          },
        })}
      />
    </div>
  );
}

The transparent 2px stroke leaves a gap between the columns of a month. The three series take the primary, success and warning colors of the wrapper.

Props

PropTypeDefaultDescription
options(theme: Theme) => ApexOptionsThe ApexCharts options, with series and chart.type. Called again with the new colors when the color mode changes

Options

OptionEffect
plotOptions.bar.columnWidthWidth of a group of columns, as a percentage of the space per category
plotOptions.bar.borderRadiusRounds the end of each column, in pixels
plotOptions.bar.horizontaltrue draws horizontal bars
chart.stackedtrue stacks the series in one column per category
tooltip.y.formatterFormats the value in the tooltip. yaxis.labels.formatter does the same for the axis

The pipeline chart of the CRM dashboard is the horizontal variant. Here it has fixed values: one series in the primary color, and the grid in the border color of the current mode:

<ApexChart
  options={(theme) => ({
    chart: { type: "bar", height: 300, toolbar: { show: false } },
    colors: [theme.primary],
    series: [{ name: "Value", data: [120, 84, 61, 42, 37] }],
    plotOptions: {
      bar: { horizontal: true, borderRadius: 4, barHeight: "60%" },
    },
    dataLabels: { enabled: false },
    grid: { borderColor: theme["border-color"] },
    xaxis: { categories: ["Lead", "Qualified", "Proposal", "Negotiation", "Won"] },
  })}
/>

Accessibility

  • The y-axis title says the unit ("$ (thousands)"), so the values make sense without the tooltip.
  • The legend names the three series, so the colors are not the only key.
  • Exact values show in the tooltip on hover only. Where they matter, give them in a table too.
  • ApexChart passes other props to its <div>: role="figure" with an aria-label names the chart.

Last updated on

On this page