chart
Multi-dataset bar chart
Multi-dataset bar chart
Загрузка превью…
src/chart/c-chart-2.vue
<!-- Замена библиотеки: см. c-chart-1.vue / docs/PORTING.md §19/§27. -->
<script setup lang="ts">
import { BarChart } 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", desktop: 120, mobile: 80 },
{ month: "February", desktop: 250, mobile: 200 },
{ month: "March", desktop: 230, mobile: 120 },
{ month: "April", desktop: 70, mobile: 190 },
{ month: "May", desktop: 209, mobile: 130 },
{ month: "June", desktop: 210, mobile: 140 },
]
const chartConfig = {
desktop: { label: "Desktop", color: "var(--chart-1)" },
mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig
const categories = {
desktop: { name: "Desktop", color: "var(--chart-1)" },
mobile: { name: "Mobile", color: "var(--chart-2)" },
}
</script>
<template>
<Card class="w-full max-w-md">
<CardHeader>
<CardTitle>
Market Share
<Badge variant="warning-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>
+12%
</Badge>
</CardTitle>
<CardDescription>Departmental performance comparison</CardDescription>
</CardHeader>
<CardContent>
<ChartContainer :config="chartConfig">
<BarChart
:data="chartData"
x-axis="month"
:y-axis="['desktop', 'mobile']"
:categories="categories"
:height="200"
:radius="4"
:duration="0"
hide-tooltip
hide-legend
/>
</ChartContainer>
</CardContent>
</Card>
</template>