vlite3 1.5.12 → 1.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -8
- package/components/Accordion/AccordionContent.vue.js +2 -2
- package/components/CommandPalette/CommandPaletteContent2.vue.js +1 -1
- package/components/CommandPalette/{CommandPaletteItem2.vue.js → CommandPaletteItem.vue.js} +1 -1
- package/components/Form/AccordionView2.vue.js +1 -1
- package/components/Form/Form.vue.js +2 -2
- package/components/NavbarCommandPalette.vue.js +1 -1
- package/components/PanZoomViewport/PanZoomViewport.vue.d.ts +7 -7
- package/components/PanZoomViewport/PanZoomViewport.vue.js +1 -1
- package/components/Tabes/Tabes.vue.js +2 -2
- package/docs/README.md +16 -0
- package/docs/component-index.md +313 -0
- package/docs/components/accordion.md +52 -0
- package/docs/components/alert.md +34 -0
- package/docs/components/app-shell.md +371 -0
- package/docs/components/async-select.md +264 -0
- package/docs/components/attachments-list.md +231 -0
- package/docs/components/avatar-group.md +74 -0
- package/docs/components/avatar-uploader.md +61 -0
- package/docs/components/avatar.md +28 -0
- package/docs/components/badge.md +81 -0
- package/docs/components/barcode.md +42 -0
- package/docs/components/beacon.md +29 -0
- package/docs/components/breadcrumb.md +317 -0
- package/docs/components/button-group.md +35 -0
- package/docs/components/button.md +86 -0
- package/docs/components/calendar.md +95 -0
- package/docs/components/carousel.md +122 -0
- package/docs/components/cart.md +533 -0
- package/docs/components/category-manager.md +269 -0
- package/docs/components/category-menu.md +251 -0
- package/docs/components/charts.md +1456 -0
- package/docs/components/chat.md +330 -0
- package/docs/components/checkbox.md +31 -0
- package/docs/components/chip.md +137 -0
- package/docs/components/choice-box.md +40 -0
- package/docs/components/clipboard.md +105 -0
- package/docs/components/clock.md +70 -0
- package/docs/components/color-picker.md +82 -0
- package/docs/components/command-palette.md +214 -0
- package/docs/components/comment-thread.md +171 -0
- package/docs/components/confirmation-modal.md +50 -0
- package/docs/components/custom-fields-display.md +94 -0
- package/docs/components/custom-fields.md +97 -0
- package/docs/components/data-list.md +93 -0
- package/docs/components/data-table.md +922 -0
- package/docs/components/date-picker.md +58 -0
- package/docs/components/date-range-picker.md +24 -0
- package/docs/components/date-time.md +104 -0
- package/docs/components/dropdown.md +740 -0
- package/docs/components/empty.md +100 -0
- package/docs/components/export-data.md +320 -0
- package/docs/components/file-picker.md +83 -0
- package/docs/components/file-preview.md +42 -0
- package/docs/components/file-tree.md +144 -0
- package/docs/components/footer.md +251 -0
- package/docs/components/forms.md +776 -0
- package/docs/components/gantt-chart.md +767 -0
- package/docs/components/google-login.md +67 -0
- package/docs/components/google-map.md +128 -0
- package/docs/components/heatmap.md +80 -0
- package/docs/components/icon-picker.md +58 -0
- package/docs/components/icon.md +176 -0
- package/docs/components/image-comparison.md +51 -0
- package/docs/components/image-magnifier.md +26 -0
- package/docs/components/import-data.md +521 -0
- package/docs/components/input.md +58 -0
- package/docs/components/invoice.md +339 -0
- package/docs/components/kanban.md +302 -0
- package/docs/components/label.md +25 -0
- package/docs/components/list.md +419 -0
- package/docs/components/masonry.md +55 -0
- package/docs/components/modal.md +133 -0
- package/docs/components/multi-select.md +54 -0
- package/docs/components/navbar.md +403 -0
- package/docs/components/number-input.md +41 -0
- package/docs/components/otp-input.md +68 -0
- package/docs/components/pagination.md +83 -0
- package/docs/components/pan-zoom-viewport.md +245 -0
- package/docs/components/permission-editor.md +322 -0
- package/docs/components/persona.md +56 -0
- package/docs/components/price.md +106 -0
- package/docs/components/pricing-plan.md +68 -0
- package/docs/components/progress-bar.md +53 -0
- package/docs/components/qr-code.md +59 -0
- package/docs/components/rating.md +59 -0
- package/docs/components/rich-text-editor.md +210 -0
- package/docs/components/scale-generator.md +101 -0
- package/docs/components/screen.md +208 -0
- package/docs/components/seo-provider.md +189 -0
- package/docs/components/side-panel.md +94 -0
- package/docs/components/sidebar-menu.md +422 -0
- package/docs/components/skeleton.md +115 -0
- package/docs/components/slider.md +48 -0
- package/docs/components/spinner.md +27 -0
- package/docs/components/splitter.md +97 -0
- package/docs/components/stats.md +234 -0
- package/docs/components/status-chip.md +232 -0
- package/docs/components/switch.md +23 -0
- package/docs/components/tabs.md +335 -0
- package/docs/components/tag-input.md +55 -0
- package/docs/components/textarea.md +31 -0
- package/docs/components/theme-provider.md +130 -0
- package/docs/components/theme-toggle.md +36 -0
- package/docs/components/thumbnail-selector.md +186 -0
- package/docs/components/timeline.md +225 -0
- package/docs/components/toast-notification.md +89 -0
- package/docs/components/tooltip.md +31 -0
- package/docs/components/workbook.md +102 -0
- package/docs/composables/use-theme.md +59 -0
- package/docs/getting-started/setup.md +176 -0
- package/docs/guides/draggable.md +211 -0
- package/docs/guides/internationalization.md +281 -0
- package/docs/guides/performance.md +118 -0
- package/docs/guides/testing-forms.md +154 -0
- package/docs/guides/testing-overlays.md +131 -0
- package/docs/guides/theming.md +124 -0
- package/docs/utilities/search.md +580 -0
- package/docs/utilities/utilities.md +371 -0
- package/docs-manifest.json +336 -0
- package/package.json +5 -13
- package/scripts/generate-docs-manifest.js +207 -0
- package/scripts/sync-docs.js +754 -0
- package/style.css +1 -1
|
@@ -0,0 +1,1456 @@
|
|
|
1
|
+
# Charts
|
|
2
|
+
|
|
3
|
+
Beautiful, zero-dependency SVG chart components. Fully customizable, dark mode ready, animated, and responsive. Includes Line, Bar, Pie/Donut, Circle (progress ring), Gauge (arc/ticks), Speedometer (car dashboard), Timeline, Gantt, Segment Bar, Stat Card, and Waffle charts.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
| Component | Description |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `LineChart` | Area/line chart — single or multi-series with smooth bezier or straight lines |
|
|
12
|
+
| `BarChart` | Vertical or horizontal bar chart — single or multi-series grouped bars |
|
|
13
|
+
| `PieChart` | Pie or donut chart with animated arc draw and optional center content |
|
|
14
|
+
| `CircleChart` | Single-value progress ring (gauge) with gradient stroke |
|
|
15
|
+
| `GaugeChart` | Multi-variant gauge (arc, ticks, slim, ball) with zones and needle |
|
|
16
|
+
| `SpeedometerChart` | Car-dashboard-style speedometer with numbered ticks, needle, and red zone |
|
|
17
|
+
| `TimelineChart` | Gantt-style horizontal timeline with task bars per person across periods |
|
|
18
|
+
| `GanttChart` | Full-featured project Gantt chart with date positioning, dependencies, and drag-and-drop |
|
|
19
|
+
| `SegmentBarChart` | Single stacked horizontal bar showing proportional segments |
|
|
20
|
+
| `StatCardChart` | Grid of metric cards with percentages, proportional indicators, and trends |
|
|
21
|
+
| `WaffleChart` | Grid of rounded cells colored to represent proportional data |
|
|
22
|
+
|
|
23
|
+
All components:
|
|
24
|
+
|
|
25
|
+
- **Zero dependencies** — pure SVG, no chart library required
|
|
26
|
+
- **Dark mode ready** — colors resolve from CSS custom properties
|
|
27
|
+
- **Animated** — smooth entry animations via `requestAnimationFrame` with ease-out cubic
|
|
28
|
+
- **Responsive** — adapts to container width via `ResizeObserver`
|
|
29
|
+
- **Accessible** — SVGs have `role="img"` and `aria-label`
|
|
30
|
+
- **Focused Interactions** — hover effects highlight targets without dimming surrounding elements
|
|
31
|
+
- **Fully typed** — TypeScript interfaces exported from each component
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Installation & Import
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
import {
|
|
40
|
+
LineChart,
|
|
41
|
+
BarChart,
|
|
42
|
+
PieChart,
|
|
43
|
+
CircleChart,
|
|
44
|
+
GaugeChart,
|
|
45
|
+
SpeedometerChart,
|
|
46
|
+
TimelineChart,
|
|
47
|
+
GanttChart,
|
|
48
|
+
SegmentBarChart,
|
|
49
|
+
StatCardChart,
|
|
50
|
+
WaffleChart,
|
|
51
|
+
} from 'vlite3'
|
|
52
|
+
</script>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You can also import types:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import type { ChartDataPoint, ChartDataset } from 'vlite3'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Shared Types
|
|
64
|
+
|
|
65
|
+
### `ChartDataPoint`
|
|
66
|
+
|
|
67
|
+
The basic data unit used for single-series charts.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
interface ChartDataPoint {
|
|
71
|
+
label: string // X-axis label or legend text
|
|
72
|
+
value: number // Numeric value
|
|
73
|
+
color?: string // Optional per-point color override (CSS color string)
|
|
74
|
+
[key: string]: any // Additional metadata (unused by components)
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `ChartDataset`
|
|
79
|
+
|
|
80
|
+
Used for multi-series charts (line + bar).
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
interface ChartDataset {
|
|
84
|
+
label: string // Series name (shown in legend and tooltip)
|
|
85
|
+
data: number[] // Array of values — must align with the `labels` prop
|
|
86
|
+
color?: string // Optional series color override
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `ChartColor` (semantic tokens)
|
|
91
|
+
|
|
92
|
+
Several components accept a `color` prop that takes either a semantic token or any valid CSS color:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
type ChartColor =
|
|
96
|
+
| 'primary'
|
|
97
|
+
| 'success'
|
|
98
|
+
| 'warning'
|
|
99
|
+
| 'danger'
|
|
100
|
+
| 'info'
|
|
101
|
+
| 'purple'
|
|
102
|
+
| 'teal'
|
|
103
|
+
| 'orange'
|
|
104
|
+
| 'pink'
|
|
105
|
+
| 'cyan'
|
|
106
|
+
| string // any CSS color, e.g. '#f97316' or 'hsl(220 90% 60%)'
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `StrokeLineCap`
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
type StrokeLineCap = 'round' | 'square' | 'butt'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Color Palette
|
|
118
|
+
|
|
119
|
+
Charts automatically use CSS variable-based colors that adapt to light and dark mode:
|
|
120
|
+
|
|
121
|
+
| Variable | Light Mode | Dark Mode |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| `--color-chart-1` | `#6366f1` (indigo) | `#818cf8` |
|
|
124
|
+
| `--color-chart-2` | `#22c55e` (emerald) | `#34d399` |
|
|
125
|
+
| `--color-chart-3` | `#f59e0b` (amber) | `#fbbf24` |
|
|
126
|
+
| `--color-chart-4` | `#ef4444` (red) | `#fb7185` |
|
|
127
|
+
| `--color-chart-5` | `#3b82f6` (blue) | `#60a5fa` |
|
|
128
|
+
| `--color-chart-6` | `#ec4899` (pink) | `#f472b6` |
|
|
129
|
+
|
|
130
|
+
Override them globally in your CSS:
|
|
131
|
+
|
|
132
|
+
```css
|
|
133
|
+
:root {
|
|
134
|
+
--color-chart-1: hsl(260 80% 60%);
|
|
135
|
+
--color-chart-2: hsl(160 70% 45%);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Or pass a custom palette to any chart via the `colors` prop:
|
|
140
|
+
|
|
141
|
+
```vue
|
|
142
|
+
<LineChart :colors="['#f97316', '#8b5cf6', '#06b6d4']" :data="data" />
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## LineChart
|
|
148
|
+
|
|
149
|
+
A responsive area/line chart supporting single and multi-series data, smooth bezier curves, gradient fill, animated draw-on entry, hover tooltip with crosshair, and full axis customization.
|
|
150
|
+
|
|
151
|
+
### Basic Usage
|
|
152
|
+
|
|
153
|
+
```vue
|
|
154
|
+
<LineChart :data="data" />
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Props
|
|
158
|
+
|
|
159
|
+
#### Data
|
|
160
|
+
|
|
161
|
+
| Prop | Type | Default | Description |
|
|
162
|
+
|---|---|---|---|
|
|
163
|
+
| `data` | `ChartDataPoint[]` | — | Single-series data array |
|
|
164
|
+
| `datasets` | `ChartDataset[]` | — | Multi-series datasets — **overrides `data`** when provided |
|
|
165
|
+
| `labels` | `string[]` | — | X-axis labels when using `datasets` |
|
|
166
|
+
|
|
167
|
+
> **Note:** Use either `data` (single series) or `datasets` + `labels` (multi-series). Never both.
|
|
168
|
+
|
|
169
|
+
#### Layout
|
|
170
|
+
|
|
171
|
+
| Prop | Type | Default | Description |
|
|
172
|
+
|---|---|---|---|
|
|
173
|
+
| `height` | `number` | `300` | Chart height in pixels. Width is always 100% of the container. |
|
|
174
|
+
| `yMin` | `number` | — | Override the Y-axis minimum value |
|
|
175
|
+
| `yMax` | `number` | — | Override the Y-axis maximum value |
|
|
176
|
+
| `xLabel` | `string` | — | Text label displayed below the X axis |
|
|
177
|
+
| `yLabel` | `string` | — | Text label displayed to the left of the Y axis (rotated 90°) |
|
|
178
|
+
|
|
179
|
+
#### Line Style
|
|
180
|
+
|
|
181
|
+
| Prop | Type | Default | Description |
|
|
182
|
+
|---|---|---|---|
|
|
183
|
+
| `smooth` | `boolean` | `true` | Use smooth bezier curves. Set to `false` for straight angular lines. |
|
|
184
|
+
| `fill` | `boolean` | `true` | Fill the area under the line with a gradient. |
|
|
185
|
+
| `showDots` | `boolean` | `true` | Render circular dots at each data point. Dots scale up on hover. |
|
|
186
|
+
| `lineWidth` | `number` | `2.5` | Stroke width of the chart line in pixels. |
|
|
187
|
+
| `fillOpacity` | `number` | `0.25` | Top stop opacity for the area-fill gradient (0–1). Use a lower value for subtle sparklines. |
|
|
188
|
+
| `colors` | `string[]` | CSS palette | Override the color palette. First color used for single-series. |
|
|
189
|
+
|
|
190
|
+
#### Axis & Grid Visibility
|
|
191
|
+
|
|
192
|
+
| Prop | Type | Default | Description |
|
|
193
|
+
|---|---|---|---|
|
|
194
|
+
| `showGrid` | `boolean` | `true` | Horizontal gridlines across the chart area. |
|
|
195
|
+
| `showXAxis` | `boolean` | `true` | Bottom border line (X axis). |
|
|
196
|
+
| `showYAxis` | `boolean` | `true` | Left border line (Y axis). |
|
|
197
|
+
| `showXLabels` | `boolean` | `true` | X-axis tick labels below the chart. Hiding them also collapses their reserved space. |
|
|
198
|
+
| `showYLabels` | `boolean` | `true` | Y-axis tick labels to the left. Hiding them also collapses their reserved space. |
|
|
199
|
+
| `gridOpacity` | `number` | `0.07` | Opacity of the horizontal gridlines (0–1). |
|
|
200
|
+
| `axisOpacity` | `number` | `0.1` | Opacity of the axis border lines (0–1). |
|
|
201
|
+
|
|
202
|
+
#### Interaction & Behaviour
|
|
203
|
+
|
|
204
|
+
| Prop | Type | Default | Description |
|
|
205
|
+
|---|---|---|---|
|
|
206
|
+
| `showTooltip` | `boolean` | `true` | Crosshair and floating tooltip on hover. |
|
|
207
|
+
| `showLegend` | `boolean` | `true` | Legend row above the chart (only shown when `datasets` is used). |
|
|
208
|
+
| `animate` | `boolean` | `true` | Animate the line drawing from left to right on mount. Also re-runs when data changes. |
|
|
209
|
+
| `formatValue` | `(v: number) => string` | built-in | Custom formatter for Y-axis ticks and tooltip values. |
|
|
210
|
+
|
|
211
|
+
### Examples
|
|
212
|
+
|
|
213
|
+
```vue
|
|
214
|
+
<!-- Minimal single series -->
|
|
215
|
+
<LineChart :data="[
|
|
216
|
+
{ label: 'Jan', value: 4200 },
|
|
217
|
+
{ label: 'Feb', value: 5800 },
|
|
218
|
+
{ label: 'Mar', value: 7100 },
|
|
219
|
+
]" />
|
|
220
|
+
|
|
221
|
+
<!-- Full configuration — single series -->
|
|
222
|
+
<LineChart
|
|
223
|
+
:data="revenueData"
|
|
224
|
+
:height="320"
|
|
225
|
+
:smooth="true"
|
|
226
|
+
:fill="true"
|
|
227
|
+
:show-dots="true"
|
|
228
|
+
:line-width="3"
|
|
229
|
+
y-label="Revenue ($)"
|
|
230
|
+
:format-value="(v) => '$' + v.toLocaleString()"
|
|
231
|
+
:y-min="0"
|
|
232
|
+
:animate="true"
|
|
233
|
+
:show-tooltip="true" />
|
|
234
|
+
|
|
235
|
+
<!-- Multi-series with custom colors -->
|
|
236
|
+
<LineChart
|
|
237
|
+
:datasets="[
|
|
238
|
+
{ label: 'Revenue', data: [4200, 5800, 7100, 9400], color: '#6366f1' },
|
|
239
|
+
{ label: 'Expenses', data: [3100, 3400, 4200, 5100], color: '#ef4444' },
|
|
240
|
+
{ label: 'Profit', data: [1100, 2400, 2900, 4300], color: '#22c55e' },
|
|
241
|
+
]"
|
|
242
|
+
:labels="['Jan', 'Feb', 'Mar', 'Jun']"
|
|
243
|
+
:fill="false"
|
|
244
|
+
:show-dots="true"
|
|
245
|
+
:format-value="(v) => '$' + v.toLocaleString()" />
|
|
246
|
+
|
|
247
|
+
<!-- Minimal sparkline — no axes, no labels, no fill -->
|
|
248
|
+
<LineChart
|
|
249
|
+
:data="sparkData"
|
|
250
|
+
:height="80"
|
|
251
|
+
:smooth="true"
|
|
252
|
+
:fill="false"
|
|
253
|
+
:show-dots="false"
|
|
254
|
+
:show-grid="false"
|
|
255
|
+
:show-x-axis="false"
|
|
256
|
+
:show-y-axis="false"
|
|
257
|
+
:show-x-labels="false"
|
|
258
|
+
:show-y-labels="false"
|
|
259
|
+
:show-tooltip="false"
|
|
260
|
+
:show-legend="false"
|
|
261
|
+
:animate="false" />
|
|
262
|
+
|
|
263
|
+
<!-- Stripped axes for an embedded/widget look -->
|
|
264
|
+
<LineChart
|
|
265
|
+
:data="data"
|
|
266
|
+
:show-y-labels="false"
|
|
267
|
+
:show-x-axis="false"
|
|
268
|
+
:show-y-axis="false"
|
|
269
|
+
:grid-opacity="0.04"
|
|
270
|
+
:line-width="2" />
|
|
271
|
+
|
|
272
|
+
<!-- Dialing in subtle chrome -->
|
|
273
|
+
<LineChart
|
|
274
|
+
:data="data"
|
|
275
|
+
:grid-opacity="0.15"
|
|
276
|
+
:axis-opacity="0.25"
|
|
277
|
+
:line-width="1.5" />
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## BarChart
|
|
283
|
+
|
|
284
|
+
A vertical or horizontal bar chart supporting single and multi-series grouped data, per-bar color overrides, value labels, animated grow-in, focused hover states, and full axis customization.
|
|
285
|
+
|
|
286
|
+
### Basic Usage
|
|
287
|
+
|
|
288
|
+
```vue
|
|
289
|
+
<BarChart :data="data" />
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Props
|
|
293
|
+
|
|
294
|
+
#### Data
|
|
295
|
+
|
|
296
|
+
| Prop | Type | Default | Description |
|
|
297
|
+
|---|---|---|---|
|
|
298
|
+
| `data` | `ChartDataPoint[]` | — | Single-series data. Each item can include a `color` override. |
|
|
299
|
+
| `datasets` | `ChartDataset[]` | — | Multi-series grouped data — **overrides `data`** when provided. |
|
|
300
|
+
| `labels` | `string[]` | — | X-axis group labels when using `datasets`. |
|
|
301
|
+
|
|
302
|
+
#### Layout
|
|
303
|
+
|
|
304
|
+
| Prop | Type | Default | Description |
|
|
305
|
+
|---|---|---|---|
|
|
306
|
+
| `height` | `number` | `300` | Chart height in pixels. |
|
|
307
|
+
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Bar direction. Horizontal is great for ranked/comparative data. |
|
|
308
|
+
|
|
309
|
+
#### Bar Style
|
|
310
|
+
|
|
311
|
+
| Prop | Type | Default | Description |
|
|
312
|
+
|---|---|---|---|
|
|
313
|
+
| `barRadius` | `number` | `6` | Corner radius applied to the leading edge of each bar (top for vertical, right for horizontal). |
|
|
314
|
+
| `colors` | `string[]` | CSS palette | Override the color palette for multi-series or default single-series colors. |
|
|
315
|
+
|
|
316
|
+
#### Axis & Grid Visibility
|
|
317
|
+
|
|
318
|
+
| Prop | Type | Default | Description |
|
|
319
|
+
|---|---|---|---|
|
|
320
|
+
| `showGrid` | `boolean` | `true` | Gridlines perpendicular to the value axis. |
|
|
321
|
+
| `showXAxis` | `boolean` | `true` | Bottom border line (vertical) or bottom line (horizontal). |
|
|
322
|
+
| `showYAxis` | `boolean` | `true` | Left border line. |
|
|
323
|
+
| `showXLabels` | `boolean` | `true` | Category labels below bars (vertical) or value ticks at top (horizontal). Hiding collapses their reserved space. |
|
|
324
|
+
| `showYLabels` | `boolean` | `true` | Value tick labels left of bars (vertical) or bar names left of bars (horizontal). Hiding collapses their reserved space. |
|
|
325
|
+
| `gridOpacity` | `number` | `0.07` | Opacity of gridlines (0–1). |
|
|
326
|
+
| `axisOpacity` | `number` | `0.1` | Opacity of axis border lines (0–1). |
|
|
327
|
+
|
|
328
|
+
#### Interaction & Behaviour
|
|
329
|
+
|
|
330
|
+
| Prop | Type | Default | Description |
|
|
331
|
+
|---|---|---|---|
|
|
332
|
+
| `showValues` | `boolean` | `false` | Render value labels directly on/above each bar. |
|
|
333
|
+
| `showTooltip` | `boolean` | `true` | Floating tooltip on hover. |
|
|
334
|
+
| `showLegend` | `boolean` | `true` | Legend (only visible when `datasets` is used). |
|
|
335
|
+
| `animate` | `boolean` | `true` | Grow-in animation from the baseline on mount. Re-runs when data changes. |
|
|
336
|
+
| `formatValue` | `(v: number) => string` | built-in | Custom formatter for bar value labels and tooltip. |
|
|
337
|
+
|
|
338
|
+
### Examples
|
|
339
|
+
|
|
340
|
+
```vue
|
|
341
|
+
<!-- Vertical bars with per-bar colors and value labels -->
|
|
342
|
+
<BarChart
|
|
343
|
+
:data="[
|
|
344
|
+
{ label: 'Jan', value: 4200, color: 'var(--color-chart-1)' },
|
|
345
|
+
{ label: 'Feb', value: 5800, color: 'var(--color-chart-5)' },
|
|
346
|
+
{ label: 'Mar', value: 5200, color: 'var(--color-chart-2)' },
|
|
347
|
+
{ label: 'Apr', value: 7100, color: 'var(--color-chart-3)' },
|
|
348
|
+
{ label: 'May', value: 6800, color: 'var(--color-chart-4)' },
|
|
349
|
+
{ label: 'Jun', value: 9400, color: 'var(--color-chart-6)' },
|
|
350
|
+
]"
|
|
351
|
+
:height="280"
|
|
352
|
+
:bar-radius="8"
|
|
353
|
+
show-values />
|
|
354
|
+
|
|
355
|
+
<!-- Multi-series grouped bars -->
|
|
356
|
+
<BarChart
|
|
357
|
+
:datasets="[
|
|
358
|
+
{ label: 'Product A', data: [4200, 6100, 7800, 9200] },
|
|
359
|
+
{ label: 'Product B', data: [3100, 4800, 5200, 7100] },
|
|
360
|
+
{ label: 'Product C', data: [1800, 2400, 3100, 4300] },
|
|
361
|
+
]"
|
|
362
|
+
:labels="['Q1', 'Q2', 'Q3', 'Q4']"
|
|
363
|
+
:height="280"
|
|
364
|
+
:bar-radius="6"
|
|
365
|
+
:format-value="(v) => '$' + v.toLocaleString()" />
|
|
366
|
+
|
|
367
|
+
<!-- Horizontal orientation — great for rankings -->
|
|
368
|
+
<BarChart
|
|
369
|
+
:data="[
|
|
370
|
+
{ label: 'Next.js', value: 81 },
|
|
371
|
+
{ label: 'React', value: 78 },
|
|
372
|
+
{ label: 'Vue', value: 65 },
|
|
373
|
+
{ label: 'Angular', value: 52 },
|
|
374
|
+
{ label: 'Svelte', value: 43 },
|
|
375
|
+
]"
|
|
376
|
+
orientation="horizontal"
|
|
377
|
+
:height="280"
|
|
378
|
+
:bar-radius="6"
|
|
379
|
+
show-values
|
|
380
|
+
:format-value="(v) => v + '%'" />
|
|
381
|
+
|
|
382
|
+
<!-- Minimal embedded look — no axes, no chrome -->
|
|
383
|
+
<BarChart
|
|
384
|
+
:data="data"
|
|
385
|
+
:show-x-axis="false"
|
|
386
|
+
:show-y-axis="false"
|
|
387
|
+
:show-x-labels="false"
|
|
388
|
+
:show-y-labels="false"
|
|
389
|
+
:show-grid="false"
|
|
390
|
+
show-values />
|
|
391
|
+
|
|
392
|
+
<!-- Custom grid & axis opacity -->
|
|
393
|
+
<BarChart
|
|
394
|
+
:data="data"
|
|
395
|
+
:grid-opacity="0.12"
|
|
396
|
+
:axis-opacity="0.2"
|
|
397
|
+
:bar-radius="4" />
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## PieChart
|
|
403
|
+
|
|
404
|
+
A pie or donut chart with animated arc draw, explode-on-hover effect, optional center content, and an interactive legend.
|
|
405
|
+
|
|
406
|
+
### Basic Usage
|
|
407
|
+
|
|
408
|
+
```vue
|
|
409
|
+
<PieChart :data="data" />
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Props
|
|
413
|
+
|
|
414
|
+
#### Data
|
|
415
|
+
|
|
416
|
+
| Prop | Type | Default | Description |
|
|
417
|
+
|---|---|---|---|
|
|
418
|
+
| `data` | `ChartDataPoint[]` | **required** | Array of `{ label, value, color? }`. Colors are auto-assigned from the palette if not set per-item. |
|
|
419
|
+
|
|
420
|
+
#### Shape & Layout
|
|
421
|
+
|
|
422
|
+
| Prop | Type | Default | Description |
|
|
423
|
+
|---|---|---|---|
|
|
424
|
+
| `donut` | `boolean` | `false` | Render as a donut (ring) instead of a filled pie. |
|
|
425
|
+
| `innerRadius` | `number` | `60` | Inner cutout as a **percentage of the outer radius** (only applies when `donut` is `true`). Range: 0–100. |
|
|
426
|
+
| `size` | `number` | `280` | SVG diameter in pixels. |
|
|
427
|
+
| `startAngle` | `number` | `-90` | Starting angle in degrees. `-90` puts the first slice at the top (12 o'clock). |
|
|
428
|
+
|
|
429
|
+
#### Labels & Legend
|
|
430
|
+
|
|
431
|
+
| Prop | Type | Default | Description |
|
|
432
|
+
|---|---|---|---|
|
|
433
|
+
| `labelMode` | `'percent' \| 'value' \| 'label' \| 'outside' \| 'none'` | `'percent'` | What to display on each slice. `'outside'` draws labels and spider lines outside the chart. Use `'none'` to suppress. |
|
|
434
|
+
| `showLegend` | `boolean` | `true` | Show the item legend. |
|
|
435
|
+
| `legendPosition` | `'right' \| 'bottom'` | `'right'` | Where the legend sits relative to the chart. |
|
|
436
|
+
| `legendsVariant` | `'default' \| 'variant1' \| 'variant2'` | `'default'` | Legend layout preset. See **Legend Variants** below. |
|
|
437
|
+
|
|
438
|
+
#### Legend Variants
|
|
439
|
+
|
|
440
|
+
| Value | Description |
|
|
441
|
+
|---|---|
|
|
442
|
+
| `default` | Original two-line items (label on top, value + % below). Fully backward compatible. |
|
|
443
|
+
| `variant1` | Compact horizontal wrap: `● Label (value, pct%)`. Best for bottom legends in dense dashboards. |
|
|
444
|
+
| `variant2` | Vertical rows with label flush-left and `value (pct%)` flush-right. Spans the full container width when `legendPosition="bottom"`; the donut stays centered above. |
|
|
445
|
+
|
|
446
|
+
```vue
|
|
447
|
+
<!-- Compact horizontal legend under a donut -->
|
|
448
|
+
<PieChart
|
|
449
|
+
:data="salesStatus"
|
|
450
|
+
:donut="true"
|
|
451
|
+
label-mode="none"
|
|
452
|
+
legend-position="bottom"
|
|
453
|
+
legends-variant="variant1"
|
|
454
|
+
center-value="156"
|
|
455
|
+
center-label="Total Orders" />
|
|
456
|
+
|
|
457
|
+
<!-- Vertical value-aligned legend -->
|
|
458
|
+
<PieChart
|
|
459
|
+
:data="invoiceStatus"
|
|
460
|
+
:donut="true"
|
|
461
|
+
label-mode="none"
|
|
462
|
+
legend-position="bottom"
|
|
463
|
+
legends-variant="variant2"
|
|
464
|
+
center-value="98"
|
|
465
|
+
center-label="Total Invoices" />
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
#### Donut Center Content
|
|
469
|
+
|
|
470
|
+
| Prop | Type | Default | Description |
|
|
471
|
+
|---|---|---|---|
|
|
472
|
+
| `centerValue` | `string` | — | Primary text in the donut center (e.g. `'$94k'`). Only rendered when `donut` is `true`. |
|
|
473
|
+
| `centerLabel` | `string` | — | Secondary/subtitle text below `centerValue` in the donut center. |
|
|
474
|
+
|
|
475
|
+
> Use the `#center` slot for fully custom center content (see Slots below).
|
|
476
|
+
|
|
477
|
+
#### Colors & Behaviour
|
|
478
|
+
|
|
479
|
+
| Prop | Type | Default | Description |
|
|
480
|
+
|---|---|---|---|
|
|
481
|
+
| `colors` | `string[]` | CSS palette | Custom color palette. Overrides per-item `color` only when the item has none. |
|
|
482
|
+
| `animate` | `boolean` | `true` | Rotate-in animation on mount. Re-runs when `data` changes. |
|
|
483
|
+
| `showTooltip` | `boolean` | `true` | Floating tooltip on slice hover (shows label, value, and percentage). |
|
|
484
|
+
|
|
485
|
+
### Slots
|
|
486
|
+
|
|
487
|
+
| Slot | Slot Props | Description |
|
|
488
|
+
|---|---|---|
|
|
489
|
+
| `#center` | `{ total: number, data: ChartDataPoint[] }` | Fully custom SVG content rendered inside the donut hole. Must contain valid SVG elements. |
|
|
490
|
+
|
|
491
|
+
### Examples
|
|
492
|
+
|
|
493
|
+
```vue
|
|
494
|
+
<!-- Standard pie with percentage labels -->
|
|
495
|
+
<PieChart
|
|
496
|
+
:data="[
|
|
497
|
+
{ label: 'Desktop', value: 42 },
|
|
498
|
+
{ label: 'Mobile', value: 38 },
|
|
499
|
+
{ label: 'Tablet', value: 13 },
|
|
500
|
+
{ label: 'Other', value: 7 },
|
|
501
|
+
]"
|
|
502
|
+
label-mode="percent" />
|
|
503
|
+
|
|
504
|
+
<!-- Donut with center props -->
|
|
505
|
+
<PieChart
|
|
506
|
+
:data="revenueBreakdown"
|
|
507
|
+
:donut="true"
|
|
508
|
+
:inner-radius="62"
|
|
509
|
+
:size="300"
|
|
510
|
+
center-value="$94k"
|
|
511
|
+
center-label="Total Revenue"
|
|
512
|
+
label-mode="percent"
|
|
513
|
+
legend-position="bottom" />
|
|
514
|
+
|
|
515
|
+
<!-- Donut with fully custom center slot -->
|
|
516
|
+
<PieChart :data="data" :donut="true" :inner-radius="55" label-mode="none">
|
|
517
|
+
<template #center="{ total }">
|
|
518
|
+
<text x="140" y="128" text-anchor="middle" font-size="26" font-weight="800" class="fill-foreground">
|
|
519
|
+
{{ total.toLocaleString() }}
|
|
520
|
+
</text>
|
|
521
|
+
<text x="140" y="152" text-anchor="middle" font-size="12" class="fill-muted-foreground">
|
|
522
|
+
Total Users
|
|
523
|
+
</text>
|
|
524
|
+
</template>
|
|
525
|
+
</PieChart>
|
|
526
|
+
|
|
527
|
+
<!-- Legend at bottom, no slice labels -->
|
|
528
|
+
<PieChart
|
|
529
|
+
:data="trafficSources"
|
|
530
|
+
:size="220"
|
|
531
|
+
label-mode="none"
|
|
532
|
+
legend-position="bottom" />
|
|
533
|
+
|
|
534
|
+
<!-- Custom colors, label mode = value -->
|
|
535
|
+
<PieChart
|
|
536
|
+
:data="data"
|
|
537
|
+
:colors="['#6366f1', '#f59e0b', '#22c55e', '#ef4444']"
|
|
538
|
+
label-mode="value" />
|
|
539
|
+
|
|
540
|
+
<!-- No animation, no tooltip -->
|
|
541
|
+
<PieChart
|
|
542
|
+
:data="data"
|
|
543
|
+
:animate="false"
|
|
544
|
+
:show-tooltip="false" />
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
## CircleChart
|
|
550
|
+
|
|
551
|
+
A single-value animated progress ring (gauge), supporting semantic color tokens, custom hex colors, gradient strokes, and fully custom center content via a slot.
|
|
552
|
+
|
|
553
|
+
### Basic Usage
|
|
554
|
+
|
|
555
|
+
```vue
|
|
556
|
+
<CircleChart :value="75" />
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### Props
|
|
560
|
+
|
|
561
|
+
#### Value
|
|
562
|
+
|
|
563
|
+
| Prop | Type | Default | Description |
|
|
564
|
+
|---|---|---|---|
|
|
565
|
+
| `value` | `number` | **required** | Current value. If `max` is `100`, this is treated as a direct percentage. |
|
|
566
|
+
| `max` | `number` | `100` | Maximum value. The ring fills to `value / max`. |
|
|
567
|
+
|
|
568
|
+
#### Size & Shape
|
|
569
|
+
|
|
570
|
+
| Prop | Type | Default | Description |
|
|
571
|
+
|---|---|---|---|
|
|
572
|
+
| `size` | `number` | `160` | SVG diameter in pixels. |
|
|
573
|
+
| `strokeWidth` | `number` | `12` | Ring stroke width in pixels. Larger values mean a thicker ring. |
|
|
574
|
+
| `lineCap` | `'round' \| 'square' \| 'butt'` | `'round'` | Shape of the stroke ends. `'round'` for smooth finish, `'butt'` for flat/modern. |
|
|
575
|
+
|
|
576
|
+
#### Color & Style
|
|
577
|
+
|
|
578
|
+
| Prop | Type | Default | Description |
|
|
579
|
+
|---|---|---|---|
|
|
580
|
+
| `color` | `ChartColor \| string` | `'primary'` | Semantic color token or any CSS color string (`'#f97316'`, `'hsl(...)'`). |
|
|
581
|
+
| `gradient` | `boolean` | `true` | Apply a two-stop gradient on the arc stroke. |
|
|
582
|
+
| `trackColor` | `string` | `var(--color-muted)` | Background ring color. Accepts any CSS color. |
|
|
583
|
+
|
|
584
|
+
#### Labels & Display
|
|
585
|
+
|
|
586
|
+
| Prop | Type | Default | Description |
|
|
587
|
+
|---|---|---|---|
|
|
588
|
+
| `label` | `string` | — | Primary label rendered below the ring. |
|
|
589
|
+
| `sublabel` | `string` | — | Smaller secondary label below `label`. |
|
|
590
|
+
| `showValue` | `boolean` | `true` | Show the calculated percentage string in the center of the ring. |
|
|
591
|
+
| `formatValue` | `(v: number, pct: number) => string` | built-in | Custom center display text. Receives both the raw value and the percentage (0–100). |
|
|
592
|
+
|
|
593
|
+
#### Behaviour
|
|
594
|
+
|
|
595
|
+
| Prop | Type | Default | Description |
|
|
596
|
+
|---|---|---|---|
|
|
597
|
+
| `animate` | `boolean` | `true` | Animate the arc fill from 0 to the target value on mount. Also re-animates when `value` changes. |
|
|
598
|
+
|
|
599
|
+
### Slots
|
|
600
|
+
|
|
601
|
+
| Slot | Slot Props | Description |
|
|
602
|
+
|---|---|---|
|
|
603
|
+
| `#center` | `{ value: number, percentage: number, displayValue: string }` | Fully custom HTML content rendered inside the ring. Replaces the default value display. |
|
|
604
|
+
|
|
605
|
+
### Examples
|
|
606
|
+
|
|
607
|
+
```vue
|
|
608
|
+
<!-- Basic with semantic color -->
|
|
609
|
+
<CircleChart :value="84" color="success" label="Uptime" sublabel="This month" />
|
|
610
|
+
|
|
611
|
+
<!-- Custom max (not a percentage) -->
|
|
612
|
+
<CircleChart
|
|
613
|
+
:value="2480"
|
|
614
|
+
:max="5000"
|
|
615
|
+
color="info"
|
|
616
|
+
label="Tasks Done"
|
|
617
|
+
sublabel="of 5,000 total"
|
|
618
|
+
:format-value="(v) => v.toLocaleString()" />
|
|
619
|
+
|
|
620
|
+
<!-- All semantic colors -->
|
|
621
|
+
<CircleChart :value="78" color="primary" label="Performance" :size="140" />
|
|
622
|
+
<CircleChart :value="92" color="success" label="Uptime" :size="140" />
|
|
623
|
+
<CircleChart :value="64" color="warning" label="Disk Usage" :size="140" />
|
|
624
|
+
<CircleChart :value="38" color="danger" label="Error Rate" :size="140" />
|
|
625
|
+
<CircleChart :value="85" color="info" label="API Health" :size="140" />
|
|
626
|
+
|
|
627
|
+
<!-- Custom hex color -->
|
|
628
|
+
<CircleChart :value="72" color="#8b5cf6" label="Adoption" sublabel="Beta users" />
|
|
629
|
+
|
|
630
|
+
<!-- No gradient, flat stroke -->
|
|
631
|
+
<CircleChart :value="55" :size="100" :stroke-width="8" color="primary" :gradient="false" />
|
|
632
|
+
|
|
633
|
+
<!-- Butt / flat line cap -->
|
|
634
|
+
<CircleChart :value="90" :size="180" :stroke-width="18" color="info" line-cap="butt" label="Coverage" />
|
|
635
|
+
|
|
636
|
+
<!-- Custom track color -->
|
|
637
|
+
<CircleChart :value="60" color="warning" track-color="rgba(245,158,11,0.1)" />
|
|
638
|
+
|
|
639
|
+
<!-- Fully custom center slot -->
|
|
640
|
+
<CircleChart :value="68" color="#f97316" :show-value="false" label="Goals Met">
|
|
641
|
+
<template #center="{ percentage }">
|
|
642
|
+
<div class="text-center">
|
|
643
|
+
<div class="text-2xl font-black" style="color: #f97316">
|
|
644
|
+
{{ Math.round(percentage) }}%
|
|
645
|
+
</div>
|
|
646
|
+
<div class="text-xs text-muted-foreground">Goals Met</div>
|
|
647
|
+
</div>
|
|
648
|
+
</template>
|
|
649
|
+
</CircleChart>
|
|
650
|
+
|
|
651
|
+
<!-- No animation (e.g. server-side snapshot) -->
|
|
652
|
+
<CircleChart :value="75" :animate="false" />
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
---
|
|
656
|
+
|
|
657
|
+
## SpeedometerChart
|
|
658
|
+
|
|
659
|
+
A car-dashboard-style gauge with numbered tick marks around the arc, a sweeping animated needle, glowing hub, and optional red zone. Supports four visual variants: classic, modern, sport, and minimal.
|
|
660
|
+
|
|
661
|
+
### Basic Usage
|
|
662
|
+
|
|
663
|
+
```vue
|
|
664
|
+
<SpeedometerChart :value="120" />
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
### Props
|
|
668
|
+
|
|
669
|
+
#### Data
|
|
670
|
+
|
|
671
|
+
| Prop | Type | Default | Description |
|
|
672
|
+
|---|---|---|---|
|
|
673
|
+
| `value` | `number` | **required** | Current speed / value the needle points to |
|
|
674
|
+
| `min` | `number` | `0` | Minimum value on the scale |
|
|
675
|
+
| `max` | `number` | `240` | Maximum value on the scale |
|
|
676
|
+
|
|
677
|
+
#### Visual Variant
|
|
678
|
+
|
|
679
|
+
| Prop | Type | Default | Description |
|
|
680
|
+
|---|---|---|---|
|
|
681
|
+
| `variant` | `'classic' \| 'modern' \| 'sport' \| 'minimal'` | `'classic'` | Rendering style. Classic = traditional car dash, Modern = sleek with glow, Sport = aggressive with red zone effects, Minimal = clean thin design. |
|
|
682
|
+
|
|
683
|
+
#### Dimensions
|
|
684
|
+
|
|
685
|
+
| Prop | Type | Default | Description |
|
|
686
|
+
|---|---|---|---|
|
|
687
|
+
| `size` | `number` | `280` | SVG diameter in pixels. All labels and ticks scale proportionally. |
|
|
688
|
+
| `gapAngle` | `number` | `60` | Opening gap at the bottom of the gauge arc, in degrees. |
|
|
689
|
+
|
|
690
|
+
#### Colors
|
|
691
|
+
|
|
692
|
+
| Prop | Type | Default | Description |
|
|
693
|
+
|---|---|---|---|
|
|
694
|
+
| `color` | `ChartColor \| string` | `'primary'` | Semantic color token or any CSS color. Controls the needle, progress arc, and hub. |
|
|
695
|
+
| `needleColor` | `string` | — | Override needle color. Defaults to `'danger'` for sport variant, otherwise inherits `color`. |
|
|
696
|
+
|
|
697
|
+
#### Scale
|
|
698
|
+
|
|
699
|
+
| Prop | Type | Default | Description |
|
|
700
|
+
|---|---|---|---|
|
|
701
|
+
| `majorStep` | `number` | `20` | Step between major (numbered) tick labels. E.g. `20` → labels at 0, 20, 40, 60, ... |
|
|
702
|
+
| `minorTicks` | `number` | `4` | Number of minor ticks between each pair of major ticks. |
|
|
703
|
+
| `unit` | `string` | `'km/h'` | Unit label displayed below the value (e.g. `'mph'`, `'RPM'`, `'°C'`). |
|
|
704
|
+
|
|
705
|
+
#### Labels & Display
|
|
706
|
+
|
|
707
|
+
| Prop | Type | Default | Description |
|
|
708
|
+
|---|---|---|---|
|
|
709
|
+
| `showValue` | `boolean` | `true` | Show the current value in the center of the gauge. |
|
|
710
|
+
| `formatValue` | `(v: number) => string` | built-in | Custom formatter for the center value display. |
|
|
711
|
+
| `label` | `string` | — | Primary label rendered below the gauge SVG. |
|
|
712
|
+
|
|
713
|
+
#### Red Zone
|
|
714
|
+
|
|
715
|
+
| Prop | Type | Default | Description |
|
|
716
|
+
|---|---|---|---|
|
|
717
|
+
| `redZoneStart` | `number` | — | Start of the danger zone (absolute value). When set, renders a red arc segment and — in sport variant — turns the needle, value, and progress arc red when the value enters the zone. |
|
|
718
|
+
|
|
719
|
+
#### Behaviour
|
|
720
|
+
|
|
721
|
+
| Prop | Type | Default | Description |
|
|
722
|
+
|---|---|---|---|
|
|
723
|
+
| `animate` | `boolean` | `true` | Animate needle sweep on mount and when value changes. |
|
|
724
|
+
|
|
725
|
+
### Examples
|
|
726
|
+
|
|
727
|
+
```vue
|
|
728
|
+
<!-- Basic speedometer -->
|
|
729
|
+
<SpeedometerChart :value="120" :max="240" unit="km/h" />
|
|
730
|
+
|
|
731
|
+
<!-- Sport variant with red zone -->
|
|
732
|
+
<SpeedometerChart
|
|
733
|
+
:value="210"
|
|
734
|
+
variant="sport"
|
|
735
|
+
color="primary"
|
|
736
|
+
:max="260"
|
|
737
|
+
:major-step="20"
|
|
738
|
+
unit="km/h"
|
|
739
|
+
:red-zone-start="220"
|
|
740
|
+
label="Speed" />
|
|
741
|
+
|
|
742
|
+
<!-- Tachometer (RPM) -->
|
|
743
|
+
<SpeedometerChart
|
|
744
|
+
:value="5500"
|
|
745
|
+
:min="0" :max="8000"
|
|
746
|
+
:major-step="1000"
|
|
747
|
+
:minor-ticks="4"
|
|
748
|
+
variant="sport"
|
|
749
|
+
color="info"
|
|
750
|
+
unit="RPM"
|
|
751
|
+
:red-zone-start="6500"
|
|
752
|
+
:format-value="(v) => (v / 1000).toFixed(1)" />
|
|
753
|
+
|
|
754
|
+
<!-- Temperature gauge -->
|
|
755
|
+
<SpeedometerChart
|
|
756
|
+
:value="92"
|
|
757
|
+
:min="50" :max="130"
|
|
758
|
+
:major-step="10"
|
|
759
|
+
:minor-ticks="1"
|
|
760
|
+
variant="minimal"
|
|
761
|
+
color="warning"
|
|
762
|
+
unit="°C"
|
|
763
|
+
:red-zone-start="110"
|
|
764
|
+
:format-value="(v) => Math.round(v) + '°'" />
|
|
765
|
+
|
|
766
|
+
<!-- Fuel gauge -->
|
|
767
|
+
<SpeedometerChart
|
|
768
|
+
:value="65"
|
|
769
|
+
:min="0" :max="100"
|
|
770
|
+
:major-step="25"
|
|
771
|
+
variant="modern"
|
|
772
|
+
color="success"
|
|
773
|
+
unit="%"
|
|
774
|
+
label="Fuel Level" />
|
|
775
|
+
|
|
776
|
+
<!-- Custom colors, smaller size -->
|
|
777
|
+
<SpeedometerChart
|
|
778
|
+
:value="90"
|
|
779
|
+
color="#8b5cf6"
|
|
780
|
+
:size="180"
|
|
781
|
+
:max="200"
|
|
782
|
+
:major-step="40" />
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
---
|
|
786
|
+
|
|
787
|
+
## TimelineChart
|
|
788
|
+
|
|
789
|
+
A Gantt-style horizontal timeline chart showing task bars per person across configurable time periods. Each person occupies their own row, with focused hover states, rounded colored bars spanning from a start to end position.
|
|
790
|
+
|
|
791
|
+
### Basic Usage
|
|
792
|
+
|
|
793
|
+
```vue
|
|
794
|
+
<TimelineChart
|
|
795
|
+
:tasks="[
|
|
796
|
+
{ person: 'Caleb', task: 'UI Design', start: 0.5, end: 4.5, color: '#10b981' },
|
|
797
|
+
{ person: 'Shaw', task: 'UX Design', start: 2.5, end: 5.8, color: '#f43f5e' },
|
|
798
|
+
{ person: 'Jane', task: 'Music', start: 1.8, end: 5.5, color: '#f59e0b' },
|
|
799
|
+
]"
|
|
800
|
+
:periods="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']" />
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
### Props
|
|
804
|
+
|
|
805
|
+
| Prop | Type | Default | Description |
|
|
806
|
+
|---|---|---|---|
|
|
807
|
+
| `tasks` | `TimelineTask[]` | **required** | Array of task objects — `{ person, task, start, end, color? }` |
|
|
808
|
+
| `periods` | `string[]` | **required** | X-axis period labels (e.g. month names) |
|
|
809
|
+
| `height` | `number` | `300` | Chart height in pixels |
|
|
810
|
+
| `barRadius` | `number` | `20` | Corner radius per task bar |
|
|
811
|
+
| `showGrid` | `boolean` | `true` | Show dashed vertical grid lines |
|
|
812
|
+
| `showTooltip` | `boolean` | `true` | Floating tooltip on bar hover |
|
|
813
|
+
| `showLabels` | `boolean` | `true` | Show task name labels inside bars |
|
|
814
|
+
| `animate` | `boolean` | `true` | Grow-in animation from zero width |
|
|
815
|
+
| `colors` | `string[]` | CSS palette | Palette for tasks without explicit `color` |
|
|
816
|
+
|
|
817
|
+
### TimelineTask Interface
|
|
818
|
+
|
|
819
|
+
```ts
|
|
820
|
+
interface TimelineTask {
|
|
821
|
+
person: string // Row label (Y-axis)
|
|
822
|
+
task: string // Text inside bar
|
|
823
|
+
start: number // Start position (0-based index)
|
|
824
|
+
end: number // End position
|
|
825
|
+
color?: string // Optional CSS color
|
|
826
|
+
}
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
---
|
|
830
|
+
|
|
831
|
+
## GanttChart
|
|
832
|
+
|
|
833
|
+
A full-featured project Gantt chart with date-based positioning, task groups, progress tracking, dependency arrows, interactive dependency linking, milestones, live move/resize preview, and controlled drag-and-drop updates.
|
|
834
|
+
|
|
835
|
+
> Full reference (props, events, dates, live resize preview, dependency types, and examples): **[GanttChart.md](./gantt-chart.md)**
|
|
836
|
+
|
|
837
|
+
### Basic Usage
|
|
838
|
+
|
|
839
|
+
```vue
|
|
840
|
+
<script setup lang="ts">
|
|
841
|
+
import { ref } from 'vue'
|
|
842
|
+
import { GanttChart, formatGanttLocalDate, type GanttTask } from 'vlite3'
|
|
843
|
+
|
|
844
|
+
const tasks = ref<GanttTask[]>([
|
|
845
|
+
{ id: '1', name: 'UI Design', start: '2024-01-01', end: '2024-01-15', progress: 100, color: '#10b981' },
|
|
846
|
+
{ id: '2', name: 'UX Design', start: '2024-01-10', end: '2024-01-25', progress: 50, color: '#f43f5e', dependencies: ['1'] },
|
|
847
|
+
{ id: '3', name: 'Development', start: '2024-01-20', end: '2024-02-28', color: '#3b82f6', dependencies: ['2'] },
|
|
848
|
+
])
|
|
849
|
+
|
|
850
|
+
function onTaskUpdate(task: GanttTask, changes: { start: Date; end: Date }) {
|
|
851
|
+
tasks.value = tasks.value.map((item) =>
|
|
852
|
+
item.id === task.id
|
|
853
|
+
? {
|
|
854
|
+
...item,
|
|
855
|
+
start: formatGanttLocalDate(changes.start),
|
|
856
|
+
end: formatGanttLocalDate(changes.end),
|
|
857
|
+
}
|
|
858
|
+
: item,
|
|
859
|
+
)
|
|
860
|
+
}
|
|
861
|
+
</script>
|
|
862
|
+
|
|
863
|
+
<template>
|
|
864
|
+
<GanttChart
|
|
865
|
+
:tasks="tasks"
|
|
866
|
+
view-mode="week"
|
|
867
|
+
editable-dependencies
|
|
868
|
+
@task-update="onTaskUpdate"
|
|
869
|
+
@dependency-create="onDependencyCreate"
|
|
870
|
+
/>
|
|
871
|
+
</template>
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
### Props
|
|
875
|
+
|
|
876
|
+
| Prop | Type | Default | Description |
|
|
877
|
+
|---|---|---|---|
|
|
878
|
+
| `tasks` | `GanttTask[]` | **required** | Array of task objects |
|
|
879
|
+
| `viewMode` | `'day' \| 'week' \| 'month'` | `'week'` | Time axis granularity |
|
|
880
|
+
| `height` | `number` | `0` (auto) | Total chart height in px |
|
|
881
|
+
| `rowHeight` | `number` | `44` | Height of each task row in px |
|
|
882
|
+
| `barHeight` | `number` | `28` | Task bar height within the row |
|
|
883
|
+
| `barRadius` | `number` | `6` | Corner radius per task bar |
|
|
884
|
+
| `sidebarWidth` | `number` | `220` | Width of the left task-name sidebar in px |
|
|
885
|
+
| `showGrid` | `boolean` | `true` | Show dashed vertical grid lines |
|
|
886
|
+
| `showLabels` | `boolean` | `true` | Show task name labels inside bars |
|
|
887
|
+
| `showTooltip` | `boolean` | `true` | Enable hover tooltip |
|
|
888
|
+
| `showProgress` | `boolean` | `true` | Show progress fill inside task bars |
|
|
889
|
+
| `showDependencies` | `boolean` | `true` | Render dependency arrows between tasks |
|
|
890
|
+
| `showTodayLine` | `boolean` | `true` | Show a vertical "today" marker line |
|
|
891
|
+
| `showHeader` | `boolean` | `true` | Show the top date axis header |
|
|
892
|
+
| `animate` | `boolean` | `true` | Play an entry animation on mount |
|
|
893
|
+
| `colors` | `string[]` | CSS palette | Custom color palette for tasks |
|
|
894
|
+
| `todayColor` | `string` | `var(--color-danger)` | CSS color for the today marker |
|
|
895
|
+
| `locale` | `string` | `'en-US'` | Locale used for date labels and tooltips |
|
|
896
|
+
| `draggable` | `boolean` | `true` | Allow drag-and-drop to move/resize tasks (live preview during gesture) |
|
|
897
|
+
| `editableDependencies` | `boolean` | `false` | Opt-in dependency linking via `+` connectors (independent of `showDependencies`) |
|
|
898
|
+
| `cascadeDependencies`| `boolean` | `false` | Shift dependent tasks recursively when a task is moved (emit on release) |
|
|
899
|
+
| `zoom` | `boolean` | `true` | Enable Ctrl/Meta + wheel and pinch zoom. No zoom buttons are rendered — drive zoom from the parent via the exposed `zoomIn`/`zoomOut`/`setZoom`/`resetZoom` methods and the `zoom-change` event |
|
|
900
|
+
| `visiblePeriodCount` | `number` | Day 7 · Week 4 · Month 1.7 | Period columns that fill the viewport at zoom 1 (fractional allowed); zoom out/in to show more/fewer |
|
|
901
|
+
| `minColumnWidth` | `number` | per view | Minimum px width per column so the project never compresses to fit (Day 44, Week 96, Month 130) |
|
|
902
|
+
| `timelineStart` | `Date \| string` | earliest task | Force the timeline start (aligned to the view's period boundary) |
|
|
903
|
+
| `timelineEnd` | `Date \| string` | last task | Force the timeline end |
|
|
904
|
+
| `rangePadding` | `number` | `0` | Extra empty periods after the last task's completed boundary period |
|
|
905
|
+
| `preserveCenterDate` | `boolean` | `true` | Keep the viewport's centre date in view when switching Day / Week / Month |
|
|
906
|
+
| `collapsibleSidebar` | `boolean` | `true` | Show a collapse/expand control on the task sidebar to give the timeline more room |
|
|
907
|
+
| `defaultSidebarCollapsed` | `boolean` | `false` | Start with the sidebar collapsed |
|
|
908
|
+
|
|
909
|
+
### Events
|
|
910
|
+
|
|
911
|
+
| Event | Payload | Description |
|
|
912
|
+
|---|---|---|
|
|
913
|
+
| `task-click` | `GanttTask` | Task row or bar click |
|
|
914
|
+
| `task-hover` | `GanttTask \| null` | Hover enter / leave |
|
|
915
|
+
| `task-update` | `(task, { start, end })` | Once on release after move/resize; live bar/date preview during the gesture |
|
|
916
|
+
| `dependency-create` | `GanttDependencyCreatePayload` | Valid link request; parent must update `tasks` |
|
|
917
|
+
| `dependency-delete` | `GanttDependencyDeletePayload` | Selected link deleted; parent must update `tasks` |
|
|
918
|
+
| `zoom-change` | `GanttZoomState` | Zoom level changed (wheel or imperative) |
|
|
919
|
+
| `sidebar-toggle` | `boolean` | Task sidebar collapsed (`true`) or expanded (`false`) |
|
|
920
|
+
|
|
921
|
+
### GanttTask Interface
|
|
922
|
+
|
|
923
|
+
```ts
|
|
924
|
+
interface GanttTask {
|
|
925
|
+
id: string
|
|
926
|
+
name: string
|
|
927
|
+
start: Date | string
|
|
928
|
+
end: Date | string
|
|
929
|
+
progress?: number
|
|
930
|
+
color?: string
|
|
931
|
+
group?: string
|
|
932
|
+
/** Predecessor IDs this task is waiting on (draws arrows) */
|
|
933
|
+
dependencies?: string[]
|
|
934
|
+
/** Typed links; `related-to` never draws arrows */
|
|
935
|
+
dependencyLinks?: { taskId: string; type: 'waiting-on' | 'blocking' | 'related-to' }[]
|
|
936
|
+
milestone?: boolean
|
|
937
|
+
blocked?: boolean
|
|
938
|
+
blockedReason?: string
|
|
939
|
+
/** People shown in the tooltip: 1 → Persona, many → AvatarGroup */
|
|
940
|
+
assignees?: GanttPerson[]
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
interface GanttPerson {
|
|
944
|
+
name?: string
|
|
945
|
+
src?: string
|
|
946
|
+
alt?: string
|
|
947
|
+
fallback?: string
|
|
948
|
+
role?: string
|
|
949
|
+
presence?: 'online' | 'offline' | 'busy' | 'dnd' | 'away'
|
|
950
|
+
}
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
See [GanttChart.md](./gantt-chart.md) for dates (`formatGanttLocalDate`), live resize preview, dependency types, validation, and full controlled-state examples.
|
|
954
|
+
|
|
955
|
+
---
|
|
956
|
+
|
|
957
|
+
## SegmentBarChart
|
|
958
|
+
|
|
959
|
+
A single stacked horizontal bar showing proportional segments. Each segment represents a category with color, label, and percentage value.
|
|
960
|
+
|
|
961
|
+
### Basic Usage
|
|
962
|
+
|
|
963
|
+
```vue
|
|
964
|
+
<SegmentBarChart
|
|
965
|
+
:data="[
|
|
966
|
+
{ label: 'On the way', value: 33.3, color: '#525252' },
|
|
967
|
+
{ label: 'Unloading', value: 23.5, color: '#737373' },
|
|
968
|
+
{ label: 'Loading', value: 23.1, color: '#a3a3a3' },
|
|
969
|
+
{ label: 'Waiting', value: 20.1, color: '#d4d4d4' },
|
|
970
|
+
]" />
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
### Props
|
|
974
|
+
|
|
975
|
+
| Prop | Type | Default | Description |
|
|
976
|
+
|---|---|---|---|
|
|
977
|
+
| `data` | `ChartDataPoint[]` | **required** | Segment data — `{ label, value, color? }` |
|
|
978
|
+
| `barHeight` | `number` | `48` | Height of the stacked bar in px |
|
|
979
|
+
| `barRadius` | `number` | `8` | Corner radius for the outer bar |
|
|
980
|
+
| `showLabels` | `boolean` | `true` | Show category labels with indicator dots above the bar |
|
|
981
|
+
| `showValues` | `boolean` | `true` | Show percentage values inside each segment |
|
|
982
|
+
| `showTooltip` | `boolean` | `true` | Floating tooltip on segment hover |
|
|
983
|
+
| `animate` | `boolean` | `true` | Width expansion entry animation |
|
|
984
|
+
| `colors` | `string[]` | CSS palette | Color palette for segments without explicit `color` |
|
|
985
|
+
| `formatValue` | `(v: number, pct: number) => string` | built-in | Custom formatter for segment display |
|
|
986
|
+
|
|
987
|
+
---
|
|
988
|
+
|
|
989
|
+
## StatCardChart
|
|
990
|
+
|
|
991
|
+
A responsive grid of metric cards showing a label, large percentage value, proportional size indicator, and a trend arrow. Designed for device or category breakdowns.
|
|
992
|
+
|
|
993
|
+
### Basic Usage
|
|
994
|
+
|
|
995
|
+
```vue
|
|
996
|
+
<StatCardChart
|
|
997
|
+
:data="[
|
|
998
|
+
{ label: 'Desktop', percentage: 17, value: 23.8, trend: 'up', color: '#a3a3a3' },
|
|
999
|
+
{ label: 'Tablet', percentage: 65, value: 13.604, trend: 'down', color: '#525252' },
|
|
1000
|
+
{ label: 'Mobile', percentage: 18, value: 47.146, trend: 'up', color: '#737373' },
|
|
1001
|
+
]" />
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
### Props
|
|
1005
|
+
|
|
1006
|
+
| Prop | Type | Default | Description |
|
|
1007
|
+
|---|---|---|---|
|
|
1008
|
+
| `data` | `StatCardItem[]` | **required** | Array of card items |
|
|
1009
|
+
| `animate` | `boolean` | `true` | Staggered fade-in / slide-up entry animation |
|
|
1010
|
+
| `colors` | `string[]` | CSS palette | Color palette for items without explicit `color` |
|
|
1011
|
+
|
|
1012
|
+
### StatCardItem Interface
|
|
1013
|
+
|
|
1014
|
+
```ts
|
|
1015
|
+
interface StatCardItem {
|
|
1016
|
+
label: string // Card label (e.g. "Desktop")
|
|
1017
|
+
percentage: number // Large percentage value (e.g. 17)
|
|
1018
|
+
value: number // Bottom metric value (e.g. 23.8)
|
|
1019
|
+
trend: 'up' | 'down' // Trend arrow direction
|
|
1020
|
+
color?: string // Optional CSS color for the indicator
|
|
1021
|
+
}
|
|
1022
|
+
```
|
|
1023
|
+
|
|
1024
|
+
---
|
|
1025
|
+
|
|
1026
|
+
## WaffleChart
|
|
1027
|
+
|
|
1028
|
+
A grid of rounded cells colored proportionally to represent data. Supports single-value (progress) and multi-segment modes with staggered fill animation.
|
|
1029
|
+
|
|
1030
|
+
### Basic Usage
|
|
1031
|
+
|
|
1032
|
+
```vue
|
|
1033
|
+
<!-- Single value -->
|
|
1034
|
+
<WaffleChart :value="60" :max="100" :cell-count="30" color="primary" />
|
|
1035
|
+
|
|
1036
|
+
<!-- Multi-segment -->
|
|
1037
|
+
<WaffleChart
|
|
1038
|
+
:data="[
|
|
1039
|
+
{ label: 'Completed', value: 12, color: '#e5e5e5' },
|
|
1040
|
+
{ label: 'In Progress', value: 4, color: '#d4d4d4' },
|
|
1041
|
+
{ label: 'Remaining', value: 14, color: '#525252' },
|
|
1042
|
+
]"
|
|
1043
|
+
:cell-count="30" />
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
### Props
|
|
1047
|
+
|
|
1048
|
+
| Prop | Type | Default | Description |
|
|
1049
|
+
|---|---|---|---|
|
|
1050
|
+
| `value` | `number` | — | Current value (single-segment mode) |
|
|
1051
|
+
| `max` | `number` | `100` | Maximum value (single-segment mode) |
|
|
1052
|
+
| `data` | `ChartDataPoint[]` | — | Multi-segment data — each item fills proportionally |
|
|
1053
|
+
| `cellCount` | `number` | `30` | Total number of cells in the grid |
|
|
1054
|
+
| `columns` | `number` | auto | Number of cells per row (defaults to `cellCount` for a single row) |
|
|
1055
|
+
| `cellRadius` | `number` | `6` | Corner radius per cell |
|
|
1056
|
+
| `cellGap` | `number` | `4` | Gap between cells in px |
|
|
1057
|
+
| `color` | `ChartColor` | `'primary'` | Color for filled cells (single-segment mode) |
|
|
1058
|
+
| `colors` | `string[]` | CSS palette | Color palette for multi-segment mode |
|
|
1059
|
+
| `trackColor` | `string` | `var(--color-muted)` | Background color for unfilled cells |
|
|
1060
|
+
| `animate` | `boolean` | `true` | Staggered fill animation on mount |
|
|
1061
|
+
| `showTooltip` | `boolean` | `true` | Floating tooltip on cell hover |
|
|
1062
|
+
|
|
1063
|
+
---
|
|
1064
|
+
|
|
1065
|
+
## Advanced Patterns
|
|
1066
|
+
|
|
1067
|
+
### Sparkline (no chrome)
|
|
1068
|
+
|
|
1069
|
+
A minimal, chromeless line that works well as a KPI trend indicator inside a card.
|
|
1070
|
+
|
|
1071
|
+
```vue
|
|
1072
|
+
<LineChart
|
|
1073
|
+
:data="weeklyData"
|
|
1074
|
+
:height="60"
|
|
1075
|
+
:smooth="true"
|
|
1076
|
+
:fill="true"
|
|
1077
|
+
:show-dots="false"
|
|
1078
|
+
:show-grid="false"
|
|
1079
|
+
:show-x-axis="false"
|
|
1080
|
+
:show-y-axis="false"
|
|
1081
|
+
:show-x-labels="false"
|
|
1082
|
+
:show-y-labels="false"
|
|
1083
|
+
:show-tooltip="false"
|
|
1084
|
+
:show-legend="false"
|
|
1085
|
+
:animate="false"
|
|
1086
|
+
:colors="['var(--color-success)']" />
|
|
1087
|
+
```
|
|
1088
|
+
|
|
1089
|
+
### Embedded widget — stripped axes
|
|
1090
|
+
|
|
1091
|
+
Charts inside compact cards often look better without axis chrome. Padding collapses automatically when labels are hidden.
|
|
1092
|
+
|
|
1093
|
+
```vue
|
|
1094
|
+
<LineChart
|
|
1095
|
+
:data="data"
|
|
1096
|
+
:height="120"
|
|
1097
|
+
:show-x-labels="false"
|
|
1098
|
+
:show-y-labels="false"
|
|
1099
|
+
:show-x-axis="false"
|
|
1100
|
+
:show-y-axis="false"
|
|
1101
|
+
:grid-opacity="0.05"
|
|
1102
|
+
:line-width="2" />
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
### Custom value formatter (currency)
|
|
1106
|
+
|
|
1107
|
+
```vue
|
|
1108
|
+
<LineChart
|
|
1109
|
+
:data="revenueData"
|
|
1110
|
+
:format-value="(v) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', notation: 'compact' }).format(v)" />
|
|
1111
|
+
```
|
|
1112
|
+
|
|
1113
|
+
### Reactive data updates
|
|
1114
|
+
|
|
1115
|
+
All charts re-animate when their `data` or `datasets` prop changes — just update your reactive ref:
|
|
1116
|
+
|
|
1117
|
+
```vue
|
|
1118
|
+
<script setup lang="ts">
|
|
1119
|
+
import { ref } from 'vue'
|
|
1120
|
+
const data = ref([
|
|
1121
|
+
{ label: 'Jan', value: 4200 },
|
|
1122
|
+
{ label: 'Feb', value: 5800 },
|
|
1123
|
+
])
|
|
1124
|
+
function refresh() {
|
|
1125
|
+
data.value = data.value.map(d => ({ ...d, value: Math.random() * 10000 }))
|
|
1126
|
+
}
|
|
1127
|
+
</script>
|
|
1128
|
+
|
|
1129
|
+
<template>
|
|
1130
|
+
<button @click="refresh">Refresh</button>
|
|
1131
|
+
<LineChart :data="data" />
|
|
1132
|
+
</template>
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
### Multi-series line chart
|
|
1136
|
+
|
|
1137
|
+
```vue
|
|
1138
|
+
<script setup lang="ts">
|
|
1139
|
+
const labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul']
|
|
1140
|
+
const datasets = [
|
|
1141
|
+
{ label: 'Revenue', data: [4200, 5800, 5200, 7100, 6800, 9400, 8200] },
|
|
1142
|
+
{ label: 'Expenses', data: [3100, 3400, 2900, 4200, 3800, 5100, 4600] },
|
|
1143
|
+
{ label: 'Profit', data: [1100, 2400, 2300, 2900, 3000, 4300, 3600] },
|
|
1144
|
+
]
|
|
1145
|
+
</script>
|
|
1146
|
+
|
|
1147
|
+
<template>
|
|
1148
|
+
<LineChart
|
|
1149
|
+
:datasets="datasets"
|
|
1150
|
+
:labels="labels"
|
|
1151
|
+
:height="280"
|
|
1152
|
+
:fill="false"
|
|
1153
|
+
:format-value="(v) => '$' + v.toLocaleString()" />
|
|
1154
|
+
</template>
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
### Donut KPI row
|
|
1158
|
+
|
|
1159
|
+
A common dashboard pattern — small donut rings side-by-side inside cards.
|
|
1160
|
+
|
|
1161
|
+
```vue
|
|
1162
|
+
<div class="grid grid-cols-4 gap-4">
|
|
1163
|
+
<div v-for="kpi in kpis" :key="kpi.label" class="bg-card border rounded-xl p-4 flex items-center gap-3">
|
|
1164
|
+
<CircleChart
|
|
1165
|
+
:value="kpi.value"
|
|
1166
|
+
:size="56"
|
|
1167
|
+
:stroke-width="5"
|
|
1168
|
+
:color="kpi.color"
|
|
1169
|
+
:show-value="true"
|
|
1170
|
+
:animate="true" />
|
|
1171
|
+
<div>
|
|
1172
|
+
<p class="text-xs text-muted-foreground">{{ kpi.label }}</p>
|
|
1173
|
+
<p class="font-bold">{{ kpi.display }}</p>
|
|
1174
|
+
</div>
|
|
1175
|
+
</div>
|
|
1176
|
+
</div>
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
---
|
|
1180
|
+
|
|
1181
|
+
## How Animations Work
|
|
1182
|
+
|
|
1183
|
+
All chart animations use `requestAnimationFrame` with an **ease-out cubic** easing function:
|
|
1184
|
+
|
|
1185
|
+
```
|
|
1186
|
+
eased = 1 - (1 - t)³
|
|
1187
|
+
```
|
|
1188
|
+
|
|
1189
|
+
- **LineChart** — clips a `<clipPath>` rect from left to right over 900ms
|
|
1190
|
+
- **BarChart** — grows bars from the baseline via a `progress` multiplier on bar height over 800ms
|
|
1191
|
+
- **PieChart** — sweeps the arc angle from 0 to the full value over 1000ms
|
|
1192
|
+
- **CircleChart** — interpolates the `stroke-dashoffset` from 0 to the target over 1000ms
|
|
1193
|
+
|
|
1194
|
+
Setting `:animate="false"` skips to the final state immediately — useful for server-side rendering, reduced-motion preferences, or snapshot tests.
|
|
1195
|
+
|
|
1196
|
+
---
|
|
1197
|
+
|
|
1198
|
+
## Padding & Layout System
|
|
1199
|
+
|
|
1200
|
+
LineChart and BarChart compute internal padding dynamically based on what is rendered:
|
|
1201
|
+
|
|
1202
|
+
| Side | When increased | When collapsed |
|
|
1203
|
+
|---|---|---|
|
|
1204
|
+
| `left` | Y tick labels visible → measured text width + 12px (min 24px) | Y labels hidden → 8px |
|
|
1205
|
+
| `bottom` | X tick labels visible → 24px | X labels hidden → 6px |
|
|
1206
|
+
| `left` (horizontal bar) | Bar name labels visible → measured text width | Bar names hidden → 8px |
|
|
1207
|
+
| `top` (horizontal bar) | Value ticks visible → 16px | Value ticks hidden → 4px |
|
|
1208
|
+
|
|
1209
|
+
There is also an additional `+20px` added to `left` when a `yLabel` (Y axis title) is provided.
|
|
1210
|
+
|
|
1211
|
+
This means **hiding labels is completely lossless** — the chart drawing area expands to use the freed space with no manual padding adjustments needed.
|
|
1212
|
+
|
|
1213
|
+
---
|
|
1214
|
+
|
|
1215
|
+
## CSS Variables Reference
|
|
1216
|
+
|
|
1217
|
+
You can override any of these in your global stylesheet or a scoped `:root` block:
|
|
1218
|
+
|
|
1219
|
+
```css
|
|
1220
|
+
:root {
|
|
1221
|
+
/* Chart series colors */
|
|
1222
|
+
--color-chart-1: #6366f1;
|
|
1223
|
+
--color-chart-2: #22c55e;
|
|
1224
|
+
--color-chart-3: #f59e0b;
|
|
1225
|
+
--color-chart-4: #ef4444;
|
|
1226
|
+
--color-chart-5: #3b82f6;
|
|
1227
|
+
--color-chart-6: #ec4899;
|
|
1228
|
+
|
|
1229
|
+
/* Semantic UI colors used by charts */
|
|
1230
|
+
--color-primary: hsl(239 84% 67%);
|
|
1231
|
+
--color-success: hsl(142 71% 45%);
|
|
1232
|
+
--color-warning: hsl(38 92% 50%);
|
|
1233
|
+
--color-danger: hsl(0 84% 60%);
|
|
1234
|
+
--color-info: hsl(199 89% 48%);
|
|
1235
|
+
|
|
1236
|
+
/* Surface colors */
|
|
1237
|
+
--color-background: #ffffff;
|
|
1238
|
+
--color-muted: #f4f4f5;
|
|
1239
|
+
--color-muted-foreground: #71717a;
|
|
1240
|
+
--color-foreground: #09090b;
|
|
1241
|
+
--color-border: #e4e4e7;
|
|
1242
|
+
}
|
|
1243
|
+
```
|
|
1244
|
+
|
|
1245
|
+
---
|
|
1246
|
+
|
|
1247
|
+
## TypeScript — Full Interface Reference
|
|
1248
|
+
|
|
1249
|
+
```ts
|
|
1250
|
+
// ─── Shared ────────────────────────────────────
|
|
1251
|
+
|
|
1252
|
+
interface ChartDataPoint {
|
|
1253
|
+
label: string
|
|
1254
|
+
value: number
|
|
1255
|
+
color?: string
|
|
1256
|
+
[key: string]: any
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
interface ChartDataset {
|
|
1260
|
+
label: string
|
|
1261
|
+
data: number[]
|
|
1262
|
+
color?: string
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
type ChartColor =
|
|
1266
|
+
| 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
|
1267
|
+
| 'purple' | 'teal' | 'orange' | 'pink' | 'cyan'
|
|
1268
|
+
| string
|
|
1269
|
+
|
|
1270
|
+
type PieLabelMode = 'percent' | 'value' | 'label' | 'none'
|
|
1271
|
+
type LegendPosition = 'right' | 'bottom'
|
|
1272
|
+
type StrokeLineCap = 'round' | 'square' | 'butt'
|
|
1273
|
+
|
|
1274
|
+
// ─── LineChart ─────────────────────────────────
|
|
1275
|
+
|
|
1276
|
+
interface LineChartProps {
|
|
1277
|
+
data?: ChartDataPoint[]
|
|
1278
|
+
datasets?: ChartDataset[]
|
|
1279
|
+
labels?: string[]
|
|
1280
|
+
height?: number // default: 300
|
|
1281
|
+
smooth?: boolean // default: true
|
|
1282
|
+
fill?: boolean // default: true
|
|
1283
|
+
showDots?: boolean // default: true
|
|
1284
|
+
showGrid?: boolean // default: true
|
|
1285
|
+
showLegend?: boolean // default: true
|
|
1286
|
+
showTooltip?: boolean // default: true
|
|
1287
|
+
colors?: string[] // default: CSS palette
|
|
1288
|
+
animate?: boolean // default: true
|
|
1289
|
+
xLabel?: string
|
|
1290
|
+
yLabel?: string
|
|
1291
|
+
formatValue?: (v: number) => string
|
|
1292
|
+
yMin?: number
|
|
1293
|
+
yMax?: number
|
|
1294
|
+
showXAxis?: boolean // default: true
|
|
1295
|
+
showYAxis?: boolean // default: true
|
|
1296
|
+
showXLabels?: boolean // default: true
|
|
1297
|
+
showYLabels?: boolean // default: true
|
|
1298
|
+
gridOpacity?: number // default: 0.07
|
|
1299
|
+
axisOpacity?: number // default: 0.1
|
|
1300
|
+
lineWidth?: number // default: 2.5
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// ─── BarChart ──────────────────────────────────
|
|
1304
|
+
|
|
1305
|
+
interface BarChartProps {
|
|
1306
|
+
data?: ChartDataPoint[]
|
|
1307
|
+
datasets?: ChartDataset[]
|
|
1308
|
+
labels?: string[]
|
|
1309
|
+
height?: number // default: 300
|
|
1310
|
+
orientation?: 'vertical' | 'horizontal' // default: 'vertical'
|
|
1311
|
+
barRadius?: number // default: 6
|
|
1312
|
+
showGrid?: boolean // default: true
|
|
1313
|
+
showLegend?: boolean // default: true
|
|
1314
|
+
showTooltip?: boolean // default: true
|
|
1315
|
+
showValues?: boolean // default: false
|
|
1316
|
+
colors?: string[] // default: CSS palette
|
|
1317
|
+
animate?: boolean // default: true
|
|
1318
|
+
formatValue?: (v: number) => string
|
|
1319
|
+
showXAxis?: boolean // default: true
|
|
1320
|
+
showYAxis?: boolean // default: true
|
|
1321
|
+
showXLabels?: boolean // default: true
|
|
1322
|
+
showYLabels?: boolean // default: true
|
|
1323
|
+
gridOpacity?: number // default: 0.07
|
|
1324
|
+
axisOpacity?: number // default: 0.1
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
// ─── PieChart ──────────────────────────────────
|
|
1328
|
+
|
|
1329
|
+
interface PieChartProps {
|
|
1330
|
+
data: ChartDataPoint[] // required
|
|
1331
|
+
donut?: boolean // default: false
|
|
1332
|
+
innerRadius?: number // default: 60 (% of outer radius)
|
|
1333
|
+
size?: number // default: 280
|
|
1334
|
+
startAngle?: number // default: -90
|
|
1335
|
+
showLegend?: boolean // default: true
|
|
1336
|
+
legendPosition?: LegendPosition // default: 'right'
|
|
1337
|
+
labelMode?: PieLabelMode // default: 'percent'
|
|
1338
|
+
colors?: string[] // default: CSS palette
|
|
1339
|
+
animate?: boolean // default: true
|
|
1340
|
+
showTooltip?: boolean // default: true
|
|
1341
|
+
centerLabel?: string
|
|
1342
|
+
centerValue?: string
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// ─── CircleChart ───────────────────────────────
|
|
1346
|
+
|
|
1347
|
+
interface CircleChartProps {
|
|
1348
|
+
value: number // required
|
|
1349
|
+
max?: number // default: 100
|
|
1350
|
+
size?: number // default: 160
|
|
1351
|
+
strokeWidth?: number // default: 12
|
|
1352
|
+
color?: ChartColor // default: 'primary'
|
|
1353
|
+
gradient?: boolean // default: true
|
|
1354
|
+
label?: string
|
|
1355
|
+
sublabel?: string
|
|
1356
|
+
showValue?: boolean // default: true
|
|
1357
|
+
formatValue?: (v: number, pct: number) => string
|
|
1358
|
+
animate?: boolean // default: true
|
|
1359
|
+
trackColor?: string // default: var(--color-muted)
|
|
1360
|
+
lineCap?: StrokeLineCap // default: 'round'
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
// ─── TimelineChart ─────────────────────────────
|
|
1364
|
+
|
|
1365
|
+
// ─── SpeedometerChart ─────────────────────────
|
|
1366
|
+
|
|
1367
|
+
type SpeedometerVariant = 'classic' | 'modern' | 'sport' | 'minimal'
|
|
1368
|
+
|
|
1369
|
+
interface SpeedometerChartProps {
|
|
1370
|
+
value: number // required
|
|
1371
|
+
min?: number // default: 0
|
|
1372
|
+
max?: number // default: 240
|
|
1373
|
+
variant?: SpeedometerVariant // default: 'classic'
|
|
1374
|
+
size?: number // default: 280
|
|
1375
|
+
gapAngle?: number // default: 60
|
|
1376
|
+
color?: ChartColor // default: 'primary'
|
|
1377
|
+
needleColor?: string
|
|
1378
|
+
majorStep?: number // default: 20
|
|
1379
|
+
minorTicks?: number // default: 4
|
|
1380
|
+
unit?: string // default: 'km/h'
|
|
1381
|
+
showValue?: boolean // default: true
|
|
1382
|
+
formatValue?: (v: number) => string
|
|
1383
|
+
label?: string
|
|
1384
|
+
redZoneStart?: number
|
|
1385
|
+
animate?: boolean // default: true
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
// ─── TimelineChart ─────────────────────────────
|
|
1389
|
+
|
|
1390
|
+
interface TimelineTask {
|
|
1391
|
+
person: string
|
|
1392
|
+
task: string
|
|
1393
|
+
start: number
|
|
1394
|
+
end: number
|
|
1395
|
+
color?: string
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
interface TimelineChartProps {
|
|
1399
|
+
tasks: TimelineTask[] // required
|
|
1400
|
+
periods: string[] // required
|
|
1401
|
+
height?: number // default: 300
|
|
1402
|
+
barRadius?: number // default: 20
|
|
1403
|
+
showGrid?: boolean // default: true
|
|
1404
|
+
showTooltip?: boolean // default: true
|
|
1405
|
+
showLabels?: boolean // default: true
|
|
1406
|
+
animate?: boolean // default: true
|
|
1407
|
+
colors?: string[] // default: CSS palette
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
// ─── SegmentBarChart ───────────────────────────
|
|
1411
|
+
|
|
1412
|
+
interface SegmentBarChartProps {
|
|
1413
|
+
data: ChartDataPoint[] // required
|
|
1414
|
+
barHeight?: number // default: 48
|
|
1415
|
+
barRadius?: number // default: 8
|
|
1416
|
+
showLabels?: boolean // default: true
|
|
1417
|
+
showValues?: boolean // default: true
|
|
1418
|
+
showTooltip?: boolean // default: true
|
|
1419
|
+
animate?: boolean // default: true
|
|
1420
|
+
colors?: string[] // default: CSS palette
|
|
1421
|
+
formatValue?: (v: number, pct: number) => string
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
// ─── StatCardChart ─────────────────────────────
|
|
1425
|
+
|
|
1426
|
+
interface StatCardItem {
|
|
1427
|
+
label: string
|
|
1428
|
+
percentage: number
|
|
1429
|
+
value: number
|
|
1430
|
+
trend: 'up' | 'down'
|
|
1431
|
+
color?: string
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
interface StatCardChartProps {
|
|
1435
|
+
data: StatCardItem[] // required
|
|
1436
|
+
animate?: boolean // default: true
|
|
1437
|
+
colors?: string[] // default: CSS palette
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
// ─── WaffleChart ───────────────────────────────
|
|
1441
|
+
|
|
1442
|
+
interface WaffleChartProps {
|
|
1443
|
+
value?: number
|
|
1444
|
+
max?: number // default: 100
|
|
1445
|
+
data?: ChartDataPoint[]
|
|
1446
|
+
cellCount?: number // default: 30
|
|
1447
|
+
columns?: number // default: cellCount (single row)
|
|
1448
|
+
cellRadius?: number // default: 6
|
|
1449
|
+
cellGap?: number // default: 4
|
|
1450
|
+
color?: ChartColor // default: 'primary'
|
|
1451
|
+
colors?: string[] // default: CSS palette
|
|
1452
|
+
trackColor?: string // default: var(--color-muted)
|
|
1453
|
+
animate?: boolean // default: true
|
|
1454
|
+
showTooltip?: boolean // default: true
|
|
1455
|
+
}
|
|
1456
|
+
```
|