Line Chart

Create single and multiple line visualizations in your Nuxt application.

The LineChart component provides a flexible and customizable way to visualize data trends over time or continuous values, supporting single and multiple line series with various curve interpolations.

Basic Usage

Line Chart

Multiple Lines

Line Chart

Single Line

Line Chart

Dash Array

Line Chart

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).
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.
xAxisConfigAxisConfigundefinedAxis configuration for customizing the appearance of the x-axis.
yAxisConfigAxisConfigundefinedAxis configuration for customizing the appearance of the y-axis.
crosshairConfigCrosshairConfigundefinedCrosshair configuration for customizing the crosshair line.
yDomain[number | undefined, number | undefined]undefinedDomain for the y-axis.
xDomain[number | undefined, number | undefined]undefinedDomain for the x-axis.

Data Format

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

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

Categories Format

Categories define the visual appearance and metadata for each line:

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

interface LineCategories {
  [key: string]: LineCategory
}

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)