snice 4.8.0 → 4.9.0
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/adapters/react/camera-annotate.d.ts +27 -0
- package/adapters/react/camera-annotate.d.ts.map +1 -0
- package/adapters/react/camera-annotate.js +24 -0
- package/adapters/react/camera-annotate.js.map +1 -0
- package/adapters/react/camera-annotate.tsx +35 -0
- package/adapters/react/candlestick.d.ts +34 -0
- package/adapters/react/candlestick.d.ts.map +1 -0
- package/adapters/react/candlestick.js +24 -0
- package/adapters/react/candlestick.js.map +1 -0
- package/adapters/react/candlestick.tsx +42 -0
- package/adapters/react/components.d.ts +14 -0
- package/adapters/react/components.d.ts.map +1 -1
- package/adapters/react/components.js +7 -0
- package/adapters/react/components.js.map +1 -1
- package/adapters/react/components.ts +14 -0
- package/adapters/react/funnel.d.ts +31 -0
- package/adapters/react/funnel.d.ts.map +1 -0
- package/adapters/react/funnel.js +24 -0
- package/adapters/react/funnel.js.map +1 -0
- package/adapters/react/funnel.tsx +39 -0
- package/adapters/react/network-graph.d.ts +32 -0
- package/adapters/react/network-graph.d.ts.map +1 -0
- package/adapters/react/network-graph.js +24 -0
- package/adapters/react/network-graph.js.map +1 -0
- package/adapters/react/network-graph.tsx +40 -0
- package/adapters/react/sankey.d.ts +31 -0
- package/adapters/react/sankey.d.ts.map +1 -0
- package/adapters/react/sankey.js +24 -0
- package/adapters/react/sankey.js.map +1 -0
- package/adapters/react/sankey.tsx +39 -0
- package/adapters/react/time-range-picker.d.ts +33 -0
- package/adapters/react/time-range-picker.d.ts.map +1 -0
- package/adapters/react/time-range-picker.js +24 -0
- package/adapters/react/time-range-picker.js.map +1 -0
- package/adapters/react/time-range-picker.tsx +41 -0
- package/adapters/react/treemap.d.ts +30 -0
- package/adapters/react/treemap.d.ts.map +1 -0
- package/adapters/react/treemap.js +24 -0
- package/adapters/react/treemap.js.map +1 -0
- package/adapters/react/treemap.tsx +38 -0
- package/adapters/react/virtual-scroller.d.ts +1 -0
- package/adapters/react/virtual-scroller.d.ts.map +1 -1
- package/adapters/react/virtual-scroller.js +1 -1
- package/adapters/react/virtual-scroller.js.map +1 -1
- package/adapters/react/virtual-scroller.tsx +2 -1
- package/dist/cdn/accordion/snice-accordion.js +1 -1
- package/dist/cdn/accordion/snice-accordion.min.js +1 -1
- package/dist/cdn/alert/snice-alert.js +1 -1
- package/dist/cdn/alert/snice-alert.min.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.min.js +1 -1
- package/dist/cdn/avatar/snice-avatar.js +1 -1
- package/dist/cdn/avatar/snice-avatar.min.js +1 -1
- package/dist/cdn/badge/snice-badge.js +1 -1
- package/dist/cdn/badge/snice-badge.min.js +1 -1
- package/dist/cdn/banner/snice-banner.js +1 -1
- package/dist/cdn/banner/snice-banner.min.js +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +2 -2
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.js.map +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.min.js +13 -13
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.min.js.map +1 -1
- package/dist/cdn/button/snice-button.js +1 -1
- package/dist/cdn/button/snice-button.min.js +1 -1
- package/dist/cdn/calendar/snice-calendar.js +1 -1
- package/dist/cdn/calendar/snice-calendar.min.js +1 -1
- package/dist/cdn/camera/snice-camera.js +1 -1
- package/dist/cdn/camera/snice-camera.min.js +1 -1
- package/dist/cdn/camera-annotate/README.md +27 -0
- package/dist/cdn/camera-annotate/snice-camera-annotate.js +730 -0
- package/dist/cdn/camera-annotate/snice-camera-annotate.js.map +1 -0
- package/dist/cdn/camera-annotate/snice-camera-annotate.min.js +144 -0
- package/dist/cdn/camera-annotate/snice-camera-annotate.min.js.map +1 -0
- package/dist/cdn/candlestick/README.md +27 -0
- package/dist/cdn/candlestick/snice-candlestick.js +717 -0
- package/dist/cdn/candlestick/snice-candlestick.js.map +1 -0
- package/dist/cdn/candlestick/snice-candlestick.min.js +22 -0
- package/dist/cdn/candlestick/snice-candlestick.min.js.map +1 -0
- package/dist/cdn/card/snice-card.js +1 -1
- package/dist/cdn/card/snice-card.min.js +1 -1
- package/dist/cdn/carousel/snice-carousel.js +1 -1
- package/dist/cdn/carousel/snice-carousel.min.js +1 -1
- package/dist/cdn/chart/snice-chart.js +1 -1
- package/dist/cdn/chart/snice-chart.min.js +1 -1
- package/dist/cdn/chat/snice-chat.js +1 -1
- package/dist/cdn/chat/snice-chat.min.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.min.js +1 -1
- package/dist/cdn/chip/snice-chip.js +1 -1
- package/dist/cdn/chip/snice-chip.min.js +1 -1
- package/dist/cdn/code-block/snice-code-block.js +1 -1
- package/dist/cdn/code-block/snice-code-block.min.js +1 -1
- package/dist/cdn/color-display/snice-color-display.js +1 -1
- package/dist/cdn/color-display/snice-color-display.min.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.min.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.min.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.min.js +1 -1
- package/dist/cdn/divider/snice-divider.js +1 -1
- package/dist/cdn/divider/snice-divider.min.js +1 -1
- package/dist/cdn/doc/snice-doc.js +1 -1
- package/dist/cdn/doc/snice-doc.min.js +1 -1
- package/dist/cdn/draw/snice-draw.js +1 -1
- package/dist/cdn/draw/snice-draw.min.js +1 -1
- package/dist/cdn/drawer/snice-drawer.js +1 -1
- package/dist/cdn/drawer/snice-drawer.min.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.min.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.min.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.min.js +1 -1
- package/dist/cdn/funnel/README.md +27 -0
- package/dist/cdn/funnel/snice-funnel.js +424 -0
- package/dist/cdn/funnel/snice-funnel.js.map +1 -0
- package/dist/cdn/funnel/snice-funnel.min.js +20 -0
- package/dist/cdn/funnel/snice-funnel.min.js.map +1 -0
- package/dist/cdn/gauge/snice-gauge.js +1 -1
- package/dist/cdn/gauge/snice-gauge.min.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.min.js +1 -1
- package/dist/cdn/image/snice-image.js +1 -1
- package/dist/cdn/image/snice-image.min.js +1 -1
- package/dist/cdn/input/snice-input.js +1 -1
- package/dist/cdn/input/snice-input.min.js +1 -1
- package/dist/cdn/kanban/snice-kanban.js +1 -1
- package/dist/cdn/kanban/snice-kanban.min.js +1 -1
- package/dist/cdn/kpi/snice-kpi.js +1 -1
- package/dist/cdn/kpi/snice-kpi.min.js +1 -1
- package/dist/cdn/layout/README.md +2 -2
- package/dist/cdn/layout/snice-layout.js +23 -6
- package/dist/cdn/layout/snice-layout.js.map +1 -1
- package/dist/cdn/layout/snice-layout.min.js +2 -2
- package/dist/cdn/layout/snice-layout.min.js.map +1 -1
- package/dist/cdn/link/snice-link.js +1 -1
- package/dist/cdn/link/snice-link.min.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.min.js +1 -1
- package/dist/cdn/list/README.md +6 -2
- package/dist/cdn/list/snice-list.js +87 -10
- package/dist/cdn/list/snice-list.js.map +1 -1
- package/dist/cdn/list/snice-list.min.js +20 -6
- package/dist/cdn/list/snice-list.min.js.map +1 -1
- package/dist/cdn/location/snice-location.js +1 -1
- package/dist/cdn/location/snice-location.min.js +1 -1
- package/dist/cdn/login/snice-login.js +1 -1
- package/dist/cdn/login/snice-login.min.js +1 -1
- package/dist/cdn/masonry/snice-masonry.js +1 -1
- package/dist/cdn/masonry/snice-masonry.min.js +1 -1
- package/dist/cdn/menu/snice-menu.js +1 -1
- package/dist/cdn/menu/snice-menu.min.js +1 -1
- package/dist/cdn/modal/snice-modal.js +1 -1
- package/dist/cdn/modal/snice-modal.min.js +1 -1
- package/dist/cdn/music-player/snice-music-player.js +1 -1
- package/dist/cdn/music-player/snice-music-player.min.js +1 -1
- package/dist/cdn/nav/README.md +2 -2
- package/dist/cdn/nav/snice-nav.js +23 -6
- package/dist/cdn/nav/snice-nav.js.map +1 -1
- package/dist/cdn/nav/snice-nav.min.js +2 -2
- package/dist/cdn/nav/snice-nav.min.js.map +1 -1
- package/dist/cdn/network-graph/README.md +27 -0
- package/dist/cdn/network-graph/snice-network-graph.js +788 -0
- package/dist/cdn/network-graph/snice-network-graph.js.map +1 -0
- package/dist/cdn/network-graph/snice-network-graph.min.js +13 -0
- package/dist/cdn/network-graph/snice-network-graph.min.js.map +1 -0
- package/dist/cdn/pagination/README.md +2 -2
- package/dist/cdn/pagination/snice-pagination.js +13 -13
- package/dist/cdn/pagination/snice-pagination.js.map +1 -1
- package/dist/cdn/pagination/snice-pagination.min.js +14 -14
- package/dist/cdn/pagination/snice-pagination.min.js.map +1 -1
- package/dist/cdn/paint/snice-paint.js +1 -1
- package/dist/cdn/paint/snice-paint.min.js +1 -1
- package/dist/cdn/progress/snice-progress.js +1 -1
- package/dist/cdn/progress/snice-progress.min.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.min.js +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.min.js +1 -1
- package/dist/cdn/radio/snice-radio.js +1 -1
- package/dist/cdn/radio/snice-radio.min.js +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.js +3 -3
- package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js +3 -3
- package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.js +3 -3
- package/dist/cdn/runtime/snice-runtime.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js +3 -3
- package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
- package/dist/cdn/sankey/README.md +27 -0
- package/dist/cdn/sankey/snice-sankey.js +679 -0
- package/dist/cdn/sankey/snice-sankey.js.map +1 -0
- package/dist/cdn/sankey/snice-sankey.min.js +21 -0
- package/dist/cdn/sankey/snice-sankey.min.js.map +1 -0
- package/dist/cdn/select/snice-select.js +1 -1
- package/dist/cdn/select/snice-select.min.js +1 -1
- package/dist/cdn/skeleton/snice-skeleton.js +1 -1
- package/dist/cdn/skeleton/snice-skeleton.min.js +1 -1
- package/dist/cdn/slider/snice-slider.js +1 -1
- package/dist/cdn/slider/snice-slider.min.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.min.js +1 -1
- package/dist/cdn/spinner/snice-spinner.js +1 -1
- package/dist/cdn/spinner/snice-spinner.min.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.min.js +1 -1
- package/dist/cdn/stepper/README.md +6 -2
- package/dist/cdn/stepper/snice-stepper.js +77 -10
- package/dist/cdn/stepper/snice-stepper.js.map +1 -1
- package/dist/cdn/stepper/snice-stepper.min.js +13 -9
- package/dist/cdn/stepper/snice-stepper.min.js.map +1 -1
- package/dist/cdn/switch/snice-switch.js +1 -1
- package/dist/cdn/switch/snice-switch.min.js +1 -1
- package/dist/cdn/table/snice-table.js +1 -1
- package/dist/cdn/table/snice-table.min.js +1 -1
- package/dist/cdn/tabs/snice-tabs.js +1 -1
- package/dist/cdn/tabs/snice-tabs.min.js +1 -1
- package/dist/cdn/terminal/snice-terminal.js +1 -1
- package/dist/cdn/terminal/snice-terminal.min.js +1 -1
- package/dist/cdn/textarea/snice-textarea.js +1 -1
- package/dist/cdn/textarea/snice-textarea.min.js +1 -1
- package/dist/cdn/time-range-picker/README.md +27 -0
- package/dist/cdn/time-range-picker/snice-time-range-picker.js +635 -0
- package/dist/cdn/time-range-picker/snice-time-range-picker.js.map +1 -0
- package/dist/cdn/time-range-picker/snice-time-range-picker.min.js +34 -0
- package/dist/cdn/time-range-picker/snice-time-range-picker.min.js.map +1 -0
- package/dist/cdn/timeline/snice-timeline.js +1 -1
- package/dist/cdn/timeline/snice-timeline.min.js +1 -1
- package/dist/cdn/timer/snice-timer.js +1 -1
- package/dist/cdn/timer/snice-timer.min.js +1 -1
- package/dist/cdn/toast/snice-toast.js +1 -1
- package/dist/cdn/toast/snice-toast.min.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.min.js +1 -1
- package/dist/cdn/tree/README.md +5 -1
- package/dist/cdn/tree/snice-tree.js +4 -8
- package/dist/cdn/tree/snice-tree.js.map +1 -1
- package/dist/cdn/tree/snice-tree.min.js +5 -5
- package/dist/cdn/tree/snice-tree.min.js.map +1 -1
- package/dist/cdn/treemap/README.md +27 -0
- package/dist/cdn/treemap/snice-treemap.js +522 -0
- package/dist/cdn/treemap/snice-treemap.js.map +1 -0
- package/dist/cdn/treemap/snice-treemap.min.js +14 -0
- package/dist/cdn/treemap/snice-treemap.min.js.map +1 -0
- package/dist/cdn/virtual-scroller/README.md +2 -2
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +47 -16
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.js.map +1 -1
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.min.js +9 -9
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.min.js.map +1 -1
- package/dist/components/breadcrumbs/snice-breadcrumbs.js +1 -1
- package/dist/components/breadcrumbs/snice-breadcrumbs.js.map +1 -1
- package/dist/components/camera-annotate/snice-camera-annotate.d.ts +68 -0
- package/dist/components/camera-annotate/snice-camera-annotate.js +663 -0
- package/dist/components/camera-annotate/snice-camera-annotate.js.map +1 -0
- package/dist/components/camera-annotate/snice-camera-annotate.types.d.ts +50 -0
- package/dist/components/candlestick/snice-candlestick.d.ts +78 -0
- package/dist/components/candlestick/snice-candlestick.js +650 -0
- package/dist/components/candlestick/snice-candlestick.js.map +1 -0
- package/dist/components/candlestick/snice-candlestick.types.d.ts +40 -0
- package/dist/components/funnel/snice-funnel.d.ts +37 -0
- package/dist/components/funnel/snice-funnel.js +357 -0
- package/dist/components/funnel/snice-funnel.js.map +1 -0
- package/dist/components/funnel/snice-funnel.types.d.ts +28 -0
- package/dist/components/list/snice-list-item.d.ts +2 -0
- package/dist/components/list/snice-list-item.js +20 -2
- package/dist/components/list/snice-list-item.js.map +1 -1
- package/dist/components/nav/snice-nav.js +22 -5
- package/dist/components/nav/snice-nav.js.map +1 -1
- package/dist/components/network-graph/snice-network-graph.d.ts +80 -0
- package/dist/components/network-graph/snice-network-graph.js +721 -0
- package/dist/components/network-graph/snice-network-graph.js.map +1 -0
- package/dist/components/network-graph/snice-network-graph.types.d.ts +49 -0
- package/dist/components/pagination/snice-pagination.js +12 -12
- package/dist/components/sankey/snice-sankey.d.ts +46 -0
- package/dist/components/sankey/snice-sankey.js +612 -0
- package/dist/components/sankey/snice-sankey.js.map +1 -0
- package/dist/components/sankey/snice-sankey.types.d.ts +59 -0
- package/dist/components/stepper/snice-stepper.js +9 -3
- package/dist/components/stepper/snice-stepper.js.map +1 -1
- package/dist/components/time-range-picker/snice-time-range-picker.d.ts +67 -0
- package/dist/components/time-range-picker/snice-time-range-picker.js +568 -0
- package/dist/components/time-range-picker/snice-time-range-picker.js.map +1 -0
- package/dist/components/time-range-picker/snice-time-range-picker.types.d.ts +39 -0
- package/dist/components/treemap/snice-treemap.d.ts +49 -0
- package/dist/components/treemap/snice-treemap.js +455 -0
- package/dist/components/treemap/snice-treemap.js.map +1 -0
- package/dist/components/treemap/snice-treemap.types.d.ts +42 -0
- package/dist/components/virtual-scroller/snice-virtual-scroller.d.ts +5 -0
- package/dist/components/virtual-scroller/snice-virtual-scroller.js +47 -16
- package/dist/components/virtual-scroller/snice-virtual-scroller.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/transitions.cjs +1 -1
- package/dist/transitions.esm.js +1 -1
- package/docs/ai/components/camera-annotate.md +82 -0
- package/docs/ai/components/candlestick.md +79 -0
- package/docs/ai/components/funnel.md +86 -0
- package/docs/ai/components/network-graph.md +87 -0
- package/docs/ai/components/sankey.md +63 -0
- package/docs/ai/components/time-range-picker.md +78 -0
- package/docs/ai/components/treemap.md +78 -0
- package/docs/components/camera-annotate.md +186 -0
- package/docs/components/candlestick.md +196 -0
- package/docs/components/funnel.md +191 -0
- package/docs/components/network-graph.md +215 -0
- package/docs/components/sankey.md +201 -0
- package/docs/components/time-range-picker.md +213 -0
- package/docs/components/treemap.md +198 -0
- package/package.json +1 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Camera Annotate Component
|
|
2
|
+
|
|
3
|
+
The camera annotate component combines camera capture with freehand drawing and labeled annotations. It provides a workflow for taking pictures, drawing shapes on them, and adding descriptive labels to each annotation.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Basic Usage](#basic-usage)
|
|
7
|
+
- [Properties](#properties)
|
|
8
|
+
- [Methods](#methods)
|
|
9
|
+
- [Events](#events)
|
|
10
|
+
- [Examples](#examples)
|
|
11
|
+
- [Annotation Workflow](#annotation-workflow)
|
|
12
|
+
- [Accessibility](#accessibility)
|
|
13
|
+
- [Best Practices](#best-practices)
|
|
14
|
+
|
|
15
|
+
## Basic Usage
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<snice-camera-annotate></snice-camera-annotate>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import 'snice/components/camera-annotate/snice-camera-annotate';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Properties
|
|
26
|
+
|
|
27
|
+
| Property | Type | Default | Description |
|
|
28
|
+
|----------|------|---------|-------------|
|
|
29
|
+
| `mode` | `'camera' \| 'annotate'` | `'camera'` | Current mode of the component |
|
|
30
|
+
| `auto-rotate-colors` | `boolean` | `true` | Automatically cycle through preset colors for each new annotation |
|
|
31
|
+
| `show-labels-panel` | `boolean` | `true` | Show the sidebar panel with annotation labels |
|
|
32
|
+
|
|
33
|
+
## Methods
|
|
34
|
+
|
|
35
|
+
| Method | Return Type | Description |
|
|
36
|
+
|--------|-------------|-------------|
|
|
37
|
+
| `capture()` | `Promise<void>` | Capture current camera frame and switch to annotate mode |
|
|
38
|
+
| `exportImage(options?)` | `string` | Export annotated image as data URL. Options: `{ includeLabels?: boolean }` |
|
|
39
|
+
| `exportAnnotations()` | `AnnotationData` | Export all annotation data as a serializable object |
|
|
40
|
+
| `importAnnotations(data)` | `void` | Load annotation data from a previously exported object |
|
|
41
|
+
| `clearAnnotations()` | `void` | Remove all annotations and strokes |
|
|
42
|
+
|
|
43
|
+
## Events
|
|
44
|
+
|
|
45
|
+
| Event | Detail | Description |
|
|
46
|
+
|-------|--------|-------------|
|
|
47
|
+
| `@snice/capture` | `{ dataURL, width, height }` | Fired when an image is captured from the camera |
|
|
48
|
+
| `@snice/annotate` | `{ annotation }` | Fired when a new annotation (shape) is drawn |
|
|
49
|
+
| `@snice/annotation-change` | `{ annotations }` | Fired when annotations are modified (add, remove, visibility, label) |
|
|
50
|
+
|
|
51
|
+
## Examples
|
|
52
|
+
|
|
53
|
+
### Default Camera Annotator
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<snice-camera-annotate></snice-camera-annotate>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Without Labels Panel
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<snice-camera-annotate show-labels-panel="false"></snice-camera-annotate>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Manual Color Selection
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<snice-camera-annotate auto-rotate-colors="false"></snice-camera-annotate>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Listening to Events
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<snice-camera-annotate id="annotator"></snice-camera-annotate>
|
|
75
|
+
|
|
76
|
+
<script type="module">
|
|
77
|
+
const annotator = document.getElementById('annotator');
|
|
78
|
+
|
|
79
|
+
annotator.addEventListener('@snice/capture', (e) => {
|
|
80
|
+
console.log('Captured:', e.detail.width, 'x', e.detail.height);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
annotator.addEventListener('@snice/annotate', (e) => {
|
|
84
|
+
console.log('New annotation:', e.detail.annotation.id);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
annotator.addEventListener('@snice/annotation-change', (e) => {
|
|
88
|
+
console.log('Total annotations:', e.detail.annotations.length);
|
|
89
|
+
});
|
|
90
|
+
</script>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Save and Load Annotations
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<snice-camera-annotate id="annotator"></snice-camera-annotate>
|
|
97
|
+
|
|
98
|
+
<script type="module">
|
|
99
|
+
const annotator = document.getElementById('annotator');
|
|
100
|
+
|
|
101
|
+
// Save
|
|
102
|
+
function saveAnnotations() {
|
|
103
|
+
const data = annotator.exportAnnotations();
|
|
104
|
+
localStorage.setItem('annotations', JSON.stringify(data));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Load
|
|
108
|
+
function loadAnnotations() {
|
|
109
|
+
const json = localStorage.getItem('annotations');
|
|
110
|
+
if (json) {
|
|
111
|
+
annotator.importAnnotations(JSON.parse(json));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
</script>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Export Image
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<snice-camera-annotate id="annotator"></snice-camera-annotate>
|
|
121
|
+
<button onclick="downloadImage()">Download</button>
|
|
122
|
+
|
|
123
|
+
<script type="module">
|
|
124
|
+
function downloadImage() {
|
|
125
|
+
const annotator = document.getElementById('annotator');
|
|
126
|
+
|
|
127
|
+
// Without labels on the image
|
|
128
|
+
const imageOnly = annotator.exportImage();
|
|
129
|
+
|
|
130
|
+
// With labels rendered on the image
|
|
131
|
+
const withLabels = annotator.exportImage({ includeLabels: true });
|
|
132
|
+
|
|
133
|
+
// Download
|
|
134
|
+
const a = document.createElement('a');
|
|
135
|
+
a.href = withLabels;
|
|
136
|
+
a.download = 'annotated.png';
|
|
137
|
+
a.click();
|
|
138
|
+
}
|
|
139
|
+
</script>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Annotation Workflow
|
|
143
|
+
|
|
144
|
+
1. **Camera Mode**: The component starts showing a live camera feed
|
|
145
|
+
2. **Capture**: Click the "Capture" button to take a photo
|
|
146
|
+
3. **Annotate Mode**: Draw shapes on the captured image using freehand strokes
|
|
147
|
+
4. **Label**: Type labels for each annotation in the sidebar
|
|
148
|
+
5. **Manage**: Show/hide individual annotations, toggle all, or delete specific ones
|
|
149
|
+
6. **Export**: Save annotation data as JSON or export the annotated image
|
|
150
|
+
7. **Retake**: Click "Retake" to return to camera mode and start fresh
|
|
151
|
+
|
|
152
|
+
### Color System
|
|
153
|
+
|
|
154
|
+
- **Preset Palette**: 12 preset colors displayed as swatches in the sidebar
|
|
155
|
+
- **Auto Rotate**: When enabled (default), each new annotation automatically gets the next color from the palette
|
|
156
|
+
- **Manual Selection**: Click any color swatch to set the active drawing color
|
|
157
|
+
|
|
158
|
+
### Visual Highlighting
|
|
159
|
+
|
|
160
|
+
When you hover over an annotation label in the sidebar:
|
|
161
|
+
- The corresponding shape is highlighted at full opacity
|
|
162
|
+
- All other shapes dim to 20% opacity with a grayscale filter
|
|
163
|
+
- This makes it easy to identify which shape belongs to which label
|
|
164
|
+
|
|
165
|
+
## Accessibility
|
|
166
|
+
|
|
167
|
+
- Color swatches have title attributes showing the hex value
|
|
168
|
+
- Annotation visibility toggles have descriptive title text
|
|
169
|
+
- Delete buttons have clear title labels
|
|
170
|
+
- The sidebar scrolls independently when annotations exceed available space
|
|
171
|
+
|
|
172
|
+
## Browser Support
|
|
173
|
+
|
|
174
|
+
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
175
|
+
- Requires camera access via `getUserMedia`
|
|
176
|
+
- Requires Custom Elements v1 and Shadow DOM support
|
|
177
|
+
|
|
178
|
+
## Best Practices
|
|
179
|
+
|
|
180
|
+
1. **Grant camera permissions**: Ensure users have allowed camera access for the capture workflow
|
|
181
|
+
2. **Add labels promptly**: Label annotations as you draw them for better organization
|
|
182
|
+
3. **Use auto-rotate colors**: Keeps annotations visually distinct without manual color selection
|
|
183
|
+
4. **Export regularly**: Save annotation data to prevent loss on page refresh
|
|
184
|
+
5. **Use the sidebar**: Hovering labels helps verify which shape corresponds to which annotation
|
|
185
|
+
6. **Clear before starting fresh**: Use clearAnnotations() or "Retake" to reset
|
|
186
|
+
7. **Export with labels**: When sharing annotated images, include labels for context
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Candlestick Chart Component
|
|
2
|
+
|
|
3
|
+
The candlestick chart component renders an SVG-based OHLC (Open-High-Low-Close) financial chart, commonly used for stock market and cryptocurrency price visualization. It supports volume bars, crosshair overlay, zoom/pan, tooltips, and responsive sizing.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Basic Usage](#basic-usage)
|
|
7
|
+
- [Properties](#properties)
|
|
8
|
+
- [Methods](#methods)
|
|
9
|
+
- [Events](#events)
|
|
10
|
+
- [Examples](#examples)
|
|
11
|
+
- [Accessibility](#accessibility)
|
|
12
|
+
- [Best Practices](#best-practices)
|
|
13
|
+
|
|
14
|
+
## Basic Usage
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<snice-candlestick id="chart"></snice-candlestick>
|
|
18
|
+
|
|
19
|
+
<script type="module">
|
|
20
|
+
import 'snice/components/candlestick/snice-candlestick';
|
|
21
|
+
|
|
22
|
+
const chart = document.getElementById('chart');
|
|
23
|
+
chart.data = [
|
|
24
|
+
{ date: '2024-01-01', open: 100, high: 110, low: 95, close: 105, volume: 500000 },
|
|
25
|
+
{ date: '2024-01-02', open: 105, high: 115, low: 100, close: 98, volume: 600000 },
|
|
26
|
+
{ date: '2024-01-03', open: 98, high: 108, low: 93, close: 107, volume: 450000 },
|
|
27
|
+
];
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Properties
|
|
32
|
+
|
|
33
|
+
| Property | Type | Default | Description |
|
|
34
|
+
|----------|------|---------|-------------|
|
|
35
|
+
| `data` | `CandleData[]` | `[]` | Array of candlestick data points |
|
|
36
|
+
| `show-volume` | `boolean` | `false` | Show volume bars below the price chart |
|
|
37
|
+
| `show-grid` | `boolean` | `true` | Show horizontal grid lines |
|
|
38
|
+
| `show-crosshair` | `boolean` | `true` | Show crosshair overlay on hover |
|
|
39
|
+
| `bullish-color` | `string` | `''` | Custom color for bullish candles (close >= open) |
|
|
40
|
+
| `bearish-color` | `string` | `''` | Custom color for bearish candles (close < open) |
|
|
41
|
+
| `time-format` | `string` | `'auto'` | Date format: `'auto'`, `'date'`, `'time'`, `'datetime'`, `'month'`, `'year'` |
|
|
42
|
+
| `y-axis-format` | `string` | `'number'` | Y-axis format: `'number'`, `'currency'`, `'percent'` |
|
|
43
|
+
| `zoom-enabled` | `boolean` | `true` | Enable scroll-to-zoom and drag-to-pan |
|
|
44
|
+
| `animation` | `boolean` | `true` | Animate candle appearance on data change |
|
|
45
|
+
|
|
46
|
+
### CandleData Interface
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
interface CandleData {
|
|
50
|
+
date: string | number | Date; // Timestamp or date string
|
|
51
|
+
open: number; // Opening price
|
|
52
|
+
high: number; // Highest price
|
|
53
|
+
low: number; // Lowest price
|
|
54
|
+
close: number; // Closing price
|
|
55
|
+
volume?: number; // Trading volume (optional)
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Methods
|
|
60
|
+
|
|
61
|
+
| Method | Signature | Description |
|
|
62
|
+
|--------|-----------|-------------|
|
|
63
|
+
| `resetZoom()` | `() => void` | Reset zoom to show all data points |
|
|
64
|
+
| `zoomTo()` | `(startIndex: number, endIndex: number) => void` | Zoom to a specific index range |
|
|
65
|
+
|
|
66
|
+
## Events
|
|
67
|
+
|
|
68
|
+
| Event | Detail | Description |
|
|
69
|
+
|-------|--------|-------------|
|
|
70
|
+
| `@snice/candle-click` | `{ candle: CandleData, index: number }` | A candle was clicked |
|
|
71
|
+
| `@snice/candle-hover` | `{ candle: CandleData, index: number }` | Mouse entered a candle |
|
|
72
|
+
| `@snice/crosshair-move` | `{ price: number, date: string, x: number, y: number }` | Crosshair position changed |
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
### With Volume Bars
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<snice-candlestick id="vol-chart" show-volume></snice-candlestick>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Custom Colors
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<snice-candlestick bullish-color="#0088ff" bearish-color="#ff6600"></snice-candlestick>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Currency Format (Stock Prices)
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<snice-candlestick id="stock-chart" y-axis-format="currency" show-volume></snice-candlestick>
|
|
92
|
+
|
|
93
|
+
<script>
|
|
94
|
+
stockChart.data = [
|
|
95
|
+
{ date: '2024-01-02', open: 42500, high: 42850, low: 42200, close: 42700, volume: 15000000 },
|
|
96
|
+
// ...
|
|
97
|
+
];
|
|
98
|
+
</script>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Minimal (No Grid, No Crosshair)
|
|
102
|
+
|
|
103
|
+
```html
|
|
104
|
+
<snice-candlestick show-grid="false" show-crosshair="false"></snice-candlestick>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Zoom Controls
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<button onclick="chart.resetZoom()">Reset Zoom</button>
|
|
111
|
+
<button onclick="chart.zoomTo(0, 30)">First 30 Days</button>
|
|
112
|
+
<snice-candlestick id="chart" zoom-enabled></snice-candlestick>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Listening to Events
|
|
116
|
+
|
|
117
|
+
```html
|
|
118
|
+
<snice-candlestick id="chart"></snice-candlestick>
|
|
119
|
+
|
|
120
|
+
<script>
|
|
121
|
+
chart.addEventListener('@snice/candle-click', (e) => {
|
|
122
|
+
console.log('Clicked candle:', e.detail.candle);
|
|
123
|
+
console.log('Index:', e.detail.index);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
chart.addEventListener('@snice/crosshair-move', (e) => {
|
|
127
|
+
console.log('Price at cursor:', e.detail.price);
|
|
128
|
+
console.log('Date at cursor:', e.detail.date);
|
|
129
|
+
});
|
|
130
|
+
</script>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Dynamic Data Updates
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
<snice-candlestick id="live-chart" show-volume></snice-candlestick>
|
|
137
|
+
|
|
138
|
+
<script>
|
|
139
|
+
// Add new candle every 5 seconds
|
|
140
|
+
setInterval(() => {
|
|
141
|
+
const data = [...liveChart.data];
|
|
142
|
+
const last = data[data.length - 1];
|
|
143
|
+
const change = (Math.random() - 0.5) * 10;
|
|
144
|
+
const open = last.close;
|
|
145
|
+
const close = open + change;
|
|
146
|
+
data.push({
|
|
147
|
+
date: new Date(),
|
|
148
|
+
open,
|
|
149
|
+
high: Math.max(open, close) + Math.random() * 3,
|
|
150
|
+
low: Math.min(open, close) - Math.random() * 3,
|
|
151
|
+
close,
|
|
152
|
+
volume: Math.floor(Math.random() * 1000000)
|
|
153
|
+
});
|
|
154
|
+
liveChart.data = data;
|
|
155
|
+
}, 5000);
|
|
156
|
+
</script>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## CSS Custom Properties
|
|
160
|
+
|
|
161
|
+
| Property | Default | Description |
|
|
162
|
+
|----------|---------|-------------|
|
|
163
|
+
| `--snice-candlestick-bullish` | `rgb(22 163 74)` (green) | Bullish candle color |
|
|
164
|
+
| `--snice-candlestick-bearish` | `rgb(220 38 38)` (red) | Bearish candle color |
|
|
165
|
+
|
|
166
|
+
You can also override colors globally using these CSS custom properties:
|
|
167
|
+
|
|
168
|
+
```css
|
|
169
|
+
snice-candlestick {
|
|
170
|
+
--snice-candlestick-bullish: #26a69a;
|
|
171
|
+
--snice-candlestick-bearish: #ef5350;
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Accessibility
|
|
176
|
+
|
|
177
|
+
- **ARIA role**: The SVG has `role="img"` for screen reader identification
|
|
178
|
+
- **ARIA label**: Includes data point count in `aria-label`
|
|
179
|
+
- **Keyboard**: Zoom and pan are mouse-driven; use `resetZoom()` and `zoomTo()` methods for programmatic control
|
|
180
|
+
- **Color contrast**: Default bullish (green) and bearish (red) colors meet WCAG AA standards
|
|
181
|
+
|
|
182
|
+
## Browser Support
|
|
183
|
+
|
|
184
|
+
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
185
|
+
- Requires Custom Elements v1 and Shadow DOM support
|
|
186
|
+
|
|
187
|
+
## Best Practices
|
|
188
|
+
|
|
189
|
+
1. **Set data via property**: Data is an array of objects, set via JavaScript (`chart.data = [...]`), not as an HTML attribute
|
|
190
|
+
2. **Include volume data**: Even if not displayed, volume data enriches tooltips
|
|
191
|
+
3. **Use appropriate time formats**: Match `time-format` to your data granularity (intraday = `'time'`, daily = `'date'`, monthly = `'month'`)
|
|
192
|
+
4. **Give the chart height**: The component needs an explicit height (set via CSS or a container)
|
|
193
|
+
5. **Limit visible candles**: For large datasets, the chart auto-limits visible candles; use `zoomTo()` for specific ranges
|
|
194
|
+
6. **Handle events**: Use `@snice/candle-click` for drill-down, `@snice/crosshair-move` for real-time price readout
|
|
195
|
+
7. **Custom colors**: Use `bullish-color` / `bearish-color` or CSS custom properties for theme integration
|
|
196
|
+
8. **Responsive**: The chart uses `ResizeObserver` and redraws on container resize
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Funnel Component
|
|
2
|
+
|
|
3
|
+
The funnel component renders an SVG-based funnel/conversion chart, ideal for visualizing pipeline stages, conversion funnels, and drop-off analysis. Each stage is rendered as a trapezoid shape that narrows proportionally to its value.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Basic Usage](#basic-usage)
|
|
7
|
+
- [Properties](#properties)
|
|
8
|
+
- [Methods](#methods)
|
|
9
|
+
- [Events](#events)
|
|
10
|
+
- [Examples](#examples)
|
|
11
|
+
- [Accessibility](#accessibility)
|
|
12
|
+
- [Best Practices](#best-practices)
|
|
13
|
+
|
|
14
|
+
## Basic Usage
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<snice-funnel id="my-funnel"></snice-funnel>
|
|
18
|
+
|
|
19
|
+
<script type="module">
|
|
20
|
+
import 'snice/components/funnel/snice-funnel';
|
|
21
|
+
|
|
22
|
+
const funnel = document.getElementById('my-funnel');
|
|
23
|
+
funnel.data = [
|
|
24
|
+
{ label: 'Visitors', value: 10000 },
|
|
25
|
+
{ label: 'Leads', value: 5000 },
|
|
26
|
+
{ label: 'Opportunities', value: 2000 },
|
|
27
|
+
{ label: 'Customers', value: 500 },
|
|
28
|
+
];
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Properties
|
|
33
|
+
|
|
34
|
+
| Property | Type | Default | Description |
|
|
35
|
+
|----------|------|---------|-------------|
|
|
36
|
+
| `data` | `FunnelStage[]` | `[]` | Array of stage objects with label, value, and optional color |
|
|
37
|
+
| `variant` | `'default' \| 'gradient'` | `'default'` | Color variant - default uses distinct colors, gradient uses opacity fade |
|
|
38
|
+
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Funnel layout direction |
|
|
39
|
+
| `show-labels` | `boolean` | `true` | Whether to display stage labels |
|
|
40
|
+
| `show-values` | `boolean` | `true` | Whether to display stage values |
|
|
41
|
+
| `show-percentages` | `boolean` | `true` | Whether to display conversion percentages |
|
|
42
|
+
| `animation` | `boolean` | `false` | Whether to animate stages on initial render |
|
|
43
|
+
|
|
44
|
+
### FunnelStage Interface
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
interface FunnelStage {
|
|
48
|
+
label: string; // Stage name (e.g., "Visitors")
|
|
49
|
+
value: number; // Numeric value for the stage
|
|
50
|
+
color?: string; // Optional custom color (CSS color string)
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Methods
|
|
55
|
+
|
|
56
|
+
| Method | Return Type | Description |
|
|
57
|
+
|--------|-------------|-------------|
|
|
58
|
+
| `setStages(stages)` | `void` | Set funnel data programmatically (alternative to setting `data` property) |
|
|
59
|
+
| `exportImage(format?)` | `string` | Export the funnel as a data URL. Format: `'png'` (default) or `'svg'` |
|
|
60
|
+
|
|
61
|
+
### Export Example
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const funnel = document.getElementById('my-funnel');
|
|
65
|
+
|
|
66
|
+
// Export as SVG
|
|
67
|
+
const svgDataUrl = funnel.exportImage('svg');
|
|
68
|
+
|
|
69
|
+
// Export as PNG
|
|
70
|
+
const pngDataUrl = funnel.exportImage('png');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Events
|
|
74
|
+
|
|
75
|
+
| Event | Detail | Description |
|
|
76
|
+
|-------|--------|-------------|
|
|
77
|
+
| `funnel-click` | `{ stage: FunnelStage, index: number }` | Fired when a stage is clicked |
|
|
78
|
+
| `funnel-hover` | `{ stage: FunnelStage, index: number }` | Fired when a stage is hovered |
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
funnel.addEventListener('funnel-click', (e) => {
|
|
82
|
+
console.log('Clicked stage:', e.detail.stage.label);
|
|
83
|
+
console.log('Stage index:', e.detail.index);
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
### Conversion Funnel
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<snice-funnel id="conversion"></snice-funnel>
|
|
93
|
+
<script>
|
|
94
|
+
document.getElementById('conversion').data = [
|
|
95
|
+
{ label: 'Website Visits', value: 50000 },
|
|
96
|
+
{ label: 'Sign Ups', value: 12000 },
|
|
97
|
+
{ label: 'Trial Started', value: 5000 },
|
|
98
|
+
{ label: 'Paid', value: 1500 },
|
|
99
|
+
{ label: 'Retained', value: 800 },
|
|
100
|
+
];
|
|
101
|
+
</script>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Gradient Variant
|
|
105
|
+
|
|
106
|
+
The gradient variant uses decreasing opacity of the primary color for a smoother visual effect.
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<snice-funnel id="gradient-funnel" variant="gradient"></snice-funnel>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Custom Colors
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
<snice-funnel id="colored-funnel"></snice-funnel>
|
|
116
|
+
<script>
|
|
117
|
+
document.getElementById('colored-funnel').data = [
|
|
118
|
+
{ label: 'Awareness', value: 10000, color: 'rgb(37 99 235)' },
|
|
119
|
+
{ label: 'Interest', value: 6000, color: 'rgb(22 163 74)' },
|
|
120
|
+
{ label: 'Decision', value: 2500, color: 'rgb(234 179 8)' },
|
|
121
|
+
{ label: 'Action', value: 1000, color: 'rgb(220 38 38)' },
|
|
122
|
+
];
|
|
123
|
+
</script>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Horizontal Layout
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<snice-funnel id="horizontal" orientation="horizontal"></snice-funnel>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### With Animation
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<snice-funnel id="animated" animation></snice-funnel>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Minimal Display
|
|
139
|
+
|
|
140
|
+
```html
|
|
141
|
+
<snice-funnel id="minimal" show-labels="false" show-percentages="false"></snice-funnel>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Event Handling
|
|
145
|
+
|
|
146
|
+
```html
|
|
147
|
+
<snice-funnel id="interactive"></snice-funnel>
|
|
148
|
+
<div id="output"></div>
|
|
149
|
+
|
|
150
|
+
<script>
|
|
151
|
+
const funnel = document.getElementById('interactive');
|
|
152
|
+
const output = document.getElementById('output');
|
|
153
|
+
|
|
154
|
+
funnel.data = [
|
|
155
|
+
{ label: 'Step 1', value: 1000 },
|
|
156
|
+
{ label: 'Step 2', value: 600 },
|
|
157
|
+
{ label: 'Step 3', value: 200 },
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
funnel.addEventListener('funnel-click', (e) => {
|
|
161
|
+
output.textContent = `Clicked: ${e.detail.stage.label} (${e.detail.stage.value})`;
|
|
162
|
+
});
|
|
163
|
+
</script>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Accessibility
|
|
167
|
+
|
|
168
|
+
- **ARIA role**: The SVG has `role="img"` with `aria-label="Funnel chart"`
|
|
169
|
+
- **Interactive stages**: Each stage has `role="button"` and `tabindex="0"` for keyboard navigation
|
|
170
|
+
- **ARIA labels**: Each stage has a descriptive `aria-label` including the label, value, and percentage
|
|
171
|
+
- **Keyboard support**: Stages can be activated with Enter or Space keys
|
|
172
|
+
- **Focus styles**: Visible focus ring on keyboard navigation
|
|
173
|
+
- **Color contrast**: Default colors meet WCAG AA standards
|
|
174
|
+
|
|
175
|
+
## Browser Support
|
|
176
|
+
|
|
177
|
+
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
178
|
+
- Requires Custom Elements v1 and Shadow DOM support
|
|
179
|
+
|
|
180
|
+
## Best Practices
|
|
181
|
+
|
|
182
|
+
1. **Order data by value**: Place the largest value first for a natural funnel shape
|
|
183
|
+
2. **Use meaningful labels**: Stage labels should clearly describe each step in the process
|
|
184
|
+
3. **Limit stages**: 3-7 stages works best visually; more than 8 becomes hard to read
|
|
185
|
+
4. **Choose colors wisely**: Use custom colors to match your brand or highlight important stages
|
|
186
|
+
5. **Include percentages**: Conversion percentages help users understand drop-off rates
|
|
187
|
+
6. **Use animation sparingly**: Enable animation for initial page load or dashboard reveals
|
|
188
|
+
7. **Consider orientation**: Vertical works well for sidebar placement; horizontal for wide layouts
|
|
189
|
+
8. **Handle click events**: Use click events to drill down into stage details
|
|
190
|
+
9. **Format values**: Large numbers are automatically formatted (K/M notation)
|
|
191
|
+
10. **Test responsiveness**: The SVG scales with its container width
|