Area Chart

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

The AreaChart component is a powerful addition to the Vue charts library, visualizing time series or categorical data as filled line charts. Examples ↗

Basic Usage

Basic Single Line

Basic Area Chart

Area Chart

Step Area Chart

Stacked Area Chart

To create stacked area charts, simply include multiple data series in your categories and set the stacked prop to true. This approach makes it easy to visualize cumulative data trends in Vue and Nuxt applications:

Props

PropTypeDefaultDescription
dataT[]RequiredArray of data points for the chart. Each element represents a data point.
heightnumberRequiredHeight of the chart in pixels.
xLabelstringundefinedOptional label for the x-axis.
yLabelstringundefinedOptional label for the y-axis.
padding{ top: number; right: number; bottom: number; left: number; }undefinedOptional padding for the chart (top, right, bottom, left).
categoriesRecord<string, BulletLegendItemInterface>RequiredSeries configuration: name and color for each data key.
markerConfigRecord<string, MarkerConfig>{}Marker configuration for each series.
xFormatteraxisFormatterundefinedFormats X-axis labels. (tick, i, ticks) => string where tick can be a number or Date.
yFormatteraxisFormatterundefinedFormats Y-axis labels. (tick, i, ticks) => string where tick can be a number or Date.
curveTypeCurveTypeundefinedType of curve interpolation (see Curve Types section).
hideAreabooleanfalseIf true, hides the area fill and shows only the line.
stackedbooleanfalseIf true, the area chart will be stacked.
gradientStopsArray<{ offset: string; stopOpacity: number }>undefinedCustom gradient stops for the area fill.
lineWidthnumber2Width of the line in pixels.
lineDashArraynumber[][]undefinedSVG stroke-dasharray for dashed lines.
xNumTicksnumberundefinedDesired number of ticks on the x-axis.
xExplicitTicks`(numberstringDate)`
minMaxTicksOnlybooleanfalseIf true, only show first and last ticks on the x-axis.
yNumTicksnumberundefinedDesired number of ticks on the y-axis.
hideLegendbooleanfalseIf true, hides the chart legend.
hideTooltipbooleanfalseIf true, hides the chart tooltip.
legendPositionLegendPositionundefinedPosition of the legend (see LegendPosition).
legendStylestring | Record<string, string>undefinedCustom CSS style for the legend container.
xDomainLinebooleanfalseShow domain (axis) line on the x-axis.
yDomainLinebooleanfalseShow domain (axis) line on the y-axis.
xTickLinebooleanfalseShow tick lines on the x-axis.
yTickLinebooleanfalseShow tick lines on the y-axis.
xGridLinebooleanfalseShow grid lines on the x-axis.
yGridLinebooleanfalseShow grid lines on the y-axis.
hideXAxisbooleanfalseIf true, hides the x-axis.
hideYAxisbooleanfalseIf true, hides the y-axis.
crosshairConfigCrosshairConfigundefinedCrosshair configuration for customizing the crosshair line.
xAxisConfigAxisConfigundefinedAxis configuration for customizing the appearance of the x-axis.
yAxisConfigAxisConfigundefinedAxis configuration for customizing the appearance of the y-axis.
yDomain[number | undefined, number | undefined]undefinedDomain for the y-axis.
xDomain[number | undefined, number | undefined]undefinedDomain for the x-axis.
yExplicitTicks(number | string | Date)[]undefinedForce specific ticks on the y-axis.
xMinMaxTicksOnlybooleanfalseIf true, only show first and last ticks on the x-axis.
yMinMaxTicksOnlybooleanfalseIf true, only show first and last ticks on the y-axis.
minMaxTicksOnlyShowGridLinesbooleanfalseShow grid lines for min and max axis ticks.
xMinMaxTicksOnlyShowGridLinesbooleanfalseShow grid lines for min and max x-axis ticks.
yMinMaxTicksOnlyShowGridLinesbooleanfalseShow grid lines for min and max y-axis ticks.
tooltipTitleFormatter(data: T) => string | numberundefinedCustom formatter for tooltip titles.
tooltipTooltipConfigundefinedTooltip configuration (hideDelay, showDelay, followCursor).
durationnumberundefinedAnimation duration in milliseconds.
stackedbooleanfalseIf true, creates a stacked area chart where areas stack on top of each other.

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)

Examples

Check out examples here ↗