Formatting values
Values of 1000 or more print as 1.2k by default. valueFormatter replaces that on the axis and in the tooltip, and a point's label, when it has one, is shown in the tooltip instead of its value.
vue
<template>
<NbLineChart :series="series" :value-formatter="formatUsers" />
</template>
<script setup lang="ts">
const users = new Intl.NumberFormat('en-GB')
const formatUsers = (value: number) => `${users.format(value)} users`
</script>Props
| Prop | Type | Default | Description |
|---|---|---|---|
series | IChartSeries[] | [] | One or more named series of { x, y } data points |
title | string | - | Chart title |
subtitle | string | - | Secondary descriptive line |
height | number | string | 280 | Container height |
area | boolean | false | Render filled area under each line |
points | boolean | false | Render a circle at each data point |
curve | 'linear' | 'smooth' | 'step' | 'smooth' | Path interpolation |
showLegend | boolean | true | Render a legend below the chart |
showTooltip | boolean | true | Show hover tooltip with vertical guide |
showGrid | boolean | true | Render Y-axis gridlines |
colors | string[] | default palette | Per-series colors |
valueFormatter | (value: number) => string | 1.2k shorthand | Formats axis ticks and tooltip values |
animate | boolean | false | Draw the lines in on first render and on data change |
Entrance animation
animate draws each line in from the left when the chart first renders and again when its data changes. An area fill and the points fade in once the line is under way. It is off by default and is switched off entirely under prefers-reduced-motion: reduce.
vue
<NbLineChart animate :series="series" />Notes
- The X dimension is treated as ordinal, points are spaced evenly along the X axis, regardless of the underlying value. Use the order of
datato control point sequence. - All series should share the same X-value sequence (the first series defines the X-axis labels).
- For cumulative / area mode, ensure your data is sorted ascending on X.