Line Chart

Create single and multiple line visualizations in your Nuxt application.

Basic Usage

Multiple Lines

Single Line

Dash Array

Props

PropTypeDefaultDescription
dataLineChartData[][]Array of data points for the chart.
categoriesRecord<string, LineCategory>{}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.
stroke-widthnumber2Width of the line stroke.
stroke-dasharraystring-Dash pattern for the line.
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: LineChartData, 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 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)