Area
AlphaAn area chart visually represents data over time, displaying trends and patterns through filled-in areas under a line graph.
Installation
Run the following command
pnpm dlx shadcn-vue@latest add chart-area
Setup
Follow the guide to complete the setup.
API
Prop
data
Record<string, any>[]Required*The source data, in which each entry is a dictionary.
categories
string[]Required*Select the categories from your data. Used to populate the legend and tooltip.
index
stringRequired*Sets the key to map the data to the axis.
colors
string[]Change the default colors.
margin
SpacingMargin of each the container
filterOpacity
numberChange the opacity of the non-selected field
xFormatter
((tick: number | Date, i: number, ticks: number[] | Date[]) => string)Function to format X label
yFormatter
((tick: number | Date, i: number, ticks: number[] | Date[]) => string)Function to format Y label
showXAxis
booleanControls the visibility of the X axis.
showYAxis
booleanControls the visibility of the Y axis.
showTooltip
booleanControls the visibility of tooltip.
showLegend
booleanControls the visibility of legend.
showGridLine
booleanControls the visibility of gridline.
customTooltip
ComponentRender custom tooltip component.
curveType
CurveTypeType of curve
showGradient
booleanControls the visibility of gradient.
Emit
legendItemClick
[d: BulletLegendItemInterface, i: number]Example
Sparkline
We can turn the chart into sparkline chart by hiding axis, gridline and legends.
Custom Tooltip
If you want to render custom tooltip, you can easily pass in a custom component. Refer to prop definition here.