snice 3.2.0 → 3.3.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/dist/components/accordion/snice-accordion-item.d.ts +2 -2
- package/dist/components/accordion/snice-accordion-item.js +8 -8
- package/dist/components/accordion/snice-accordion-item.js.map +1 -1
- package/dist/components/accordion/snice-accordion.d.ts +2 -2
- package/dist/components/accordion/snice-accordion.js +8 -8
- package/dist/components/accordion/snice-accordion.js.map +1 -1
- package/dist/components/actions/snice-actions.d.ts +28 -0
- package/dist/components/actions/snice-actions.js +220 -0
- package/dist/components/actions/snice-actions.js.map +1 -0
- package/dist/components/actions/snice-actions.types.d.ts +27 -0
- package/dist/components/alert/snice-alert.d.ts +2 -2
- package/dist/components/alert/snice-alert.js +8 -8
- package/dist/components/alert/snice-alert.js.map +1 -1
- package/dist/components/audio-recorder/snice-audio-recorder.d.ts +58 -0
- package/dist/components/audio-recorder/snice-audio-recorder.js +413 -0
- package/dist/components/audio-recorder/snice-audio-recorder.js.map +1 -0
- package/dist/components/audio-recorder/snice-audio-recorder.types.d.ts +28 -0
- package/dist/components/avatar/snice-avatar.d.ts +2 -2
- package/dist/components/avatar/snice-avatar.js +8 -8
- package/dist/components/avatar/snice-avatar.js.map +1 -1
- package/dist/components/badge/snice-badge.d.ts +2 -2
- package/dist/components/badge/snice-badge.js +9 -9
- package/dist/components/badge/snice-badge.js.map +1 -1
- package/dist/components/banner/snice-banner.d.ts +2 -2
- package/dist/components/banner/snice-banner.js +8 -8
- package/dist/components/banner/snice-banner.js.map +1 -1
- package/dist/components/breadcrumbs/snice-breadcrumbs.d.ts +2 -2
- package/dist/components/breadcrumbs/snice-breadcrumbs.js +8 -8
- package/dist/components/breadcrumbs/snice-breadcrumbs.js.map +1 -1
- package/dist/components/button/snice-button.d.ts +2 -2
- package/dist/components/button/snice-button.js +8 -8
- package/dist/components/button/snice-button.js.map +1 -1
- package/dist/components/calendar/snice-calendar.d.ts +46 -0
- package/dist/components/calendar/snice-calendar.js +294 -0
- package/dist/components/calendar/snice-calendar.js.map +1 -0
- package/dist/components/calendar/snice-calendar.types.d.ts +34 -0
- package/dist/components/camera/snice-camera.d.ts +39 -0
- package/dist/components/camera/snice-camera.js +286 -0
- package/dist/components/camera/snice-camera.js.map +1 -0
- package/dist/components/camera/snice-camera.types.d.ts +28 -0
- package/dist/components/card/snice-card.d.ts +2 -2
- package/dist/components/card/snice-card.js +8 -8
- package/dist/components/card/snice-card.js.map +1 -1
- package/dist/components/carousel/snice-carousel.d.ts +32 -0
- package/dist/components/carousel/snice-carousel.js +279 -0
- package/dist/components/carousel/snice-carousel.js.map +1 -0
- package/dist/components/carousel/snice-carousel.types.d.ts +22 -0
- package/dist/components/chart/snice-chart.d.ts +73 -0
- package/dist/components/chart/snice-chart.js +940 -0
- package/dist/components/chart/snice-chart.js.map +1 -0
- package/dist/components/chart/snice-chart.types.d.ts +71 -0
- package/dist/components/chat/snice-chat.d.ts +98 -0
- package/dist/components/chat/snice-chat.js +589 -0
- package/dist/components/chat/snice-chat.js.map +1 -0
- package/dist/components/chat/snice-chat.types.d.ts +141 -0
- package/dist/components/checkbox/snice-checkbox.d.ts +2 -2
- package/dist/components/checkbox/snice-checkbox.js +8 -8
- package/dist/components/checkbox/snice-checkbox.js.map +1 -1
- package/dist/components/chip/snice-chip.d.ts +2 -2
- package/dist/components/chip/snice-chip.js +8 -8
- package/dist/components/chip/snice-chip.js.map +1 -1
- package/dist/components/code-block/snice-code-block.d.ts +15 -0
- package/dist/components/code-block/snice-code-block.js +141 -0
- package/dist/components/code-block/snice-code-block.js.map +1 -0
- package/dist/components/code-block/snice-code-block.types.d.ts +15 -0
- package/dist/components/color-display/snice-color-display.d.ts +2 -2
- package/dist/components/color-display/snice-color-display.js +9 -9
- package/dist/components/color-display/snice-color-display.js.map +1 -1
- package/dist/components/color-picker/snice-color-picker.d.ts +2 -2
- package/dist/components/color-picker/snice-color-picker.js +8 -8
- package/dist/components/color-picker/snice-color-picker.js.map +1 -1
- package/dist/components/command-palette/snice-command-palette.d.ts +47 -0
- package/dist/components/command-palette/snice-command-palette.js +428 -0
- package/dist/components/command-palette/snice-command-palette.js.map +1 -0
- package/dist/components/command-palette/snice-command-palette.types.d.ts +49 -0
- package/dist/components/date-picker/snice-date-picker.d.ts +2 -2
- package/dist/components/date-picker/snice-date-picker.js +9 -9
- package/dist/components/date-picker/snice-date-picker.js.map +1 -1
- package/dist/components/divider/snice-divider.d.ts +2 -2
- package/dist/components/divider/snice-divider.js +8 -8
- package/dist/components/divider/snice-divider.js.map +1 -1
- package/dist/components/doc/snice-doc.d.ts +93 -0
- package/dist/components/doc/snice-doc.js +626 -0
- package/dist/components/doc/snice-doc.js.map +1 -0
- package/dist/components/doc/snice-doc.types.d.ts +118 -0
- package/dist/components/draw/snice-draw.d.ts +71 -0
- package/dist/components/draw/snice-draw.js +709 -0
- package/dist/components/draw/snice-draw.js.map +1 -0
- package/dist/components/draw/snice-draw.types.d.ts +41 -0
- package/dist/components/drawer/snice-drawer.d.ts +2 -2
- package/dist/components/drawer/snice-drawer.js +8 -8
- package/dist/components/drawer/snice-drawer.js.map +1 -1
- package/dist/components/empty-state/snice-empty-state.d.ts +2 -2
- package/dist/components/empty-state/snice-empty-state.js +8 -8
- package/dist/components/empty-state/snice-empty-state.js.map +1 -1
- package/dist/components/file-upload/snice-file-upload.d.ts +2 -3
- package/dist/components/file-upload/snice-file-upload.js +8 -15
- package/dist/components/file-upload/snice-file-upload.js.map +1 -1
- package/dist/components/gantt/snice-gantt.d.ts +29 -0
- package/dist/components/gantt/snice-gantt.js +268 -0
- package/dist/components/gantt/snice-gantt.js.map +1 -0
- package/dist/components/gantt/snice-gantt.types.d.ts +23 -0
- package/dist/components/image/snice-image.d.ts +2 -2
- package/dist/components/image/snice-image.js +9 -9
- package/dist/components/image/snice-image.js.map +1 -1
- package/dist/components/input/snice-input.d.ts +2 -2
- package/dist/components/input/snice-input.js +8 -8
- package/dist/components/input/snice-input.js.map +1 -1
- package/dist/components/kanban/snice-kanban.d.ts +31 -0
- package/dist/components/kanban/snice-kanban.js +243 -0
- package/dist/components/kanban/snice-kanban.js.map +1 -0
- package/dist/components/kanban/snice-kanban.types.d.ts +29 -0
- package/dist/components/kpi/snice-kpi.d.ts +2 -2
- package/dist/components/kpi/snice-kpi.js +10 -10
- package/dist/components/kpi/snice-kpi.js.map +1 -1
- package/dist/components/layout/snice-layout-blog.d.ts +2 -2
- package/dist/components/layout/snice-layout-blog.js +8 -8
- package/dist/components/layout/snice-layout-blog.js.map +1 -1
- package/dist/components/layout/snice-layout-card.d.ts +2 -2
- package/dist/components/layout/snice-layout-card.js +8 -8
- package/dist/components/layout/snice-layout-card.js.map +1 -1
- package/dist/components/layout/snice-layout-centered.d.ts +2 -2
- package/dist/components/layout/snice-layout-centered.js +8 -8
- package/dist/components/layout/snice-layout-centered.js.map +1 -1
- package/dist/components/layout/snice-layout-dashboard.d.ts +2 -2
- package/dist/components/layout/snice-layout-dashboard.js +8 -8
- package/dist/components/layout/snice-layout-dashboard.js.map +1 -1
- package/dist/components/layout/snice-layout-fullscreen.d.ts +2 -2
- package/dist/components/layout/snice-layout-fullscreen.js +8 -8
- package/dist/components/layout/snice-layout-fullscreen.js.map +1 -1
- package/dist/components/layout/snice-layout-landing.d.ts +2 -2
- package/dist/components/layout/snice-layout-landing.js +8 -8
- package/dist/components/layout/snice-layout-landing.js.map +1 -1
- package/dist/components/layout/snice-layout-minimal.d.ts +2 -2
- package/dist/components/layout/snice-layout-minimal.js +8 -8
- package/dist/components/layout/snice-layout-minimal.js.map +1 -1
- package/dist/components/layout/snice-layout-sidebar.d.ts +2 -2
- package/dist/components/layout/snice-layout-sidebar.js +8 -8
- package/dist/components/layout/snice-layout-sidebar.js.map +1 -1
- package/dist/components/layout/snice-layout-split.d.ts +2 -2
- package/dist/components/layout/snice-layout-split.js +8 -8
- package/dist/components/layout/snice-layout-split.js.map +1 -1
- package/dist/components/layout/snice-layout.d.ts +2 -2
- package/dist/components/layout/snice-layout.js +8 -8
- package/dist/components/layout/snice-layout.js.map +1 -1
- package/dist/components/link/snice-link.d.ts +2 -2
- package/dist/components/link/snice-link.js +9 -9
- package/dist/components/link/snice-link.js.map +1 -1
- package/dist/components/list/snice-list-item.d.ts +6 -0
- package/dist/components/list/snice-list-item.js +68 -0
- package/dist/components/list/snice-list-item.js.map +1 -0
- package/dist/components/list/snice-list.d.ts +23 -0
- package/dist/components/list/snice-list.js +270 -0
- package/dist/components/list/snice-list.js.map +1 -0
- package/dist/components/list/snice-list.types.d.ts +28 -0
- package/dist/components/location/snice-location.d.ts +35 -0
- package/dist/components/location/snice-location.js +238 -0
- package/dist/components/location/snice-location.js.map +1 -0
- package/dist/components/location/snice-location.types.d.ts +35 -0
- package/dist/components/login/snice-login.d.ts +2 -2
- package/dist/components/login/snice-login.js +8 -8
- package/dist/components/login/snice-login.js.map +1 -1
- package/dist/components/menu/snice-menu-divider.d.ts +4 -0
- package/dist/components/menu/snice-menu-divider.js +53 -0
- package/dist/components/menu/snice-menu-divider.js.map +1 -0
- package/dist/components/menu/snice-menu-item.d.ts +10 -0
- package/dist/components/menu/snice-menu-item.js +99 -0
- package/dist/components/menu/snice-menu-item.js.map +1 -0
- package/dist/components/menu/snice-menu-item.types.d.ts +9 -0
- package/dist/components/menu/snice-menu.d.ts +27 -0
- package/dist/components/menu/snice-menu.js +199 -0
- package/dist/components/menu/snice-menu.js.map +1 -0
- package/dist/components/menu/snice-menu.types.d.ts +18 -0
- package/dist/components/modal/snice-modal.d.ts +2 -2
- package/dist/components/modal/snice-modal.js +8 -8
- package/dist/components/modal/snice-modal.js.map +1 -1
- package/dist/components/nav/snice-nav.js.map +1 -1
- package/dist/components/pagination/snice-pagination.d.ts +2 -2
- package/dist/components/pagination/snice-pagination.js +8 -8
- package/dist/components/pagination/snice-pagination.js.map +1 -1
- package/dist/components/progress/snice-progress.d.ts +2 -2
- package/dist/components/progress/snice-progress.js +8 -8
- package/dist/components/progress/snice-progress.js.map +1 -1
- package/dist/components/qr-code/qrcode.d.ts +28 -0
- package/dist/components/qr-code/qrcode.js +906 -0
- package/dist/components/qr-code/qrcode.js.map +1 -0
- package/dist/components/qr-code/snice-qr-code.d.ts +35 -0
- package/dist/components/qr-code/snice-qr-code.js +256 -0
- package/dist/components/qr-code/snice-qr-code.js.map +1 -0
- package/dist/components/qr-code/snice-qr-code.types.d.ts +33 -0
- package/dist/components/radio/snice-radio.d.ts +2 -2
- package/dist/components/radio/snice-radio.js +8 -8
- package/dist/components/radio/snice-radio.js.map +1 -1
- package/dist/components/select/snice-option.d.ts +2 -2
- package/dist/components/select/snice-option.js +8 -8
- package/dist/components/select/snice-option.js.map +1 -1
- package/dist/components/select/snice-select.d.ts +2 -2
- package/dist/components/select/snice-select.js +8 -8
- package/dist/components/select/snice-select.js.map +1 -1
- package/dist/components/skeleton/snice-skeleton.d.ts +2 -2
- package/dist/components/skeleton/snice-skeleton.js +8 -8
- package/dist/components/skeleton/snice-skeleton.js.map +1 -1
- package/dist/components/slider/snice-slider.d.ts +2 -2
- package/dist/components/slider/snice-slider.js +8 -8
- package/dist/components/slider/snice-slider.js.map +1 -1
- package/dist/components/sparkline/snice-sparkline.d.ts +2 -2
- package/dist/components/sparkline/snice-sparkline.js +9 -9
- package/dist/components/sparkline/snice-sparkline.js.map +1 -1
- package/dist/components/spinner/snice-spinner.d.ts +2 -2
- package/dist/components/spinner/snice-spinner.js +9 -9
- package/dist/components/spinner/snice-spinner.js.map +1 -1
- package/dist/components/split-pane/snice-split-pane.d.ts +32 -0
- package/dist/components/split-pane/snice-split-pane.js +191 -0
- package/dist/components/split-pane/snice-split-pane.js.map +1 -0
- package/dist/components/split-pane/snice-split-pane.types.d.ts +19 -0
- package/dist/components/stat/snice-stat.d.ts +14 -0
- package/dist/components/stat/snice-stat.js +140 -0
- package/dist/components/stat/snice-stat.js.map +1 -0
- package/dist/components/stat/snice-stat.types.d.ts +12 -0
- package/dist/components/stepper/snice-stepper-panel.d.ts +2 -2
- package/dist/components/stepper/snice-stepper-panel.js +9 -9
- package/dist/components/stepper/snice-stepper-panel.js.map +1 -1
- package/dist/components/stepper/snice-stepper.d.ts +2 -2
- package/dist/components/stepper/snice-stepper.js +9 -9
- package/dist/components/stepper/snice-stepper.js.map +1 -1
- package/dist/components/switch/snice-switch.d.ts +2 -2
- package/dist/components/switch/snice-switch.js +8 -8
- package/dist/components/switch/snice-switch.js.map +1 -1
- package/dist/components/table/snice-cell-actions.d.ts +2 -2
- package/dist/components/table/snice-cell-actions.js +8 -8
- package/dist/components/table/snice-cell-actions.js.map +1 -1
- package/dist/components/table/snice-cell-boolean.d.ts +2 -2
- package/dist/components/table/snice-cell-boolean.js +8 -8
- package/dist/components/table/snice-cell-boolean.js.map +1 -1
- package/dist/components/table/snice-cell-color.d.ts +2 -2
- package/dist/components/table/snice-cell-color.js +8 -8
- package/dist/components/table/snice-cell-color.js.map +1 -1
- package/dist/components/table/snice-cell-currency.d.ts +2 -2
- package/dist/components/table/snice-cell-currency.js +8 -8
- package/dist/components/table/snice-cell-currency.js.map +1 -1
- package/dist/components/table/snice-cell-date.d.ts +2 -2
- package/dist/components/table/snice-cell-date.js +8 -8
- package/dist/components/table/snice-cell-date.js.map +1 -1
- package/dist/components/table/snice-cell-duration.d.ts +2 -2
- package/dist/components/table/snice-cell-duration.js +8 -8
- package/dist/components/table/snice-cell-duration.js.map +1 -1
- package/dist/components/table/snice-cell-email.d.ts +2 -2
- package/dist/components/table/snice-cell-email.js +8 -8
- package/dist/components/table/snice-cell-email.js.map +1 -1
- package/dist/components/table/snice-cell-filesize.d.ts +2 -2
- package/dist/components/table/snice-cell-filesize.js +8 -8
- package/dist/components/table/snice-cell-filesize.js.map +1 -1
- package/dist/components/table/snice-cell-image.d.ts +2 -2
- package/dist/components/table/snice-cell-image.js +8 -8
- package/dist/components/table/snice-cell-image.js.map +1 -1
- package/dist/components/table/snice-cell-json.d.ts +2 -2
- package/dist/components/table/snice-cell-json.js +8 -8
- package/dist/components/table/snice-cell-json.js.map +1 -1
- package/dist/components/table/snice-cell-link.d.ts +2 -2
- package/dist/components/table/snice-cell-link.js +8 -8
- package/dist/components/table/snice-cell-link.js.map +1 -1
- package/dist/components/table/snice-cell-location.d.ts +2 -2
- package/dist/components/table/snice-cell-location.js +8 -8
- package/dist/components/table/snice-cell-location.js.map +1 -1
- package/dist/components/table/snice-cell-number.d.ts +2 -2
- package/dist/components/table/snice-cell-number.js +8 -8
- package/dist/components/table/snice-cell-number.js.map +1 -1
- package/dist/components/table/snice-cell-percentage.d.ts +2 -2
- package/dist/components/table/snice-cell-percentage.js +8 -8
- package/dist/components/table/snice-cell-percentage.js.map +1 -1
- package/dist/components/table/snice-cell-phone.d.ts +2 -2
- package/dist/components/table/snice-cell-phone.js +8 -8
- package/dist/components/table/snice-cell-phone.js.map +1 -1
- package/dist/components/table/snice-cell-progress.d.ts +2 -2
- package/dist/components/table/snice-cell-progress.js +8 -8
- package/dist/components/table/snice-cell-progress.js.map +1 -1
- package/dist/components/table/snice-cell-rating.d.ts +2 -2
- package/dist/components/table/snice-cell-rating.js +8 -8
- package/dist/components/table/snice-cell-rating.js.map +1 -1
- package/dist/components/table/snice-cell-sparkline.d.ts +2 -2
- package/dist/components/table/snice-cell-sparkline.js +8 -8
- package/dist/components/table/snice-cell-sparkline.js.map +1 -1
- package/dist/components/table/snice-cell-status.d.ts +2 -2
- package/dist/components/table/snice-cell-status.js +8 -8
- package/dist/components/table/snice-cell-status.js.map +1 -1
- package/dist/components/table/snice-cell-tag.d.ts +2 -2
- package/dist/components/table/snice-cell-tag.js +8 -8
- package/dist/components/table/snice-cell-tag.js.map +1 -1
- package/dist/components/table/snice-cell-text.d.ts +2 -2
- package/dist/components/table/snice-cell-text.js +8 -8
- package/dist/components/table/snice-cell-text.js.map +1 -1
- package/dist/components/table/snice-cell.d.ts +2 -2
- package/dist/components/table/snice-cell.js +8 -8
- package/dist/components/table/snice-cell.js.map +1 -1
- package/dist/components/table/snice-column.d.ts +1 -1
- package/dist/components/table/snice-column.js +4 -4
- package/dist/components/table/snice-column.js.map +1 -1
- package/dist/components/table/snice-header.d.ts +2 -2
- package/dist/components/table/snice-header.js +8 -8
- package/dist/components/table/snice-header.js.map +1 -1
- package/dist/components/table/snice-progress.d.ts +2 -2
- package/dist/components/table/snice-progress.js +8 -8
- package/dist/components/table/snice-progress.js.map +1 -1
- package/dist/components/table/snice-rating.d.ts +2 -2
- package/dist/components/table/snice-rating.js +8 -8
- package/dist/components/table/snice-rating.js.map +1 -1
- package/dist/components/table/snice-row.d.ts +2 -2
- package/dist/components/table/snice-row.js +8 -8
- package/dist/components/table/snice-row.js.map +1 -1
- package/dist/components/table/snice-table.d.ts +2 -3
- package/dist/components/table/snice-table.js +8 -13
- package/dist/components/table/snice-table.js.map +1 -1
- package/dist/components/tabs/snice-tab-panel.d.ts +2 -2
- package/dist/components/tabs/snice-tab-panel.js +8 -8
- package/dist/components/tabs/snice-tab-panel.js.map +1 -1
- package/dist/components/tabs/snice-tab.d.ts +2 -2
- package/dist/components/tabs/snice-tab.js +8 -8
- package/dist/components/tabs/snice-tab.js.map +1 -1
- package/dist/components/tabs/snice-tabs.d.ts +2 -2
- package/dist/components/tabs/snice-tabs.js +8 -8
- package/dist/components/tabs/snice-tabs.js.map +1 -1
- package/dist/components/terminal/snice-terminal.types.d.ts +133 -0
- package/dist/components/textarea/snice-textarea.d.ts +2 -2
- package/dist/components/textarea/snice-textarea.js +8 -8
- package/dist/components/textarea/snice-textarea.js.map +1 -1
- package/dist/components/timeline/snice-timeline.d.ts +1 -1
- package/dist/components/timeline/snice-timeline.js +5 -5
- package/dist/components/timeline/snice-timeline.js.map +1 -1
- package/dist/components/toast/snice-toast-container.d.ts +2 -2
- package/dist/components/toast/snice-toast-container.js +8 -8
- package/dist/components/toast/snice-toast-container.js.map +1 -1
- package/dist/components/toast/snice-toast.d.ts +2 -2
- package/dist/components/toast/snice-toast.js +8 -8
- package/dist/components/toast/snice-toast.js.map +1 -1
- package/dist/components/tooltip/snice-tooltip.d.ts +2 -2
- package/dist/components/tooltip/snice-tooltip.js +8 -8
- package/dist/components/tooltip/snice-tooltip.js.map +1 -1
- package/dist/components/tree/snice-tree-item.d.ts +35 -0
- package/dist/components/tree/snice-tree-item.js +301 -0
- package/dist/components/tree/snice-tree-item.js.map +1 -0
- package/dist/components/tree/snice-tree-item.types.d.ts +30 -0
- package/dist/components/tree/snice-tree.d.ts +45 -0
- package/dist/components/tree/snice-tree.js +390 -0
- package/dist/components/tree/snice-tree.js.map +1 -0
- package/dist/components/tree/snice-tree.types.d.ts +65 -0
- package/dist/components/virtual-scroller/snice-virtual-scroller.d.ts +31 -0
- package/dist/components/virtual-scroller/snice-virtual-scroller.js +160 -0
- package/dist/components/virtual-scroller/snice-virtual-scroller.js.map +1 -0
- package/dist/components/virtual-scroller/snice-virtual-scroller.types.d.ts +19 -0
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +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/actions.md +81 -0
- package/docs/ai/components/audio-recorder.md +97 -0
- package/docs/ai/components/calendar.md +95 -0
- package/docs/ai/components/camera.md +130 -0
- package/docs/ai/components/carousel.md +49 -0
- package/docs/ai/components/chart.md +160 -0
- package/docs/ai/components/chat.md +189 -0
- package/docs/ai/components/code-block.md +32 -0
- package/docs/ai/components/command-palette.md +117 -0
- package/docs/ai/components/doc.md +154 -0
- package/docs/ai/components/draw.md +140 -0
- package/docs/ai/components/gantt.md +95 -0
- package/docs/ai/components/kanban.md +102 -0
- package/docs/ai/components/layout.md +261 -0
- package/docs/ai/components/list.md +50 -0
- package/docs/ai/components/location.md +75 -0
- package/docs/ai/components/menu.md +114 -0
- package/docs/ai/components/popover.md +70 -0
- package/docs/ai/components/qr-code.md +106 -0
- package/docs/ai/components/split-pane.md +71 -0
- package/docs/ai/components/stat.md +29 -0
- package/docs/ai/components/tree.md +191 -0
- package/docs/ai/components/virtual-scroller.md +71 -0
- package/docs/components/actions.md +317 -0
- package/docs/components/alert.md +540 -0
- package/docs/components/audio-recorder.md +152 -0
- package/docs/components/badge.md +593 -0
- package/docs/components/breadcrumbs.md +568 -0
- package/docs/components/button.md +648 -0
- package/docs/components/calendar.md +397 -0
- package/docs/components/camera.md +383 -0
- package/docs/components/card.md +778 -0
- package/docs/components/carousel.md +63 -0
- package/docs/components/chart.md +526 -0
- package/docs/components/chat.md +482 -0
- package/docs/components/checkbox.md +714 -0
- package/docs/components/chip.md +670 -0
- package/docs/components/code-block.md +49 -0
- package/docs/components/command-palette.md +159 -0
- package/docs/components/doc.md +357 -0
- package/docs/components/draw.md +307 -0
- package/docs/components/gantt.md +347 -0
- package/docs/components/kanban.md +410 -0
- package/docs/components/list.md +65 -0
- package/docs/components/location.md +369 -0
- package/docs/components/menu.md +633 -0
- package/docs/components/popover.md +333 -0
- package/docs/components/qr-code.md +464 -0
- package/docs/components/split-pane.md +315 -0
- package/docs/components/stat.md +45 -0
- package/docs/components/tree.md +536 -0
- package/docs/components/virtual-scroller.md +298 -0
- package/package.json +1 -1
|
@@ -0,0 +1,940 @@
|
|
|
1
|
+
import { __runInitializers, __esDecorate } from 'tslib';
|
|
2
|
+
import { element, property, query, styles, render, css, html } from 'snice';
|
|
3
|
+
|
|
4
|
+
var chartStyles = ":host{display:block;width:100%;height:400px;position:relative;font-family:var(--font-family, system-ui, -apple-system, sans-serif)}.chart-container{width:100%;height:100%;position:relative;display:flex;flex-direction:column}.chart-canvas{flex:1;position:relative;overflow:hidden}svg{width:100%;height:100%}.chart-legend{display:flex;gap:16px;padding:12px;flex-wrap:wrap}.chart-legend.legend-top{order:-1}.chart-legend.legend-bottom{order:1}.chart-legend.legend-left{flex-direction:column;position:absolute;left:0;top:50%;transform:translateY(-50%)}.chart-legend.legend-right{flex-direction:column;position:absolute;right:0;top:50%;transform:translateY(-50%)}.legend-item{display:flex;align-items:center;gap:8px;cursor:pointer;user-select:none;transition:opacity .2s}.legend-item:hover{opacity:.8}.legend-item.hidden{opacity:.5;text-decoration:line-through}.legend-color{width:16px;height:16px;border-radius:2px}.legend-label{font-size:14px;color:var(--text-color,#333)}.chart-tooltip{position:absolute;background:var(--tooltip-bg,rgba(0,0,0,.9));color:var(--tooltip-color,#fff);padding:8px 12px;border-radius:4px;font-size:12px;pointer-events:none;white-space:nowrap;z-index:1000;opacity:0;transition:opacity .2s}.chart-tooltip.visible{opacity:1}.axis-label{font-size:12px;fill:var(--axis-color,#666)}.axis-line{stroke:var(--axis-color,#666);stroke-width:1}.grid-line{stroke:var(--grid-color,#e0e0e0);stroke-width:1;stroke-dasharray:2,2}.data-point{transition:r .2s,opacity .2s}.data-point:hover{r:6;cursor:pointer}.chart-bar,.chart-path{transition:opacity .2s}.chart-slice{transition:opacity .2s;cursor:pointer}.chart-slice:hover{opacity:.8}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes scaleIn{from{transform:scale(0)}to{transform:scale(1)}}.animated .chart-bar,.animated .chart-path,.animated .chart-slice,.animated .data-point{animation:.5s ease-out fadeIn}.animated .chart-slice{transform-origin:center;animation:.5s ease-out scaleIn}";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_OPTIONS = {
|
|
7
|
+
responsive: true,
|
|
8
|
+
maintainAspectRatio: false,
|
|
9
|
+
legend: { position: 'top', clickable: true },
|
|
10
|
+
tooltip: { trigger: 'hover' },
|
|
11
|
+
animation: { enabled: true, duration: 500, easing: 'ease-out' },
|
|
12
|
+
xAxis: { grid: true },
|
|
13
|
+
yAxis: { grid: true }
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_COLORS = [
|
|
16
|
+
'#2196f3', '#4caf50', '#ff9800', '#f44336', '#9c27b0',
|
|
17
|
+
'#00bcd4', '#8bc34a', '#ffc107', '#e91e63', '#673ab7'
|
|
18
|
+
];
|
|
19
|
+
let SniceChart = (() => {
|
|
20
|
+
let _classDecorators = [element('snice-chart')];
|
|
21
|
+
let _classDescriptor;
|
|
22
|
+
let _classExtraInitializers = [];
|
|
23
|
+
let _classThis;
|
|
24
|
+
let _classSuper = HTMLElement;
|
|
25
|
+
let _instanceExtraInitializers = [];
|
|
26
|
+
let _type_decorators;
|
|
27
|
+
let _type_initializers = [];
|
|
28
|
+
let _type_extraInitializers = [];
|
|
29
|
+
let _datasets_decorators;
|
|
30
|
+
let _datasets_initializers = [];
|
|
31
|
+
let _datasets_extraInitializers = [];
|
|
32
|
+
let _labels_decorators;
|
|
33
|
+
let _labels_initializers = [];
|
|
34
|
+
let _labels_extraInitializers = [];
|
|
35
|
+
let _options_decorators;
|
|
36
|
+
let _options_initializers = [];
|
|
37
|
+
let _options_extraInitializers = [];
|
|
38
|
+
let _width_decorators;
|
|
39
|
+
let _width_initializers = [];
|
|
40
|
+
let _width_extraInitializers = [];
|
|
41
|
+
let _height_decorators;
|
|
42
|
+
let _height_initializers = [];
|
|
43
|
+
let _height_extraInitializers = [];
|
|
44
|
+
let _renderTrigger_decorators;
|
|
45
|
+
let _renderTrigger_initializers = [];
|
|
46
|
+
let _renderTrigger_extraInitializers = [];
|
|
47
|
+
let _canvasElement_decorators;
|
|
48
|
+
let _canvasElement_initializers = [];
|
|
49
|
+
let _canvasElement_extraInitializers = [];
|
|
50
|
+
let _tooltipVisible_decorators;
|
|
51
|
+
let _tooltipVisible_initializers = [];
|
|
52
|
+
let _tooltipVisible_extraInitializers = [];
|
|
53
|
+
let _tooltipContent_decorators;
|
|
54
|
+
let _tooltipContent_initializers = [];
|
|
55
|
+
let _tooltipContent_extraInitializers = [];
|
|
56
|
+
let _tooltipX_decorators;
|
|
57
|
+
let _tooltipX_initializers = [];
|
|
58
|
+
let _tooltipX_extraInitializers = [];
|
|
59
|
+
let _tooltipY_decorators;
|
|
60
|
+
let _tooltipY_initializers = [];
|
|
61
|
+
let _tooltipY_extraInitializers = [];
|
|
62
|
+
let _styles_decorators;
|
|
63
|
+
let _render_decorators;
|
|
64
|
+
(class extends _classSuper {
|
|
65
|
+
static { _classThis = this; }
|
|
66
|
+
constructor() {
|
|
67
|
+
super(...arguments);
|
|
68
|
+
this.type = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _type_initializers, 'line'));
|
|
69
|
+
this.datasets = (__runInitializers(this, _type_extraInitializers), __runInitializers(this, _datasets_initializers, []));
|
|
70
|
+
this.labels = (__runInitializers(this, _datasets_extraInitializers), __runInitializers(this, _labels_initializers, []));
|
|
71
|
+
this.options = (__runInitializers(this, _labels_extraInitializers), __runInitializers(this, _options_initializers, DEFAULT_OPTIONS));
|
|
72
|
+
this.width = (__runInitializers(this, _options_extraInitializers), __runInitializers(this, _width_initializers, 0));
|
|
73
|
+
this.height = (__runInitializers(this, _width_extraInitializers), __runInitializers(this, _height_initializers, 0));
|
|
74
|
+
this.hiddenDatasets = (__runInitializers(this, _height_extraInitializers), new Set());
|
|
75
|
+
this.renderTrigger = __runInitializers(this, _renderTrigger_initializers, 0);
|
|
76
|
+
this.canvasElement = (__runInitializers(this, _renderTrigger_extraInitializers), __runInitializers(this, _canvasElement_initializers, void 0));
|
|
77
|
+
this.tooltipVisible = (__runInitializers(this, _canvasElement_extraInitializers), __runInitializers(this, _tooltipVisible_initializers, false));
|
|
78
|
+
this.tooltipContent = (__runInitializers(this, _tooltipVisible_extraInitializers), __runInitializers(this, _tooltipContent_initializers, ''));
|
|
79
|
+
this.tooltipX = (__runInitializers(this, _tooltipContent_extraInitializers), __runInitializers(this, _tooltipX_initializers, 0));
|
|
80
|
+
this.tooltipY = (__runInitializers(this, _tooltipX_extraInitializers), __runInitializers(this, _tooltipY_initializers, 0));
|
|
81
|
+
this.canvas = (__runInitializers(this, _tooltipY_extraInitializers), null);
|
|
82
|
+
this.ctx = null;
|
|
83
|
+
}
|
|
84
|
+
static {
|
|
85
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
86
|
+
_type_decorators = [property({ type: String })];
|
|
87
|
+
_datasets_decorators = [property({ type: Array, attribute: false })];
|
|
88
|
+
_labels_decorators = [property({ type: Array, attribute: false })];
|
|
89
|
+
_options_decorators = [property({ type: Object, attribute: false })];
|
|
90
|
+
_width_decorators = [property({ type: Number })];
|
|
91
|
+
_height_decorators = [property({ type: Number })];
|
|
92
|
+
_renderTrigger_decorators = [property({ type: Number, attribute: false })];
|
|
93
|
+
_canvasElement_decorators = [query('.chart-render-canvas')];
|
|
94
|
+
_tooltipVisible_decorators = [property({ type: Boolean, attribute: false })];
|
|
95
|
+
_tooltipContent_decorators = [property({ type: String, attribute: false })];
|
|
96
|
+
_tooltipX_decorators = [property({ type: Number, attribute: false })];
|
|
97
|
+
_tooltipY_decorators = [property({ type: Number, attribute: false })];
|
|
98
|
+
_styles_decorators = [styles()];
|
|
99
|
+
_render_decorators = [render()];
|
|
100
|
+
__esDecorate(this, null, _styles_decorators, { kind: "method", name: "styles", static: false, private: false, access: { has: obj => "styles" in obj, get: obj => obj.styles }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
101
|
+
__esDecorate(this, null, _render_decorators, { kind: "method", name: "render", static: false, private: false, access: { has: obj => "render" in obj, get: obj => obj.render }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
102
|
+
__esDecorate(null, null, _type_decorators, { kind: "field", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
|
|
103
|
+
__esDecorate(null, null, _datasets_decorators, { kind: "field", name: "datasets", static: false, private: false, access: { has: obj => "datasets" in obj, get: obj => obj.datasets, set: (obj, value) => { obj.datasets = value; } }, metadata: _metadata }, _datasets_initializers, _datasets_extraInitializers);
|
|
104
|
+
__esDecorate(null, null, _labels_decorators, { kind: "field", name: "labels", static: false, private: false, access: { has: obj => "labels" in obj, get: obj => obj.labels, set: (obj, value) => { obj.labels = value; } }, metadata: _metadata }, _labels_initializers, _labels_extraInitializers);
|
|
105
|
+
__esDecorate(null, null, _options_decorators, { kind: "field", name: "options", static: false, private: false, access: { has: obj => "options" in obj, get: obj => obj.options, set: (obj, value) => { obj.options = value; } }, metadata: _metadata }, _options_initializers, _options_extraInitializers);
|
|
106
|
+
__esDecorate(null, null, _width_decorators, { kind: "field", name: "width", static: false, private: false, access: { has: obj => "width" in obj, get: obj => obj.width, set: (obj, value) => { obj.width = value; } }, metadata: _metadata }, _width_initializers, _width_extraInitializers);
|
|
107
|
+
__esDecorate(null, null, _height_decorators, { kind: "field", name: "height", static: false, private: false, access: { has: obj => "height" in obj, get: obj => obj.height, set: (obj, value) => { obj.height = value; } }, metadata: _metadata }, _height_initializers, _height_extraInitializers);
|
|
108
|
+
__esDecorate(null, null, _renderTrigger_decorators, { kind: "field", name: "renderTrigger", static: false, private: false, access: { has: obj => "renderTrigger" in obj, get: obj => obj.renderTrigger, set: (obj, value) => { obj.renderTrigger = value; } }, metadata: _metadata }, _renderTrigger_initializers, _renderTrigger_extraInitializers);
|
|
109
|
+
__esDecorate(null, null, _canvasElement_decorators, { kind: "field", name: "canvasElement", static: false, private: false, access: { has: obj => "canvasElement" in obj, get: obj => obj.canvasElement, set: (obj, value) => { obj.canvasElement = value; } }, metadata: _metadata }, _canvasElement_initializers, _canvasElement_extraInitializers);
|
|
110
|
+
__esDecorate(null, null, _tooltipVisible_decorators, { kind: "field", name: "tooltipVisible", static: false, private: false, access: { has: obj => "tooltipVisible" in obj, get: obj => obj.tooltipVisible, set: (obj, value) => { obj.tooltipVisible = value; } }, metadata: _metadata }, _tooltipVisible_initializers, _tooltipVisible_extraInitializers);
|
|
111
|
+
__esDecorate(null, null, _tooltipContent_decorators, { kind: "field", name: "tooltipContent", static: false, private: false, access: { has: obj => "tooltipContent" in obj, get: obj => obj.tooltipContent, set: (obj, value) => { obj.tooltipContent = value; } }, metadata: _metadata }, _tooltipContent_initializers, _tooltipContent_extraInitializers);
|
|
112
|
+
__esDecorate(null, null, _tooltipX_decorators, { kind: "field", name: "tooltipX", static: false, private: false, access: { has: obj => "tooltipX" in obj, get: obj => obj.tooltipX, set: (obj, value) => { obj.tooltipX = value; } }, metadata: _metadata }, _tooltipX_initializers, _tooltipX_extraInitializers);
|
|
113
|
+
__esDecorate(null, null, _tooltipY_decorators, { kind: "field", name: "tooltipY", static: false, private: false, access: { has: obj => "tooltipY" in obj, get: obj => obj.tooltipY, set: (obj, value) => { obj.tooltipY = value; } }, metadata: _metadata }, _tooltipY_initializers, _tooltipY_extraInitializers);
|
|
114
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
115
|
+
_classThis = _classDescriptor.value;
|
|
116
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
117
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
118
|
+
}
|
|
119
|
+
styles() {
|
|
120
|
+
return css /*css*/ `${chartStyles}`;
|
|
121
|
+
}
|
|
122
|
+
render() {
|
|
123
|
+
const legendPosition = this.options.legend?.position || 'top';
|
|
124
|
+
const animated = this.options.animation?.enabled !== false;
|
|
125
|
+
// Draw chart after render
|
|
126
|
+
requestAnimationFrame(() => this.initAndDrawChart());
|
|
127
|
+
return html `
|
|
128
|
+
<div class="chart-container ${animated ? 'animated' : ''}">
|
|
129
|
+
${legendPosition !== 'none' ? this.renderLegend() : ''}
|
|
130
|
+
<div class="chart-canvas">
|
|
131
|
+
<canvas class="chart-render-canvas"></canvas>
|
|
132
|
+
</div>
|
|
133
|
+
<div class="chart-tooltip ${this.tooltipVisible ? 'visible' : ''}"
|
|
134
|
+
style="left: ${this.tooltipX}px; top: ${this.tooltipY}px;">
|
|
135
|
+
${this.tooltipContent}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
renderLegend() {
|
|
141
|
+
const position = this.options.legend?.position || 'top';
|
|
142
|
+
return html `
|
|
143
|
+
<div class="chart-legend legend-${position}">
|
|
144
|
+
${this.datasets.map((dataset, index) => html `
|
|
145
|
+
<div class="legend-item ${this.hiddenDatasets.has(index) ? 'hidden' : ''}"
|
|
146
|
+
@click=${() => this.handleLegendClick(index)}>
|
|
147
|
+
<div class="legend-color" style="background: ${this.getDatasetColor(dataset, index)};"></div>
|
|
148
|
+
<span class="legend-label">${dataset.label}</span>
|
|
149
|
+
</div>
|
|
150
|
+
`)}
|
|
151
|
+
</div>
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
initAndDrawChart() {
|
|
155
|
+
this.canvas = this.canvasElement || null;
|
|
156
|
+
if (!this.canvas)
|
|
157
|
+
return;
|
|
158
|
+
const width = this.width || this.offsetWidth || 600;
|
|
159
|
+
const height = this.height || this.offsetHeight || 400;
|
|
160
|
+
this.canvas.width = width;
|
|
161
|
+
this.canvas.height = height;
|
|
162
|
+
this.canvas.style.width = `${width}px`;
|
|
163
|
+
this.canvas.style.height = `${height}px`;
|
|
164
|
+
this.ctx = this.canvas.getContext('2d');
|
|
165
|
+
if (!this.ctx || !this.datasets.length)
|
|
166
|
+
return;
|
|
167
|
+
// Clear canvas
|
|
168
|
+
this.ctx.clearRect(0, 0, width, height);
|
|
169
|
+
const chartType = this.type;
|
|
170
|
+
switch (chartType) {
|
|
171
|
+
case 'pie':
|
|
172
|
+
case 'donut':
|
|
173
|
+
this.drawPieChart(width, height, chartType === 'donut');
|
|
174
|
+
break;
|
|
175
|
+
case 'radar':
|
|
176
|
+
this.drawRadarChart(width, height);
|
|
177
|
+
break;
|
|
178
|
+
default:
|
|
179
|
+
this.drawCartesianChart(width, height);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
drawCartesianChart(width, height) {
|
|
183
|
+
if (!this.ctx)
|
|
184
|
+
return;
|
|
185
|
+
const padding = { top: 40, right: 40, bottom: 60, left: 60 };
|
|
186
|
+
const chartWidth = width - padding.left - padding.right;
|
|
187
|
+
const chartHeight = height - padding.top - padding.bottom;
|
|
188
|
+
const { min: yMin, max: yMax } = this.getYAxisRange();
|
|
189
|
+
const xCount = this.getXAxisCount();
|
|
190
|
+
// Draw grid
|
|
191
|
+
this.drawGrid(padding, chartWidth, chartHeight, yMin, yMax, xCount);
|
|
192
|
+
// Draw axes
|
|
193
|
+
this.drawAxes(padding, chartWidth, chartHeight, yMin, yMax, xCount);
|
|
194
|
+
// Draw datasets
|
|
195
|
+
this.ctx.save();
|
|
196
|
+
this.ctx.translate(padding.left, padding.top);
|
|
197
|
+
this.datasets.forEach((dataset, index) => {
|
|
198
|
+
if (this.hiddenDatasets.has(index))
|
|
199
|
+
return;
|
|
200
|
+
this.drawDataset(dataset, index, chartWidth, chartHeight, yMin, yMax, xCount);
|
|
201
|
+
});
|
|
202
|
+
this.ctx.restore();
|
|
203
|
+
}
|
|
204
|
+
drawGrid(padding, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
205
|
+
if (!this.ctx || (!this.options.xAxis?.grid && !this.options.yAxis?.grid))
|
|
206
|
+
return;
|
|
207
|
+
this.ctx.strokeStyle = '#e0e0e0';
|
|
208
|
+
this.ctx.lineWidth = 1;
|
|
209
|
+
const yTicks = this.options.yAxis?.ticks || 5;
|
|
210
|
+
if (this.options.yAxis?.grid) {
|
|
211
|
+
for (let i = 0; i <= yTicks; i++) {
|
|
212
|
+
const y = padding.top + (chartHeight / yTicks) * i;
|
|
213
|
+
this.ctx.beginPath();
|
|
214
|
+
this.ctx.moveTo(padding.left, y);
|
|
215
|
+
this.ctx.lineTo(padding.left + chartWidth, y);
|
|
216
|
+
this.ctx.stroke();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (this.options.xAxis?.grid) {
|
|
220
|
+
for (let i = 0; i <= xCount; i++) {
|
|
221
|
+
const x = padding.left + (chartWidth / xCount) * i;
|
|
222
|
+
this.ctx.beginPath();
|
|
223
|
+
this.ctx.moveTo(x, padding.top);
|
|
224
|
+
this.ctx.lineTo(x, padding.top + chartHeight);
|
|
225
|
+
this.ctx.stroke();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
drawAxes(padding, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
230
|
+
if (!this.ctx)
|
|
231
|
+
return;
|
|
232
|
+
this.ctx.strokeStyle = '#333';
|
|
233
|
+
this.ctx.lineWidth = 2;
|
|
234
|
+
// Y axis
|
|
235
|
+
this.ctx.beginPath();
|
|
236
|
+
this.ctx.moveTo(padding.left, padding.top);
|
|
237
|
+
this.ctx.lineTo(padding.left, padding.top + chartHeight);
|
|
238
|
+
this.ctx.stroke();
|
|
239
|
+
// X axis
|
|
240
|
+
this.ctx.beginPath();
|
|
241
|
+
this.ctx.moveTo(padding.left, padding.top + chartHeight);
|
|
242
|
+
this.ctx.lineTo(padding.left + chartWidth, padding.top + chartHeight);
|
|
243
|
+
this.ctx.stroke();
|
|
244
|
+
// Y axis labels
|
|
245
|
+
this.ctx.fillStyle = '#666';
|
|
246
|
+
this.ctx.font = '12px sans-serif';
|
|
247
|
+
this.ctx.textAlign = 'right';
|
|
248
|
+
this.ctx.textBaseline = 'middle';
|
|
249
|
+
const yTicks = this.options.yAxis?.ticks || 5;
|
|
250
|
+
for (let i = 0; i <= yTicks; i++) {
|
|
251
|
+
const value = yMax - (yMax - yMin) / yTicks * i;
|
|
252
|
+
const y = padding.top + (chartHeight / yTicks) * i;
|
|
253
|
+
this.ctx.fillText(value.toFixed(1), padding.left - 10, y);
|
|
254
|
+
}
|
|
255
|
+
// X axis labels - align with line chart points
|
|
256
|
+
this.ctx.textAlign = 'center';
|
|
257
|
+
this.ctx.textBaseline = 'top';
|
|
258
|
+
const numLabels = this.labels.length;
|
|
259
|
+
if (numLabels > 0) {
|
|
260
|
+
const spacing = chartWidth / (numLabels - 1 || 1);
|
|
261
|
+
for (let i = 0; i < numLabels; i++) {
|
|
262
|
+
const x = padding.left + spacing * i;
|
|
263
|
+
const label = this.labels[i] || i.toString();
|
|
264
|
+
this.ctx.fillText(label, x, padding.top + chartHeight + 10);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
drawDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
269
|
+
const chartType = dataset.type || this.type;
|
|
270
|
+
switch (chartType) {
|
|
271
|
+
case 'line':
|
|
272
|
+
this.drawLineDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
273
|
+
break;
|
|
274
|
+
case 'area':
|
|
275
|
+
this.drawAreaDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
276
|
+
break;
|
|
277
|
+
case 'bar':
|
|
278
|
+
this.drawBarDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax, xCount);
|
|
279
|
+
break;
|
|
280
|
+
case 'scatter':
|
|
281
|
+
this.drawScatterDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
drawLineDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
286
|
+
if (!this.ctx)
|
|
287
|
+
return;
|
|
288
|
+
const points = this.getDataPoints(dataset, chartWidth, chartHeight, yMin, yMax);
|
|
289
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
290
|
+
const borderWidth = dataset.borderWidth || 2;
|
|
291
|
+
const pointRadius = dataset.pointRadius !== undefined ? dataset.pointRadius : 4;
|
|
292
|
+
if (points.length === 0)
|
|
293
|
+
return;
|
|
294
|
+
// Draw line
|
|
295
|
+
this.ctx.strokeStyle = dataset.borderColor || color;
|
|
296
|
+
this.ctx.lineWidth = borderWidth;
|
|
297
|
+
this.ctx.beginPath();
|
|
298
|
+
this.ctx.moveTo(points[0].x, points[0].y);
|
|
299
|
+
points.slice(1).forEach(p => this.ctx.lineTo(p.x, p.y));
|
|
300
|
+
this.ctx.stroke();
|
|
301
|
+
// Draw points
|
|
302
|
+
this.ctx.fillStyle = color;
|
|
303
|
+
points.forEach(p => {
|
|
304
|
+
this.ctx.beginPath();
|
|
305
|
+
this.ctx.arc(p.x, p.y, pointRadius, 0, Math.PI * 2);
|
|
306
|
+
this.ctx.fill();
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
drawAreaDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
310
|
+
if (!this.ctx)
|
|
311
|
+
return;
|
|
312
|
+
const points = this.getDataPoints(dataset, chartWidth, chartHeight, yMin, yMax);
|
|
313
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
314
|
+
if (points.length === 0)
|
|
315
|
+
return;
|
|
316
|
+
// Draw filled area
|
|
317
|
+
const bgColor = dataset.backgroundColor;
|
|
318
|
+
this.ctx.fillStyle = (Array.isArray(bgColor) ? bgColor[0] : bgColor) || color;
|
|
319
|
+
this.ctx.globalAlpha = 0.3;
|
|
320
|
+
this.ctx.beginPath();
|
|
321
|
+
this.ctx.moveTo(points[0].x, chartHeight);
|
|
322
|
+
this.ctx.lineTo(points[0].x, points[0].y);
|
|
323
|
+
points.slice(1).forEach(p => this.ctx.lineTo(p.x, p.y));
|
|
324
|
+
this.ctx.lineTo(points[points.length - 1].x, chartHeight);
|
|
325
|
+
this.ctx.closePath();
|
|
326
|
+
this.ctx.fill();
|
|
327
|
+
this.ctx.globalAlpha = 1;
|
|
328
|
+
// Draw line
|
|
329
|
+
this.drawLineDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
330
|
+
}
|
|
331
|
+
drawBarDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
332
|
+
if (!this.ctx)
|
|
333
|
+
return;
|
|
334
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
335
|
+
const visibleCount = this.datasets.filter((_, i) => !this.hiddenDatasets.has(i)).length;
|
|
336
|
+
const visibleDatasets = this.datasets.filter((_, i) => !this.hiddenDatasets.has(i));
|
|
337
|
+
const datasetOffset = visibleDatasets.indexOf(dataset);
|
|
338
|
+
const numBars = dataset.data.length;
|
|
339
|
+
const spacing = chartWidth / Math.max(numBars - 1, 1);
|
|
340
|
+
const maxBarGroupWidth = spacing * 0.6;
|
|
341
|
+
const barGroupWidth = Math.min(maxBarGroupWidth, 80);
|
|
342
|
+
const singleBarWidth = barGroupWidth / visibleCount;
|
|
343
|
+
dataset.data.forEach((value, index) => {
|
|
344
|
+
const y = typeof value === 'number' ? value : value.y || 0;
|
|
345
|
+
const barHeight = ((y - yMin) / (yMax - yMin)) * chartHeight;
|
|
346
|
+
const labelX = spacing * index;
|
|
347
|
+
let x = labelX - barGroupWidth / 2 + datasetOffset * singleBarWidth;
|
|
348
|
+
if (x < 0)
|
|
349
|
+
x = 0;
|
|
350
|
+
if (x + singleBarWidth > chartWidth)
|
|
351
|
+
x = chartWidth - singleBarWidth;
|
|
352
|
+
const barY = chartHeight - barHeight;
|
|
353
|
+
this.ctx.fillStyle = Array.isArray(dataset.backgroundColor)
|
|
354
|
+
? dataset.backgroundColor[index % dataset.backgroundColor.length]
|
|
355
|
+
: color;
|
|
356
|
+
this.ctx.fillRect(x, barY, singleBarWidth, barHeight);
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
drawScatterDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
360
|
+
this.drawLineDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
361
|
+
}
|
|
362
|
+
drawPieChart(width, height, isDonut) {
|
|
363
|
+
if (!this.ctx || !this.datasets[0])
|
|
364
|
+
return;
|
|
365
|
+
const centerX = width / 2;
|
|
366
|
+
const centerY = height / 2;
|
|
367
|
+
const radius = Math.min(width, height) / 2 - 40;
|
|
368
|
+
const innerRadius = isDonut ? radius * 0.6 : 0;
|
|
369
|
+
const dataset = this.datasets[0];
|
|
370
|
+
const total = dataset.data.reduce((sum, val) => {
|
|
371
|
+
const numVal = typeof val === 'number' ? val : 0;
|
|
372
|
+
return sum + numVal;
|
|
373
|
+
}, 0);
|
|
374
|
+
let currentAngle = -Math.PI / 2;
|
|
375
|
+
dataset.data.forEach((value, index) => {
|
|
376
|
+
const val = typeof value === 'number' ? value : 0;
|
|
377
|
+
const angle = total > 0 ? (val / total) * 2 * Math.PI : 0;
|
|
378
|
+
const endAngle = currentAngle + angle;
|
|
379
|
+
const color = Array.isArray(dataset.backgroundColor)
|
|
380
|
+
? dataset.backgroundColor[index % dataset.backgroundColor.length]
|
|
381
|
+
: DEFAULT_COLORS[index % DEFAULT_COLORS.length];
|
|
382
|
+
this.ctx.fillStyle = color;
|
|
383
|
+
this.ctx.beginPath();
|
|
384
|
+
this.ctx.arc(centerX, centerY, radius, currentAngle, endAngle);
|
|
385
|
+
if (isDonut) {
|
|
386
|
+
this.ctx.arc(centerX, centerY, innerRadius, endAngle, currentAngle, true);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
this.ctx.lineTo(centerX, centerY);
|
|
390
|
+
}
|
|
391
|
+
this.ctx.closePath();
|
|
392
|
+
this.ctx.fill();
|
|
393
|
+
currentAngle = endAngle;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
drawRadarChart(width, height) {
|
|
397
|
+
if (!this.ctx)
|
|
398
|
+
return;
|
|
399
|
+
const centerX = width / 2;
|
|
400
|
+
const centerY = height / 2;
|
|
401
|
+
const radius = Math.min(width, height) / 2 - 60;
|
|
402
|
+
const numPoints = this.labels.length || this.datasets[0]?.data.length || 3;
|
|
403
|
+
const angleStep = (2 * Math.PI) / numPoints;
|
|
404
|
+
const maxValue = Math.max(...this.datasets.flatMap(d => d.data.map(v => typeof v === 'number' ? v : 0)));
|
|
405
|
+
// Draw grid
|
|
406
|
+
this.ctx.strokeStyle = '#e0e0e0';
|
|
407
|
+
[0.2, 0.4, 0.6, 0.8, 1].forEach(ratio => {
|
|
408
|
+
const r = radius * ratio;
|
|
409
|
+
this.ctx.beginPath();
|
|
410
|
+
for (let i = 0; i <= numPoints; i++) {
|
|
411
|
+
const angle = i * angleStep - Math.PI / 2;
|
|
412
|
+
const x = centerX + Math.cos(angle) * r;
|
|
413
|
+
const y = centerY + Math.sin(angle) * r;
|
|
414
|
+
if (i === 0) {
|
|
415
|
+
this.ctx.moveTo(x, y);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
this.ctx.lineTo(x, y);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
this.ctx.closePath();
|
|
422
|
+
this.ctx.stroke();
|
|
423
|
+
});
|
|
424
|
+
// Draw axes
|
|
425
|
+
for (let i = 0; i < numPoints; i++) {
|
|
426
|
+
const angle = i * angleStep - Math.PI / 2;
|
|
427
|
+
const x = centerX + Math.cos(angle) * radius;
|
|
428
|
+
const y = centerY + Math.sin(angle) * radius;
|
|
429
|
+
this.ctx.beginPath();
|
|
430
|
+
this.ctx.moveTo(centerX, centerY);
|
|
431
|
+
this.ctx.lineTo(x, y);
|
|
432
|
+
this.ctx.stroke();
|
|
433
|
+
// Labels
|
|
434
|
+
this.ctx.fillStyle = '#666';
|
|
435
|
+
this.ctx.font = '12px sans-serif';
|
|
436
|
+
this.ctx.textAlign = 'center';
|
|
437
|
+
this.ctx.fillText(this.labels[i] || i.toString(), x, y);
|
|
438
|
+
}
|
|
439
|
+
// Draw data
|
|
440
|
+
this.datasets.forEach((dataset, datasetIndex) => {
|
|
441
|
+
if (this.hiddenDatasets.has(datasetIndex))
|
|
442
|
+
return;
|
|
443
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
444
|
+
this.ctx.fillStyle = color;
|
|
445
|
+
this.ctx.globalAlpha = 0.3;
|
|
446
|
+
this.ctx.beginPath();
|
|
447
|
+
dataset.data.forEach((value, index) => {
|
|
448
|
+
const val = typeof value === 'number' ? value : 0;
|
|
449
|
+
const angle = index * angleStep - Math.PI / 2;
|
|
450
|
+
const r = (val / maxValue) * radius;
|
|
451
|
+
const x = centerX + Math.cos(angle) * r;
|
|
452
|
+
const y = centerY + Math.sin(angle) * r;
|
|
453
|
+
if (index === 0) {
|
|
454
|
+
this.ctx.moveTo(x, y);
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
this.ctx.lineTo(x, y);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
this.ctx.closePath();
|
|
461
|
+
this.ctx.fill();
|
|
462
|
+
this.ctx.globalAlpha = 1;
|
|
463
|
+
this.ctx.strokeStyle = dataset.borderColor || color;
|
|
464
|
+
this.ctx.lineWidth = dataset.borderWidth || 2;
|
|
465
|
+
this.ctx.stroke();
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
renderCartesianChartSVG() {
|
|
469
|
+
const padding = { top: 40, right: 40, bottom: 60, left: 60 };
|
|
470
|
+
const width = this.width || this.offsetWidth || 600;
|
|
471
|
+
const height = this.height || this.offsetHeight || 400;
|
|
472
|
+
const chartWidth = width - padding.left - padding.right;
|
|
473
|
+
const chartHeight = height - padding.top - padding.bottom;
|
|
474
|
+
const { min: yMin, max: yMax } = this.getYAxisRange();
|
|
475
|
+
const xCount = this.getXAxisCount();
|
|
476
|
+
const gridSVG = this.renderCartesianGridSVG(padding, chartWidth, chartHeight, yMin, yMax, xCount);
|
|
477
|
+
const axesSVG = this.renderCartesianAxesSVG(padding, chartWidth, chartHeight, yMin, yMax, xCount);
|
|
478
|
+
const datasetsSVG = this.datasets
|
|
479
|
+
.map((dataset, index) => this.hiddenDatasets.has(index) ? '' :
|
|
480
|
+
this.renderDatasetSVG(dataset, index, chartWidth, chartHeight, yMin, yMax, xCount))
|
|
481
|
+
.join('');
|
|
482
|
+
return `
|
|
483
|
+
<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
484
|
+
${gridSVG}
|
|
485
|
+
${axesSVG}
|
|
486
|
+
<g transform="translate(${padding.left}, ${padding.top})">
|
|
487
|
+
${datasetsSVG}
|
|
488
|
+
</g>
|
|
489
|
+
</svg>
|
|
490
|
+
`;
|
|
491
|
+
}
|
|
492
|
+
renderCartesianGridSVG(padding, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
493
|
+
if (!this.options.xAxis?.grid && !this.options.yAxis?.grid)
|
|
494
|
+
return '';
|
|
495
|
+
const yTicks = this.options.yAxis?.ticks || 5;
|
|
496
|
+
let gridSVG = '';
|
|
497
|
+
if (this.options.yAxis?.grid) {
|
|
498
|
+
for (let i = 0; i <= yTicks; i++) {
|
|
499
|
+
const y = padding.top + (chartHeight / yTicks) * i;
|
|
500
|
+
gridSVG += `<line class="grid-line" x1="${padding.left}" y1="${y}" x2="${padding.left + chartWidth}" y2="${y}" stroke="#e0e0e0" />`;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if (this.options.xAxis?.grid) {
|
|
504
|
+
for (let i = 0; i <= xCount; i++) {
|
|
505
|
+
const x = padding.left + (chartWidth / xCount) * i;
|
|
506
|
+
gridSVG += `<line class="grid-line" x1="${x}" y1="${padding.top}" x2="${x}" y2="${padding.top + chartHeight}" stroke="#e0e0e0" />`;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return gridSVG;
|
|
510
|
+
}
|
|
511
|
+
renderCartesianAxesSVG(padding, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
512
|
+
const yTicks = this.options.yAxis?.ticks || 5;
|
|
513
|
+
let axesSVG = '';
|
|
514
|
+
// Y axis
|
|
515
|
+
axesSVG += `<line class="axis-line" x1="${padding.left}" y1="${padding.top}" x2="${padding.left}" y2="${padding.top + chartHeight}" stroke="#333" />`;
|
|
516
|
+
// Y axis labels
|
|
517
|
+
for (let i = 0; i <= yTicks; i++) {
|
|
518
|
+
const value = yMax - (yMax - yMin) / yTicks * i;
|
|
519
|
+
const y = padding.top + (chartHeight / yTicks) * i;
|
|
520
|
+
axesSVG += `<text class="axis-label" x="${padding.left - 10}" y="${y}" text-anchor="end" alignment-baseline="middle" fill="#666" font-size="12">${value.toFixed(1)}</text>`;
|
|
521
|
+
}
|
|
522
|
+
// X axis
|
|
523
|
+
axesSVG += `<line class="axis-line" x1="${padding.left}" y1="${padding.top + chartHeight}" x2="${padding.left + chartWidth}" y2="${padding.top + chartHeight}" stroke="#333" />`;
|
|
524
|
+
// X axis labels
|
|
525
|
+
for (let i = 0; i <= xCount; i++) {
|
|
526
|
+
const x = padding.left + (chartWidth / xCount) * i;
|
|
527
|
+
const label = this.labels[i] || i.toString();
|
|
528
|
+
axesSVG += `<text class="axis-label" x="${x}" y="${padding.top + chartHeight + 20}" text-anchor="middle" fill="#666" font-size="12">${label}</text>`;
|
|
529
|
+
}
|
|
530
|
+
return axesSVG;
|
|
531
|
+
}
|
|
532
|
+
renderDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
533
|
+
const chartType = dataset.type || this.type;
|
|
534
|
+
switch (chartType) {
|
|
535
|
+
case 'line':
|
|
536
|
+
return this.renderLineDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
537
|
+
case 'area':
|
|
538
|
+
return this.renderAreaDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
539
|
+
case 'bar':
|
|
540
|
+
return this.renderBarDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax, xCount);
|
|
541
|
+
case 'scatter':
|
|
542
|
+
return this.renderScatterDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
543
|
+
case 'bubble':
|
|
544
|
+
return this.renderBubbleDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
545
|
+
default:
|
|
546
|
+
return this.renderLineDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
renderLineDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
550
|
+
const points = this.getDataPoints(dataset, chartWidth, chartHeight, yMin, yMax);
|
|
551
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
552
|
+
const borderWidth = dataset.borderWidth || 2;
|
|
553
|
+
const pointRadius = dataset.pointRadius !== undefined ? dataset.pointRadius : 4;
|
|
554
|
+
if (points.length === 0)
|
|
555
|
+
return '';
|
|
556
|
+
const pathD = `M ${points.map(p => `${p.x} ${p.y}`).join(' L ')}`;
|
|
557
|
+
const circlesSVG = points.map(p => `<circle cx="${p.x}" cy="${p.y}" r="${pointRadius}" fill="${color}" />`).join('');
|
|
558
|
+
return `<path d="${pathD}" fill="none" stroke="${dataset.borderColor || color}" stroke-width="${borderWidth}" />${circlesSVG}`;
|
|
559
|
+
}
|
|
560
|
+
renderAreaDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
561
|
+
return this.renderLineDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
562
|
+
}
|
|
563
|
+
renderBarDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
564
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
565
|
+
const barWidth = (chartWidth / xCount) * 0.8 / this.datasets.filter((_, i) => !this.hiddenDatasets.has(i)).length;
|
|
566
|
+
return dataset.data.map((value, index) => {
|
|
567
|
+
const y = typeof value === 'number' ? value : value.y || 0;
|
|
568
|
+
const barHeight = ((y - yMin) / (yMax - yMin)) * chartHeight;
|
|
569
|
+
const x = (chartWidth / xCount) * index;
|
|
570
|
+
const barY = chartHeight - barHeight;
|
|
571
|
+
return `<rect x="${x}" y="${barY}" width="${barWidth}" height="${barHeight}" fill="${color}" />`;
|
|
572
|
+
}).join('');
|
|
573
|
+
}
|
|
574
|
+
renderScatterDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
575
|
+
return this.renderLineDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
576
|
+
}
|
|
577
|
+
renderBubbleDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
578
|
+
return this.renderLineDatasetSVG(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax);
|
|
579
|
+
}
|
|
580
|
+
renderPieChartSVG(isDonut) {
|
|
581
|
+
return '<svg width="600" height="400"><text x="300" y="200" text-anchor="middle">Pie chart placeholder</text></svg>';
|
|
582
|
+
}
|
|
583
|
+
renderRadarChartSVG() {
|
|
584
|
+
return '<svg width="600" height="400"><text x="300" y="200" text-anchor="middle">Radar chart placeholder</text></svg>';
|
|
585
|
+
}
|
|
586
|
+
renderLineDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
587
|
+
const points = this.getDataPoints(dataset, chartWidth, chartHeight, yMin, yMax);
|
|
588
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
589
|
+
const borderWidth = dataset.borderWidth || 2;
|
|
590
|
+
const pointRadius = dataset.pointRadius !== undefined ? dataset.pointRadius : 4;
|
|
591
|
+
const tension = dataset.tension || 0;
|
|
592
|
+
let pathD = '';
|
|
593
|
+
if (points.length > 0) {
|
|
594
|
+
pathD = `M ${points[0].x} ${points[0].y}`;
|
|
595
|
+
if (tension > 0) {
|
|
596
|
+
// Smooth curve
|
|
597
|
+
for (let i = 1; i < points.length; i++) {
|
|
598
|
+
const prev = points[i - 1];
|
|
599
|
+
const curr = points[i];
|
|
600
|
+
const cpx = prev.x + (curr.x - prev.x) * 0.5;
|
|
601
|
+
pathD += ` Q ${cpx} ${prev.y}, ${cpx} ${curr.y}`;
|
|
602
|
+
pathD += ` Q ${cpx} ${curr.y}, ${curr.x} ${curr.y}`;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
// Straight lines
|
|
607
|
+
points.slice(1).forEach(p => {
|
|
608
|
+
pathD += ` L ${p.x} ${p.y}`;
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return html `
|
|
613
|
+
<path class="chart-path"
|
|
614
|
+
d="${pathD}"
|
|
615
|
+
fill="none"
|
|
616
|
+
stroke="${dataset.borderColor || color}"
|
|
617
|
+
stroke-width="${borderWidth}" />
|
|
618
|
+
${points.map((p, i) => html `
|
|
619
|
+
<circle class="data-point"
|
|
620
|
+
cx="${p.x}"
|
|
621
|
+
cy="${p.y}"
|
|
622
|
+
r="${pointRadius}"
|
|
623
|
+
fill="${color}"
|
|
624
|
+
@mouseenter=${(e) => this.showTooltip(dataset, i, e)}
|
|
625
|
+
@mouseleave=${() => this.hideTooltip()} />
|
|
626
|
+
`)}
|
|
627
|
+
`;
|
|
628
|
+
}
|
|
629
|
+
renderAreaDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
630
|
+
const points = this.getDataPoints(dataset, chartWidth, chartHeight, yMin, yMax);
|
|
631
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
632
|
+
const borderWidth = dataset.borderWidth || 2;
|
|
633
|
+
if (points.length === 0)
|
|
634
|
+
return '';
|
|
635
|
+
let pathD = `M ${points[0].x} ${chartHeight}`;
|
|
636
|
+
pathD += ` L ${points[0].x} ${points[0].y}`;
|
|
637
|
+
points.slice(1).forEach(p => {
|
|
638
|
+
pathD += ` L ${p.x} ${p.y}`;
|
|
639
|
+
});
|
|
640
|
+
pathD += ` L ${points[points.length - 1].x} ${chartHeight} Z`;
|
|
641
|
+
const lineD = points.map((p, i) => i === 0 ? `M ${p.x} ${p.y}` : `L ${p.x} ${p.y}`).join(' ');
|
|
642
|
+
return html `
|
|
643
|
+
<path class="chart-path"
|
|
644
|
+
d="${pathD}"
|
|
645
|
+
fill="${dataset.backgroundColor || color}"
|
|
646
|
+
fill-opacity="0.3" />
|
|
647
|
+
<path class="chart-path"
|
|
648
|
+
d="${lineD}"
|
|
649
|
+
fill="none"
|
|
650
|
+
stroke="${dataset.borderColor || color}"
|
|
651
|
+
stroke-width="${borderWidth}" />
|
|
652
|
+
`;
|
|
653
|
+
}
|
|
654
|
+
renderBarDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax, xCount) {
|
|
655
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
656
|
+
const barWidth = (chartWidth / xCount) * 0.8 / this.datasets.filter((_, i) => !this.hiddenDatasets.has(i)).length;
|
|
657
|
+
const visibleDatasets = this.datasets.filter((_, i) => !this.hiddenDatasets.has(i));
|
|
658
|
+
const datasetOffset = visibleDatasets.indexOf(dataset);
|
|
659
|
+
return html `
|
|
660
|
+
${dataset.data.map((value, index) => {
|
|
661
|
+
const y = typeof value === 'number' ? value : value.y || 0;
|
|
662
|
+
const barHeight = ((y - yMin) / (yMax - yMin)) * chartHeight;
|
|
663
|
+
const x = (chartWidth / xCount) * index + datasetOffset * barWidth + (chartWidth / xCount) * 0.1;
|
|
664
|
+
const barY = chartHeight - barHeight;
|
|
665
|
+
return html `
|
|
666
|
+
<rect class="chart-bar"
|
|
667
|
+
x="${x}"
|
|
668
|
+
y="${barY}"
|
|
669
|
+
width="${barWidth}"
|
|
670
|
+
height="${barHeight}"
|
|
671
|
+
fill="${Array.isArray(dataset.backgroundColor) ? dataset.backgroundColor[index % dataset.backgroundColor.length] : color}"
|
|
672
|
+
@mouseenter=${(e) => this.showTooltip(dataset, index, e)}
|
|
673
|
+
@mouseleave=${() => this.hideTooltip()} />
|
|
674
|
+
`;
|
|
675
|
+
})}
|
|
676
|
+
`;
|
|
677
|
+
}
|
|
678
|
+
renderBarChart(horizontal) {
|
|
679
|
+
// Similar to renderBarDataset but with swapped axes
|
|
680
|
+
return this.renderCartesianChartSVG();
|
|
681
|
+
}
|
|
682
|
+
renderScatterDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
683
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
684
|
+
const pointRadius = dataset.pointRadius !== undefined ? dataset.pointRadius : 4;
|
|
685
|
+
return html `
|
|
686
|
+
${dataset.data.map((value, index) => {
|
|
687
|
+
const point = typeof value === 'object' ? value : { x: index, y: value };
|
|
688
|
+
const x = typeof point.x === 'number' ? (point.x / (this.getXAxisCount())) * chartWidth : 0;
|
|
689
|
+
const y = chartHeight - ((point.y - yMin) / (yMax - yMin)) * chartHeight;
|
|
690
|
+
return html `
|
|
691
|
+
<circle class="data-point"
|
|
692
|
+
cx="${x}"
|
|
693
|
+
cy="${y}"
|
|
694
|
+
r="${pointRadius}"
|
|
695
|
+
fill="${color}"
|
|
696
|
+
@mouseenter=${(e) => this.showTooltip(dataset, index, e)}
|
|
697
|
+
@mouseleave=${() => this.hideTooltip()} />
|
|
698
|
+
`;
|
|
699
|
+
})}
|
|
700
|
+
`;
|
|
701
|
+
}
|
|
702
|
+
renderBubbleDataset(dataset, datasetIndex, chartWidth, chartHeight, yMin, yMax) {
|
|
703
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
704
|
+
const maxR = Math.max(...dataset.data.map(v => typeof v === 'object' ? v.r || 5 : 5));
|
|
705
|
+
return html `
|
|
706
|
+
${dataset.data.map((value, index) => {
|
|
707
|
+
const point = value;
|
|
708
|
+
const x = typeof point.x === 'number' ? (point.x / this.getXAxisCount()) * chartWidth : 0;
|
|
709
|
+
const y = chartHeight - ((point.y - yMin) / (yMax - yMin)) * chartHeight;
|
|
710
|
+
const r = ((point.r || 5) / maxR) * 20;
|
|
711
|
+
return html `
|
|
712
|
+
<circle class="data-point"
|
|
713
|
+
cx="${x}"
|
|
714
|
+
cy="${y}"
|
|
715
|
+
r="${r}"
|
|
716
|
+
fill="${color}"
|
|
717
|
+
fill-opacity="0.6"
|
|
718
|
+
@mouseenter=${(e) => this.showTooltip(dataset, index, e)}
|
|
719
|
+
@mouseleave=${() => this.hideTooltip()} />
|
|
720
|
+
`;
|
|
721
|
+
})}
|
|
722
|
+
`;
|
|
723
|
+
}
|
|
724
|
+
renderPieChart(isDonut) {
|
|
725
|
+
const width = this.width || this.offsetWidth || 600;
|
|
726
|
+
const height = this.height || this.offsetHeight || 400;
|
|
727
|
+
const centerX = width / 2;
|
|
728
|
+
const centerY = height / 2;
|
|
729
|
+
const radius = Math.min(width, height) / 2 - 40;
|
|
730
|
+
const innerRadius = isDonut ? radius * 0.6 : 0;
|
|
731
|
+
const dataset = this.datasets[0];
|
|
732
|
+
if (!dataset)
|
|
733
|
+
return html `<svg></svg>`;
|
|
734
|
+
const total = dataset.data.reduce((sum, val) => {
|
|
735
|
+
const numVal = typeof val === 'number' ? val : 0;
|
|
736
|
+
return sum + numVal;
|
|
737
|
+
}, 0);
|
|
738
|
+
let currentAngle = -Math.PI / 2;
|
|
739
|
+
return html `
|
|
740
|
+
<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
741
|
+
${dataset.data.map((value, index) => {
|
|
742
|
+
const val = typeof value === 'number' ? value : 0;
|
|
743
|
+
const angle = total > 0 ? (val / total) * 2 * Math.PI : 0;
|
|
744
|
+
const endAngle = currentAngle + angle;
|
|
745
|
+
const x1 = centerX + Math.cos(currentAngle) * radius;
|
|
746
|
+
const y1 = centerY + Math.sin(currentAngle) * radius;
|
|
747
|
+
const x2 = centerX + Math.cos(endAngle) * radius;
|
|
748
|
+
const y2 = centerY + Math.sin(endAngle) * radius;
|
|
749
|
+
const largeArc = angle > Math.PI ? 1 : 0;
|
|
750
|
+
let pathD = `M ${centerX} ${centerY} L ${x1} ${y1} A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2} Z`;
|
|
751
|
+
if (isDonut) {
|
|
752
|
+
const ix1 = centerX + Math.cos(currentAngle) * innerRadius;
|
|
753
|
+
const iy1 = centerY + Math.sin(currentAngle) * innerRadius;
|
|
754
|
+
const ix2 = centerX + Math.cos(endAngle) * innerRadius;
|
|
755
|
+
const iy2 = centerY + Math.sin(endAngle) * innerRadius;
|
|
756
|
+
pathD = `M ${x1} ${y1} A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2} L ${ix2} ${iy2} A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${ix1} ${iy1} Z`;
|
|
757
|
+
}
|
|
758
|
+
const color = Array.isArray(dataset.backgroundColor)
|
|
759
|
+
? dataset.backgroundColor[index % dataset.backgroundColor.length]
|
|
760
|
+
: DEFAULT_COLORS[index % DEFAULT_COLORS.length];
|
|
761
|
+
const result = html `
|
|
762
|
+
<path class="chart-slice"
|
|
763
|
+
d="${pathD}"
|
|
764
|
+
fill="${color}"
|
|
765
|
+
@mouseenter=${(e) => this.showTooltip(dataset, index, e)}
|
|
766
|
+
@mouseleave=${() => this.hideTooltip()} />
|
|
767
|
+
`;
|
|
768
|
+
currentAngle = endAngle;
|
|
769
|
+
return result;
|
|
770
|
+
})}
|
|
771
|
+
</svg>
|
|
772
|
+
`;
|
|
773
|
+
}
|
|
774
|
+
renderRadarChart() {
|
|
775
|
+
const width = this.width || this.offsetWidth || 600;
|
|
776
|
+
const height = this.height || this.offsetHeight || 400;
|
|
777
|
+
const centerX = width / 2;
|
|
778
|
+
const centerY = height / 2;
|
|
779
|
+
const radius = Math.min(width, height) / 2 - 60;
|
|
780
|
+
const numPoints = this.labels.length || this.datasets[0]?.data.length || 3;
|
|
781
|
+
const angleStep = (2 * Math.PI) / numPoints;
|
|
782
|
+
const maxValue = Math.max(...this.datasets.flatMap(d => d.data.map(v => typeof v === 'number' ? v : 0)));
|
|
783
|
+
return html `
|
|
784
|
+
<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
785
|
+
<!-- Radar grid -->
|
|
786
|
+
${[0.2, 0.4, 0.6, 0.8, 1].map(ratio => {
|
|
787
|
+
const r = radius * ratio;
|
|
788
|
+
const points = Array.from({ length: numPoints }, (_, i) => {
|
|
789
|
+
const angle = i * angleStep - Math.PI / 2;
|
|
790
|
+
return `${centerX + Math.cos(angle) * r},${centerY + Math.sin(angle) * r}`;
|
|
791
|
+
}).join(' ');
|
|
792
|
+
return html `<polygon points="${points}" fill="none" stroke="#e0e0e0" />`;
|
|
793
|
+
})}
|
|
794
|
+
|
|
795
|
+
<!-- Axes -->
|
|
796
|
+
${Array.from({ length: numPoints }, (_, i) => {
|
|
797
|
+
const angle = i * angleStep - Math.PI / 2;
|
|
798
|
+
const x = centerX + Math.cos(angle) * radius;
|
|
799
|
+
const y = centerY + Math.sin(angle) * radius;
|
|
800
|
+
return html `
|
|
801
|
+
<line class="grid-line" x1="${centerX}" y1="${centerY}" x2="${x}" y2="${y}" />
|
|
802
|
+
<text class="axis-label" x="${x}" y="${y}" text-anchor="middle">
|
|
803
|
+
${this.labels[i] || i}
|
|
804
|
+
</text>
|
|
805
|
+
`;
|
|
806
|
+
})}
|
|
807
|
+
|
|
808
|
+
<!-- Data -->
|
|
809
|
+
${this.datasets.map((dataset, datasetIndex) => {
|
|
810
|
+
if (this.hiddenDatasets.has(datasetIndex))
|
|
811
|
+
return '';
|
|
812
|
+
const points = dataset.data.map((value, index) => {
|
|
813
|
+
const val = typeof value === 'number' ? value : 0;
|
|
814
|
+
const angle = index * angleStep - Math.PI / 2;
|
|
815
|
+
const r = (val / maxValue) * radius;
|
|
816
|
+
return `${centerX + Math.cos(angle) * r},${centerY + Math.sin(angle) * r}`;
|
|
817
|
+
}).join(' ');
|
|
818
|
+
const color = this.getDatasetColor(dataset, datasetIndex);
|
|
819
|
+
return html `
|
|
820
|
+
<polygon class="chart-path"
|
|
821
|
+
points="${points}"
|
|
822
|
+
fill="${color}"
|
|
823
|
+
fill-opacity="0.3"
|
|
824
|
+
stroke="${dataset.borderColor || color}"
|
|
825
|
+
stroke-width="${dataset.borderWidth || 2}" />
|
|
826
|
+
`;
|
|
827
|
+
})}
|
|
828
|
+
</svg>
|
|
829
|
+
`;
|
|
830
|
+
}
|
|
831
|
+
getDataPoints(dataset, chartWidth, chartHeight, yMin, yMax) {
|
|
832
|
+
return dataset.data.map((value, index) => {
|
|
833
|
+
const y = typeof value === 'number' ? value : value.y || 0;
|
|
834
|
+
return {
|
|
835
|
+
x: (chartWidth / (dataset.data.length - 1 || 1)) * index,
|
|
836
|
+
y: chartHeight - ((y - yMin) / (yMax - yMin)) * chartHeight
|
|
837
|
+
};
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
getYAxisRange() {
|
|
841
|
+
const allValues = this.datasets.flatMap((dataset, index) => this.hiddenDatasets.has(index) ? [] :
|
|
842
|
+
dataset.data.map(v => typeof v === 'number' ? v : v.y || 0));
|
|
843
|
+
const min = this.options.yAxis?.min !== undefined ? this.options.yAxis.min : Math.min(0, ...allValues);
|
|
844
|
+
const max = this.options.yAxis?.max !== undefined ? this.options.yAxis.max : Math.max(...allValues);
|
|
845
|
+
return { min, max };
|
|
846
|
+
}
|
|
847
|
+
getXAxisCount() {
|
|
848
|
+
return Math.max(this.labels.length - 1, ...this.datasets.map(d => d.data.length - 1)) || 1;
|
|
849
|
+
}
|
|
850
|
+
getDatasetColor(dataset, index) {
|
|
851
|
+
if (dataset.backgroundColor && !Array.isArray(dataset.backgroundColor)) {
|
|
852
|
+
return dataset.backgroundColor;
|
|
853
|
+
}
|
|
854
|
+
if (dataset.borderColor) {
|
|
855
|
+
return dataset.borderColor;
|
|
856
|
+
}
|
|
857
|
+
return DEFAULT_COLORS[index % DEFAULT_COLORS.length];
|
|
858
|
+
}
|
|
859
|
+
handleLegendClick(index) {
|
|
860
|
+
if (!this.options.legend?.clickable)
|
|
861
|
+
return;
|
|
862
|
+
this.toggleDataset(index);
|
|
863
|
+
}
|
|
864
|
+
showTooltip(dataset, index, event) {
|
|
865
|
+
if (this.options.tooltip?.trigger === 'none')
|
|
866
|
+
return;
|
|
867
|
+
const value = dataset.data[index];
|
|
868
|
+
this.labels[index] || index;
|
|
869
|
+
let content = '';
|
|
870
|
+
if (this.options.tooltip?.format) {
|
|
871
|
+
content = this.options.tooltip.format(value, this.datasets.indexOf(dataset), index);
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
const val = typeof value === 'number' ? value : value.y;
|
|
875
|
+
content = `${dataset.label}: ${val}`;
|
|
876
|
+
}
|
|
877
|
+
this.tooltipContent = content;
|
|
878
|
+
this.tooltipX = event.offsetX + 10;
|
|
879
|
+
this.tooltipY = event.offsetY - 30;
|
|
880
|
+
this.tooltipVisible = true;
|
|
881
|
+
}
|
|
882
|
+
hideTooltip() {
|
|
883
|
+
this.tooltipVisible = false;
|
|
884
|
+
}
|
|
885
|
+
refresh() {
|
|
886
|
+
// Force re-render by updating datasets reference
|
|
887
|
+
this.datasets = [...this.datasets];
|
|
888
|
+
}
|
|
889
|
+
update(datasets) {
|
|
890
|
+
this.datasets = datasets;
|
|
891
|
+
requestAnimationFrame(() => this.initAndDrawChart());
|
|
892
|
+
}
|
|
893
|
+
addDataset(dataset) {
|
|
894
|
+
this.datasets = [...this.datasets, dataset];
|
|
895
|
+
}
|
|
896
|
+
removeDataset(index) {
|
|
897
|
+
this.datasets = this.datasets.filter((_, i) => i !== index);
|
|
898
|
+
this.hiddenDatasets.delete(index);
|
|
899
|
+
}
|
|
900
|
+
toggleDataset(index) {
|
|
901
|
+
if (this.hiddenDatasets.has(index)) {
|
|
902
|
+
this.hiddenDatasets.delete(index);
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
this.hiddenDatasets.add(index);
|
|
906
|
+
}
|
|
907
|
+
// Trigger re-render
|
|
908
|
+
this.renderTrigger++;
|
|
909
|
+
}
|
|
910
|
+
exportImage(format = 'svg') {
|
|
911
|
+
if (format === 'svg') {
|
|
912
|
+
// Return the last generated SVG content
|
|
913
|
+
if (!this.datasets.length)
|
|
914
|
+
return '';
|
|
915
|
+
const chartType = this.type;
|
|
916
|
+
switch (chartType) {
|
|
917
|
+
case 'pie':
|
|
918
|
+
case 'donut':
|
|
919
|
+
return this.renderPieChartSVG(chartType === 'donut');
|
|
920
|
+
case 'radar':
|
|
921
|
+
return this.renderRadarChartSVG();
|
|
922
|
+
default:
|
|
923
|
+
return this.renderCartesianChartSVG();
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
// For PNG, would need canvas conversion
|
|
927
|
+
return '';
|
|
928
|
+
}
|
|
929
|
+
getData() {
|
|
930
|
+
return {
|
|
931
|
+
datasets: this.datasets,
|
|
932
|
+
labels: this.labels
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
return _classThis;
|
|
937
|
+
})();
|
|
938
|
+
|
|
939
|
+
export { SniceChart };
|
|
940
|
+
//# sourceMappingURL=snice-chart.js.map
|