Area Charts
Area chart examples: stacked, expanded, gradient, step and more.
Each example is an iv-card with a chart inside. Copy the code under it. See Chart for the parts and the API.
import { IV_CHART_IMPORTS } from '@inlaylab/ivorie/chart';Interactive
Mobile
Desktop
import { ChangeDetectionStrategy, Component, computed, signal } from '@angular/core';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
import { IV_SELECT_IMPORTS } from '@inlaylab/ivorie/select';
const DAYS: Record<string, number> = { '90d': 90, '30d': 30, '7d': 7 };
@Component({
selector: 'demo-chart-area-interactive',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, IV_SELECT_IMPORTS],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full pt-0">
<iv-card-header class="flex items-center gap-2 space-y-0 border-b py-5 sm:flex-row">
<div class="grid flex-1 gap-1">
<iv-card-title>Area Chart - Interactive</iv-card-title>
<iv-card-description>Showing total visitors for the last 3 months</iv-card-description>
</div>
<iv-select [(value)]="timeRange" placeholder="Last 3 months">
<iv-select-trigger
class="hidden w-[160px] rounded-lg sm:ml-auto sm:flex"
aria-label="Select a value"
/>
<iv-select-content class="rounded-xl">
<iv-select-item value="90d" class="rounded-lg">Last 3 months</iv-select-item>
<iv-select-item value="30d" class="rounded-lg">Last 30 days</iv-select-item>
<iv-select-item value="7d" class="rounded-lg">Last 7 days</iv-select-item>
</iv-select-content>
</iv-select>
</iv-card-header>
<iv-card-content class="px-2 pt-4 sm:px-6 sm:pt-6">
<iv-chart [config]="config" class="aspect-auto h-[250px] w-full">
<svg ivAreaChart [data]="filtered()">
<defs>
<linearGradient id="interactive-fill-desktop" x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stop-color="var(--color-desktop)" stop-opacity="0.8" />
<stop offset="95%" stop-color="var(--color-desktop)" stop-opacity="0.1" />
</linearGradient>
<linearGradient id="interactive-fill-mobile" x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stop-color="var(--color-mobile)" stop-opacity="0.8" />
<stop offset="95%" stop-color="var(--color-mobile)" stop-opacity="0.1" />
</linearGradient>
</defs>
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="date"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[minTickGap]="32"
[tickFormatter]="day"
/>
<g
ivArea
dataKey="mobile"
curve="natural"
fill="url(#interactive-fill-mobile)"
stackId="a"
/>
<g
ivArea
dataKey="desktop"
curve="natural"
fill="url(#interactive-fill-desktop)"
stackId="a"
/>
</svg>
<iv-chart-tooltip [cursor]="false" [labelFormatter]="day" indicator="dot" />
<iv-chart-legend />
</iv-chart>
</iv-card-content>
</iv-card>
`,
})
export default class ChartAreaInteractive {
protected readonly data = [
{ date: '2024-04-01', desktop: 222, mobile: 150 },
{ date: '2024-04-02', desktop: 97, mobile: 180 },
{ date: '2024-04-03', desktop: 167, mobile: 120 },
{ date: '2024-04-04', desktop: 242, mobile: 260 },
{ date: '2024-04-05', desktop: 373, mobile: 290 },
{ date: '2024-04-06', desktop: 301, mobile: 340 },
{ date: '2024-04-07', desktop: 245, mobile: 180 },
{ date: '2024-04-08', desktop: 409, mobile: 320 },
{ date: '2024-04-09', desktop: 59, mobile: 110 },
{ date: '2024-04-10', desktop: 261, mobile: 190 },
{ date: '2024-04-11', desktop: 327, mobile: 350 },
{ date: '2024-04-12', desktop: 292, mobile: 210 },
{ date: '2024-04-13', desktop: 342, mobile: 380 },
{ date: '2024-04-14', desktop: 137, mobile: 220 },
{ date: '2024-04-15', desktop: 120, mobile: 170 },
{ date: '2024-04-16', desktop: 138, mobile: 190 },
{ date: '2024-04-17', desktop: 446, mobile: 360 },
{ date: '2024-04-18', desktop: 364, mobile: 410 },
{ date: '2024-04-19', desktop: 243, mobile: 180 },
{ date: '2024-04-20', desktop: 89, mobile: 150 },
{ date: '2024-04-21', desktop: 137, mobile: 200 },
{ date: '2024-04-22', desktop: 224, mobile: 170 },
{ date: '2024-04-23', desktop: 138, mobile: 230 },
{ date: '2024-04-24', desktop: 387, mobile: 290 },
{ date: '2024-04-25', desktop: 215, mobile: 250 },
{ date: '2024-04-26', desktop: 75, mobile: 130 },
{ date: '2024-04-27', desktop: 383, mobile: 420 },
{ date: '2024-04-28', desktop: 122, mobile: 180 },
{ date: '2024-04-29', desktop: 315, mobile: 240 },
{ date: '2024-04-30', desktop: 454, mobile: 380 },
{ date: '2024-05-01', desktop: 165, mobile: 220 },
{ date: '2024-05-02', desktop: 293, mobile: 310 },
{ date: '2024-05-03', desktop: 247, mobile: 190 },
{ date: '2024-05-04', desktop: 385, mobile: 420 },
{ date: '2024-05-05', desktop: 481, mobile: 390 },
{ date: '2024-05-06', desktop: 498, mobile: 520 },
{ date: '2024-05-07', desktop: 388, mobile: 300 },
{ date: '2024-05-08', desktop: 149, mobile: 210 },
{ date: '2024-05-09', desktop: 227, mobile: 180 },
{ date: '2024-05-10', desktop: 293, mobile: 330 },
{ date: '2024-05-11', desktop: 335, mobile: 270 },
{ date: '2024-05-12', desktop: 197, mobile: 240 },
{ date: '2024-05-13', desktop: 197, mobile: 160 },
{ date: '2024-05-14', desktop: 448, mobile: 490 },
{ date: '2024-05-15', desktop: 473, mobile: 380 },
{ date: '2024-05-16', desktop: 338, mobile: 400 },
{ date: '2024-05-17', desktop: 499, mobile: 420 },
{ date: '2024-05-18', desktop: 315, mobile: 350 },
{ date: '2024-05-19', desktop: 235, mobile: 180 },
{ date: '2024-05-20', desktop: 177, mobile: 230 },
{ date: '2024-05-21', desktop: 82, mobile: 140 },
{ date: '2024-05-22', desktop: 81, mobile: 120 },
{ date: '2024-05-23', desktop: 252, mobile: 290 },
{ date: '2024-05-24', desktop: 294, mobile: 220 },
{ date: '2024-05-25', desktop: 201, mobile: 250 },
{ date: '2024-05-26', desktop: 213, mobile: 170 },
{ date: '2024-05-27', desktop: 420, mobile: 460 },
{ date: '2024-05-28', desktop: 233, mobile: 190 },
{ date: '2024-05-29', desktop: 78, mobile: 130 },
{ date: '2024-05-30', desktop: 340, mobile: 280 },
{ date: '2024-05-31', desktop: 178, mobile: 230 },
{ date: '2024-06-01', desktop: 178, mobile: 200 },
{ date: '2024-06-02', desktop: 470, mobile: 410 },
{ date: '2024-06-03', desktop: 103, mobile: 160 },
{ date: '2024-06-04', desktop: 439, mobile: 380 },
{ date: '2024-06-05', desktop: 88, mobile: 140 },
{ date: '2024-06-06', desktop: 294, mobile: 250 },
{ date: '2024-06-07', desktop: 323, mobile: 370 },
{ date: '2024-06-08', desktop: 385, mobile: 320 },
{ date: '2024-06-09', desktop: 438, mobile: 480 },
{ date: '2024-06-10', desktop: 155, mobile: 200 },
{ date: '2024-06-11', desktop: 92, mobile: 150 },
{ date: '2024-06-12', desktop: 492, mobile: 420 },
{ date: '2024-06-13', desktop: 81, mobile: 130 },
{ date: '2024-06-14', desktop: 426, mobile: 380 },
{ date: '2024-06-15', desktop: 307, mobile: 350 },
{ date: '2024-06-16', desktop: 371, mobile: 310 },
{ date: '2024-06-17', desktop: 475, mobile: 520 },
{ date: '2024-06-18', desktop: 107, mobile: 170 },
{ date: '2024-06-19', desktop: 341, mobile: 290 },
{ date: '2024-06-20', desktop: 408, mobile: 450 },
{ date: '2024-06-21', desktop: 169, mobile: 210 },
{ date: '2024-06-22', desktop: 317, mobile: 270 },
{ date: '2024-06-23', desktop: 480, mobile: 530 },
{ date: '2024-06-24', desktop: 132, mobile: 180 },
{ date: '2024-06-25', desktop: 141, mobile: 190 },
{ date: '2024-06-26', desktop: 434, mobile: 380 },
{ date: '2024-06-27', desktop: 448, mobile: 490 },
{ date: '2024-06-28', desktop: 149, mobile: 200 },
{ date: '2024-06-29', desktop: 103, mobile: 160 },
{ date: '2024-06-30', desktop: 446, mobile: 400 },
];
protected readonly config: IvChartConfig = {
visitors: { label: 'Visitors' },
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
mobile: { label: 'Mobile', color: 'var(--chart-2)' },
};
protected readonly timeRange = signal<string | null>('90d');
/** The last 90, 30 or 7 days up to 2024-06-30. */
protected readonly filtered = computed(() => {
const start = new Date('2024-06-30');
start.setUTCDate(start.getUTCDate() - (DAYS[this.timeRange() ?? '90d'] ?? 90));
return this.data.filter((item) => new Date(item.date) >= start);
});
/** Dates are UTC days: format them in UTC, so server and browser agree. */
protected readonly day = (value: string) =>
new Date(value).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
timeZone: 'UTC',
});
}
Default
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
@Component({
selector: 'demo-chart-area-default',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg ivAreaChart [data]="data" [margin]="{ left: 12, right: 12 }">
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<g ivArea dataKey="desktop" curve="natural" [fillOpacity]="0.4" />
</svg>
<iv-chart-tooltip [cursor]="false" indicator="line" />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaDefault {
protected readonly data = [
{ month: 'January', desktop: 186 },
{ month: 'February', desktop: 305 },
{ month: 'March', desktop: 237 },
{ month: 'April', desktop: 73 },
{ month: 'May', desktop: 209 },
{ month: 'June', desktop: 214 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}
Linear
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
@Component({
selector: 'demo-chart-area-linear',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart - Linear</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg ivAreaChart [data]="data" [margin]="{ left: 12, right: 12 }">
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<g ivArea dataKey="desktop" curve="linear" [fillOpacity]="0.4" />
</svg>
<iv-chart-tooltip [cursor]="false" indicator="dot" hideLabel />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaLinear {
protected readonly data = [
{ month: 'January', desktop: 186 },
{ month: 'February', desktop: 305 },
{ month: 'March', desktop: 237 },
{ month: 'April', desktop: 73 },
{ month: 'May', desktop: 209 },
{ month: 'June', desktop: 214 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}
Step
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideActivity, lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
/** A config icon: any component. This one wraps an ng-icon. */
@Component({
selector: 'demo-activity-icon',
imports: [NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'flex text-muted-foreground' },
template: `<ng-icon [svg]="icon" />`,
})
class ActivityIcon {
protected readonly icon = lucideActivity;
}
@Component({
selector: 'demo-chart-area-step',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart - Step</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg ivAreaChart [data]="data" [margin]="{ left: 12, right: 12 }">
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<g ivArea dataKey="desktop" curve="step" [fillOpacity]="0.4" />
</svg>
<iv-chart-tooltip [cursor]="false" hideLabel />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaStep {
protected readonly data = [
{ month: 'January', desktop: 186 },
{ month: 'February', desktop: 305 },
{ month: 'March', desktop: 237 },
{ month: 'April', desktop: 73 },
{ month: 'May', desktop: 209 },
{ month: 'June', desktop: 214 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)', icon: ActivityIcon },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}
Legend
Mobile
Desktop
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
@Component({
selector: 'demo-chart-area-legend',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart - Legend</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg ivAreaChart [data]="data" [margin]="{ left: 12, right: 12 }">
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<g ivArea dataKey="mobile" curve="natural" [fillOpacity]="0.4" stackId="a" />
<g ivArea dataKey="desktop" curve="natural" [fillOpacity]="0.4" stackId="a" />
</svg>
<iv-chart-tooltip [cursor]="false" indicator="line" />
<iv-chart-legend />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaLegend {
protected readonly data = [
{ month: 'January', desktop: 186, mobile: 80 },
{ month: 'February', desktop: 305, mobile: 200 },
{ month: 'March', desktop: 237, mobile: 120 },
{ month: 'April', desktop: 73, mobile: 190 },
{ month: 'May', desktop: 209, mobile: 130 },
{ month: 'June', desktop: 214, mobile: 140 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
mobile: { label: 'Mobile', color: 'var(--chart-2)' },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}
Stacked
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
@Component({
selector: 'demo-chart-area-stacked',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart - Stacked</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg ivAreaChart [data]="data" [margin]="{ left: 12, right: 12 }">
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<g ivArea dataKey="mobile" curve="natural" [fillOpacity]="0.4" stackId="a" />
<g ivArea dataKey="desktop" curve="natural" [fillOpacity]="0.4" stackId="a" />
</svg>
<iv-chart-tooltip [cursor]="false" indicator="dot" />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaStacked {
protected readonly data = [
{ month: 'January', desktop: 186, mobile: 80 },
{ month: 'February', desktop: 305, mobile: 200 },
{ month: 'March', desktop: 237, mobile: 120 },
{ month: 'April', desktop: 73, mobile: 190 },
{ month: 'May', desktop: 209, mobile: 130 },
{ month: 'June', desktop: 214, mobile: 140 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
mobile: { label: 'Mobile', color: 'var(--chart-2)' },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}
Stacked Expanded
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
@Component({
selector: 'demo-chart-area-stacked-expand',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart - Stacked Expanded</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg
ivAreaChart
[data]="data"
[margin]="{ left: 12, right: 12, top: 12 }"
stackOffset="expand"
>
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<g ivArea dataKey="other" curve="natural" [fillOpacity]="0.1" stackId="a" />
<g ivArea dataKey="mobile" curve="natural" [fillOpacity]="0.4" stackId="a" />
<g ivArea dataKey="desktop" curve="natural" [fillOpacity]="0.4" stackId="a" />
</svg>
<iv-chart-tooltip [cursor]="false" indicator="line" />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaStackedExpand {
protected readonly data = [
{ month: 'January', desktop: 186, mobile: 80, other: 45 },
{ month: 'February', desktop: 305, mobile: 200, other: 100 },
{ month: 'March', desktop: 237, mobile: 120, other: 150 },
{ month: 'April', desktop: 73, mobile: 190, other: 50 },
{ month: 'May', desktop: 209, mobile: 130, other: 100 },
{ month: 'June', desktop: 214, mobile: 140, other: 160 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
mobile: { label: 'Mobile', color: 'var(--chart-2)' },
other: { label: 'Other', color: 'var(--chart-3)' },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}
Icons
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideTrendingDown, lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
/** Config icons: any component. These wrap an ng-icon. */
@Component({
selector: 'demo-trending-down-icon',
imports: [NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'flex text-muted-foreground' },
template: `<ng-icon [svg]="icon" />`,
})
class TrendingDownIcon {
protected readonly icon = lucideTrendingDown;
}
@Component({
selector: 'demo-trending-up-icon',
imports: [NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'flex text-muted-foreground' },
template: `<ng-icon [svg]="icon" />`,
})
class TrendingUpIcon {
protected readonly icon = lucideTrendingUp;
}
@Component({
selector: 'demo-chart-area-icons',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart - Icons</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg ivAreaChart [data]="data" [margin]="{ left: 12, right: 12 }">
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<g ivArea dataKey="mobile" curve="natural" [fillOpacity]="0.4" stackId="a" />
<g ivArea dataKey="desktop" curve="natural" [fillOpacity]="0.4" stackId="a" />
</svg>
<iv-chart-tooltip [cursor]="false" indicator="line" />
<iv-chart-legend />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaIcons {
protected readonly data = [
{ month: 'January', desktop: 186, mobile: 80 },
{ month: 'February', desktop: 305, mobile: 200 },
{ month: 'March', desktop: 237, mobile: 120 },
{ month: 'April', desktop: 73, mobile: 190 },
{ month: 'May', desktop: 209, mobile: 130 },
{ month: 'June', desktop: 214, mobile: 140 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)', icon: TrendingDownIcon },
mobile: { label: 'Mobile', color: 'var(--chart-2)', icon: TrendingUpIcon },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}
Gradient
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
@Component({
selector: 'demo-chart-area-gradient',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart - Gradient</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg ivAreaChart [data]="data" [margin]="{ left: 12, right: 12 }">
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<defs>
<linearGradient id="gradient-fill-desktop" x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stop-color="var(--color-desktop)" stop-opacity="0.8" />
<stop offset="95%" stop-color="var(--color-desktop)" stop-opacity="0.1" />
</linearGradient>
<linearGradient id="gradient-fill-mobile" x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stop-color="var(--color-mobile)" stop-opacity="0.8" />
<stop offset="95%" stop-color="var(--color-mobile)" stop-opacity="0.1" />
</linearGradient>
</defs>
<g
ivArea
dataKey="mobile"
curve="natural"
[fillOpacity]="0.4"
fill="url(#gradient-fill-mobile)"
stackId="a"
/>
<g
ivArea
dataKey="desktop"
curve="natural"
[fillOpacity]="0.4"
fill="url(#gradient-fill-desktop)"
stackId="a"
/>
</svg>
<iv-chart-tooltip [cursor]="false" />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaGradient {
protected readonly data = [
{ month: 'January', desktop: 186, mobile: 80 },
{ month: 'February', desktop: 305, mobile: 200 },
{ month: 'March', desktop: 237, mobile: 120 },
{ month: 'April', desktop: 73, mobile: 190 },
{ month: 'May', desktop: 209, mobile: 130 },
{ month: 'June', desktop: 214, mobile: 140 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
mobile: { label: 'Mobile', color: 'var(--chart-2)' },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}
Axes
Trending up by 5.2% this month
January - June 2024
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon } from '@ng-icons/core';
import { lucideTrendingUp } from '@ng-icons/lucide';
import { IV_CARD_IMPORTS } from '@inlaylab/ivorie/card';
import { IV_CHART_IMPORTS, IvChartConfig } from '@inlaylab/ivorie/chart';
@Component({
selector: 'demo-chart-area-axes',
imports: [IV_CARD_IMPORTS, IV_CHART_IMPORTS, NgIcon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<iv-card class="w-full max-w-md">
<iv-card-header>
<iv-card-title>Area Chart - Axes</iv-card-title>
<iv-card-description>Showing total visitors for the last 6 months</iv-card-description>
</iv-card-header>
<iv-card-content>
<iv-chart [config]="config">
<svg ivAreaChart [data]="data" [margin]="{ left: -20, right: 12 }">
<g ivCartesianGrid [vertical]="false" />
<g
ivXAxis
dataKey="month"
[tickLine]="false"
[axisLine]="false"
[tickMargin]="8"
[tickFormatter]="short"
/>
<g ivYAxis [tickLine]="false" [axisLine]="false" [tickMargin]="8" [tickCount]="3" />
<g ivArea dataKey="mobile" curve="natural" [fillOpacity]="0.4" stackId="a" />
<g ivArea dataKey="desktop" curve="natural" [fillOpacity]="0.4" stackId="a" />
</svg>
<iv-chart-tooltip [cursor]="false" />
</iv-chart>
</iv-card-content>
<iv-card-footer>
<div class="flex w-full items-start gap-2 text-sm">
<div class="grid gap-2">
<div class="flex items-center gap-2 leading-none font-medium">
Trending up by 5.2% this month <ng-icon [svg]="trendingUp" size="16" />
</div>
<div class="text-muted-foreground flex items-center gap-2 leading-none">
January - June 2024
</div>
</div>
</div>
</iv-card-footer>
</iv-card>
`,
})
export default class ChartAreaAxes {
protected readonly data = [
{ month: 'January', desktop: 186, mobile: 80 },
{ month: 'February', desktop: 305, mobile: 200 },
{ month: 'March', desktop: 237, mobile: 120 },
{ month: 'April', desktop: 73, mobile: 190 },
{ month: 'May', desktop: 209, mobile: 130 },
{ month: 'June', desktop: 214, mobile: 140 },
];
protected readonly config: IvChartConfig = {
desktop: { label: 'Desktop', color: 'var(--chart-1)' },
mobile: { label: 'Mobile', color: 'var(--chart-2)' },
};
protected readonly trendingUp = lucideTrendingUp;
protected readonly short = (month: string) => month.slice(0, 3);
}