Area Chart

Learn how to implement and customize Area Charts in your Nuxt application.

Basic Usage

Basic Single Line

Basic Area Chart

Step Area Chart

Props

PropTypeDefaultDescription
dataAreaChartData[][]Array of data points for the chart.
categoriesRecord<string, AreaCategory>{}Series configuration: name and color for each data key.
heightnumber300Height of the chart in pixels.
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.
curve-typeCurveType'linear'Type of curve interpolation.
fill-opacitynumber0.3Opacity of the area fill.
legend-positionLegendPosition'none'Position of the legend.
hide-legendbooleantrueHide the chart legend.
marker-configRecord<string, MarkerConfig>{}Marker configuration for each series.
show-tooltipbooleantrueShow tooltip on hover.
tooltip-formatter(data: AreaChartData, key: string) => string-Custom formatter for tooltip content.

Data Format

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

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

Categories Format

Categories define the visual appearance and metadata for each area:

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

interface AreaCategories {
  [key: string]: AreaCategory
}

Curve Types

Available curve types for area interpolation:

  • linear - Straight lines between points
  • linearClosed - Closed straight lines
  • basis - B-spline curves
  • basisClosed - Closed B-spline curves
  • basisOpen - Open B-spline curves
  • bundle - Bundle spline curves
  • cardinal - Cardinal spline curves
  • cardinalClosed - Closed cardinal spline curves
  • cardinalOpen - Open cardinal spline curves
  • catmullRom - Catmull-Rom spline curves
  • catmullRomClosed - Closed Catmull-Rom spline curves
  • catmullRomOpen - Open Catmull-Rom spline curves
  • monotoneX - Monotone cubic interpolation (X axis)
  • monotoneY - Monotone cubic interpolation (Y axis)
  • natural - Natural cubic spline
  • step - Step function
  • stepBefore - Step function (step before)
  • stepAfter - Step function (step after)

Stacked Areas

To create stacked area charts, simply include multiple data series in your categories:

stacked-area.vue
<script setup lang="ts">
const data = [
  { month: 'Jan', desktop: 100, mobile: 80, tablet: 40 },
  { month: 'Feb', desktop: 120, mobile: 90, tablet: 50 },
  { month: 'Mar', desktop: 180, mobile: 110, tablet: 60 },
]

const categories = {
  desktop: { name: 'Desktop', color: '#3b82f6' },
  mobile: { name: 'Mobile', color: '#10b981' },
  tablet: { name: 'Tablet', color: '#f59e0b' },
}
</script>

<template>
  <AreaChart
    :data="data"
    :categories="categories"
    :height="300"
  />
  
</template>