Bar Chart

Implement vertical, horizontal, grouped, and stacked bar charts in your Nuxt application.

Basic Usage

Stacked Horizontal Bar Chart

Grouped Bar Chart

Stacked Bar Chart

Props

PropTypeDefaultDescription
dataBarChartData[][]Array of data points for the chart.
categoriesRecord<string, BarCategory>{}Series configuration: name and color for each data key.
heightnumber300Height of the chart in pixels.
y-axisstring[][]Array of keys to display on Y-axis.
x-formatter(tick: number, i?: number, ticks?: number[]) => string-Formats X-axis labels.
y-formatter(tick: number, i?: number, ticks?: number[]) => string-Formats Y-axis labels.
x-labelstring-Label for the X-axis.
y-labelstring-Label for the Y-axis.
x-num-ticksnumber5Number of ticks on X-axis.
y-num-ticksnumber5Number of ticks on Y-axis.
radiusnumber0Border radius for bars.
y-grid-linebooleanfalseShow horizontal grid lines.
x-grid-linebooleanfalseShow vertical grid lines.
legend-positionLegendPosition'none'Position of the legend.
hide-legendbooleantrueHide the chart legend.
show-tooltipbooleantrueShow tooltip on hover.
tooltip-formatter(data: BarChartData, key: string) => string-Custom formatter for tooltip content.
bar-direction`'vertical''horizontal'`'vertical'
groupedbooleanfalseDisplay grouped bars.
stackedbooleanfalseDisplay stacked bars.

Data Format

The data should be an array of objects where each object represents a data point:

types.ts
interface ChartData {
  [key: string]: string | number
}

Categories Format

Categories define the visual appearance and metadata for each data series:

types.ts
interface Category {
  name: string
  color: string
}

interface Categories {
  [key: string]: Category
}