chart
Step area chart with dotted pattern fill
Step area chart with dotted pattern fill
Загрузка превью…
src/chart/c-chart-15.vue
<!--
Замена библиотеки: см. c-chart-13.vue / docs/PORTING.md §19/§27. Точечный
SVG-паттерн заливки не переносится — сплошная градиентная заливка
по умолчанию у `AreaChart`.
-->
<script setup lang="ts">
import { AreaChart, CurveType } from "vue-chrts"
import { Badge } from "@/components/reui/badge"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { ChartContainer, type ChartConfig } from "@/components/ui/chart"
const chartData = [
{ month: "January", connections: 48 },
{ month: "February", connections: 62 },
{ month: "March", connections: 62 },
{ month: "April", connections: 85 },
{ month: "May", connections: 85 },
{ month: "June", connections: 110 },
{ month: "July", connections: 110 },
{ month: "August", connections: 135 },
]
const chartConfig = {
connections: { label: "Connections", color: "var(--chart-2)" },
} satisfies ChartConfig
const categories = { connections: { name: "Connections", color: "var(--chart-2)" } }
function xFormatter(tick: number) {
return chartData[tick]?.month.slice(0, 3) ?? ""
}
</script>
<template>
<Card class="w-full max-w-md">
<CardHeader>
<CardTitle>
Active Connections
<Badge variant="success-light" class="ml-2">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="lucide lucide-trending-up">
<path d="M16 7h6v6" />
<path d="m22 7-8.5 8.5-5-5L2 17" />
</svg>
+257%
</Badge>
</CardTitle>
<CardDescription>Server connection pool over time</CardDescription>
</CardHeader>
<CardContent>
<ChartContainer :config="chartConfig">
<AreaChart
:data="chartData"
:categories="categories"
:height="200"
:x-formatter="xFormatter"
:curve-type="CurveType.StepAfter"
:line-width="2"
:duration="0"
hide-tooltip
hide-legend
/>
</ChartContainer>
</CardContent>
</Card>
</template>