@eifi1/ui-kit 0.54.0 → 0.56.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/README.md +90 -76
- package/dist/admin/plan-change.js +2 -2
- package/dist/admin/plan-change.js.map +1 -1
- package/dist/admin/user-roster.d.ts +6 -0
- package/dist/admin/user-roster.js +4 -0
- package/dist/admin/user-roster.js.map +1 -1
- package/dist/billing/billing-labels.d.ts +26 -0
- package/dist/billing/billing-labels.js +9 -0
- package/dist/billing/billing-labels.js.map +1 -1
- package/dist/billing/subscription-standing.d.ts +61 -0
- package/dist/billing/subscription-standing.js +51 -0
- package/dist/billing/subscription-standing.js.map +1 -0
- package/dist/billing/usage-meter.d.ts +52 -0
- package/dist/billing/usage-meter.js +52 -0
- package/dist/billing/usage-meter.js.map +1 -0
- package/dist/chart.d.ts +1 -0
- package/dist/chart.js +4 -0
- package/dist/chart.js.map +1 -1
- package/dist/components/alert-banner.js +2 -3
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.js +3 -15
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.js +2 -2
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/bulk-action-bar.js +2 -1
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button.d.ts +35 -1
- package/dist/components/button.js +6 -9
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-heatmap.js +2 -2
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/camera-button.d.ts +89 -0
- package/dist/components/camera-button.js +122 -0
- package/dist/components/camera-button.js.map +1 -0
- package/dist/components/camera-capture.d.ts +66 -0
- package/dist/components/camera-capture.js +190 -0
- package/dist/components/camera-capture.js.map +1 -0
- package/dist/components/camera-labels.d.ts +20 -0
- package/dist/components/camera-labels.js +15 -0
- package/dist/components/camera-labels.js.map +1 -0
- package/dist/components/chart-edge.d.ts +9 -0
- package/dist/components/chart-edge.js +14 -3
- package/dist/components/chart-edge.js.map +1 -1
- package/dist/components/chart-zoom-core.js +34 -29
- package/dist/components/chart-zoom-core.js.map +1 -1
- package/dist/components/checkbox-group.js +1 -1
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/combobox-core.js +3 -2
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.js +2 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/consent-again-notice-labels.d.ts +25 -0
- package/dist/components/consent-again-notice-labels.js +15 -0
- package/dist/components/consent-again-notice-labels.js.map +1 -0
- package/dist/components/consent-again-notice.d.ts +85 -0
- package/dist/components/consent-again-notice.js +94 -0
- package/dist/components/consent-again-notice.js.map +1 -0
- package/dist/components/country-select.js +2 -7
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-select.js +2 -2
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.js +2 -2
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-column-settings.js +2 -2
- package/dist/components/data-table-column-settings.js.map +1 -1
- package/dist/components/data-table-fit.js.map +1 -1
- package/dist/components/data-table-virtual.js +13 -3
- package/dist/components/data-table-virtual.js.map +1 -1
- package/dist/components/date-field.js +2 -2
- package/dist/components/date-field.js.map +1 -1
- package/dist/components/date-picker.js +2 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.js +2 -6
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +3 -1
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/dropdown.js +7 -3
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.js +2 -2
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/field-parts.d.ts +108 -6
- package/dist/components/field-parts.js +59 -6
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-suggestion-labels.d.ts +2 -0
- package/dist/components/field-suggestion-labels.js +10 -0
- package/dist/components/field-suggestion-labels.js.map +1 -0
- package/dist/components/field.js +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-button.d.ts +1 -1
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/floating-panel.d.ts +7 -6
- package/dist/components/floating-panel.js +3 -17
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +3 -2
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/hover-menu.js +3 -2
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-button.d.ts +23 -5
- package/dist/components/icon-button.js +7 -8
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/inline-confirm.js +2 -1
- package/dist/components/inline-confirm.js.map +1 -1
- package/dist/components/inline-entity-combobox.js +2 -2
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.js +2 -2
- package/dist/components/input.js.map +1 -1
- package/dist/components/jump-calendar.js +3 -3
- package/dist/components/jump-calendar.js.map +1 -1
- package/dist/components/legal.d.ts +13 -1
- package/dist/components/legal.js +12 -0
- package/dist/components/legal.js.map +1 -1
- package/dist/components/legended-series-chart.d.ts +83 -0
- package/dist/components/legended-series-chart.js +77 -0
- package/dist/components/legended-series-chart.js.map +1 -0
- package/dist/components/lightbox.js +2 -1
- package/dist/components/lightbox.js.map +1 -1
- package/dist/components/mini-calendar.js +13 -5
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +23 -2
- package/dist/components/modal.js +24 -6
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +1 -1
- package/dist/components/month-picker.js +6 -6
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.js +2 -2
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.js +2 -6
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-input.js +2 -2
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/page-header-layout.d.ts +18 -0
- package/dist/components/page-header-layout.js +23 -0
- package/dist/components/page-header-layout.js.map +1 -0
- package/dist/components/page-header-skeleton.d.ts +41 -0
- package/dist/components/page-header-skeleton.js +52 -0
- package/dist/components/page-header-skeleton.js.map +1 -0
- package/dist/components/page-header.js +4 -17
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/popover.js +7 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/release-notes-labels.d.ts +16 -0
- package/dist/components/release-notes-labels.js +18 -0
- package/dist/components/release-notes-labels.js.map +1 -0
- package/dist/components/release-notes.d.ts +65 -0
- package/dist/components/release-notes.js +65 -0
- package/dist/components/release-notes.js.map +1 -0
- package/dist/components/select.js +2 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +9 -0
- package/dist/components/series-chart-labels.js +3 -1
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +5 -0
- package/dist/components/series-chart.js +89 -36
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/toggle-group.js +3 -2
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/treemap-layout.js.map +1 -1
- package/dist/components/treemap.d.ts +17 -15
- package/dist/components/treemap.js +167 -85
- package/dist/components/treemap.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/eslint/role-utilities.d.ts +2 -2
- package/dist/eslint/role-utilities.js.map +1 -1
- package/dist/feedback/feedback-inbox-page.d.ts +260 -0
- package/dist/feedback/feedback-inbox-page.js +207 -0
- package/dist/feedback/feedback-inbox-page.js.map +1 -0
- package/dist/feedback/feedback-vocabulary.js +2 -2
- package/dist/feedback/feedback-vocabulary.js.map +1 -1
- package/dist/feedback.d.ts +1 -0
- package/dist/feedback.js +6 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-debounce.d.ts +32 -5
- package/dist/hooks/use-debounce.js +6 -5
- package/dist/hooks/use-debounce.js.map +1 -1
- package/dist/hooks/use-file-picker.d.ts +3 -1
- package/dist/hooks/use-file-picker.js.map +1 -1
- package/dist/hooks/use-focus-trap.d.ts +19 -3
- package/dist/hooks/use-focus-trap.js +15 -5
- package/dist/hooks/use-focus-trap.js.map +1 -1
- package/dist/hooks/use-has-camera.d.ts +36 -0
- package/dist/hooks/use-has-camera.js +53 -0
- package/dist/hooks/use-has-camera.js.map +1 -0
- package/dist/hooks/use-hotkey.js +1 -10
- package/dist/hooks/use-hotkey.js.map +1 -1
- package/dist/hooks/use-overlay-history.d.ts +6 -1
- package/dist/hooks/use-overlay-history.js +10 -2
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.js +11 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +75 -3
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +20 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +92 -4
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +71 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +72 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +74 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +74 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +71 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +22 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +24 -5
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/landing/landing-labels.d.ts +8 -0
- package/dist/landing/landing-labels.js +2 -1
- package/dist/landing/landing-labels.js.map +1 -1
- package/dist/lib/changelog.d.ts +130 -0
- package/dist/lib/changelog.js +137 -0
- package/dist/lib/changelog.js.map +1 -0
- package/dist/lib/clipboard-minus.js +2 -2
- package/dist/lib/clipboard-minus.js.map +1 -1
- package/dist/lib/dates.d.ts +29 -3
- package/dist/lib/dates.js +41 -12
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/editable-content.d.ts +33 -0
- package/dist/lib/editable-content.js +15 -0
- package/dist/lib/editable-content.js.map +1 -0
- package/dist/lib/focus-left.d.ts +47 -1
- package/dist/lib/focus-left.js +11 -2
- package/dist/lib/focus-left.js.map +1 -1
- package/dist/lib/server-wake.d.ts +49 -9
- package/dist/lib/server-wake.js +25 -14
- package/dist/lib/server-wake.js.map +1 -1
- package/dist/lib/session-refresh.d.ts +53 -0
- package/dist/lib/session-refresh.js +27 -1
- package/dist/lib/session-refresh.js.map +1 -1
- package/dist/rhf/fields.js +3 -3
- package/dist/rhf/fields.js.map +1 -1
- package/dist/shell/app-shell.d.ts +25 -1
- package/dist/shell/app-shell.js +3 -1
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/dev-menu.d.ts +3 -0
- package/dist/shell/dev-menu.js +4 -2
- package/dist/shell/dev-menu.js.map +1 -1
- package/dist/shell/held-changes-banner-labels.d.ts +23 -0
- package/dist/shell/held-changes-banner-labels.js +14 -0
- package/dist/shell/held-changes-banner-labels.js.map +1 -0
- package/dist/shell/held-changes-banner.d.ts +75 -0
- package/dist/shell/held-changes-banner.js +106 -0
- package/dist/shell/held-changes-banner.js.map +1 -0
- package/dist/shell/sync-status-indicator.d.ts +27 -12
- package/dist/shell/sync-status-indicator.js +13 -4
- package/dist/shell/sync-status-indicator.js.map +1 -1
- package/dist/shell/top-bar-parts-labels.d.ts +5 -0
- package/dist/shell/top-bar-parts-labels.js +3 -1
- package/dist/shell/top-bar-parts-labels.js.map +1 -1
- package/dist/shell.d.ts +2 -0
- package/dist/shell.js +3 -0
- package/dist/shell.js.map +1 -1
- package/dist/sync/engine.d.ts +11 -2
- package/dist/sync/engine.js +13 -5
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync/hooks.d.ts +3 -2
- package/dist/sync/hooks.js +4 -2
- package/dist/sync/hooks.js.map +1 -1
- package/dist/testing/css-variables.generated.d.ts +2 -2
- package/dist/testing/css-variables.generated.js +1 -1
- package/dist/testing/css-variables.generated.js.map +1 -1
- package/dist/theme/chart-palette.d.ts +18 -0
- package/dist/theme/chart-palette.js +17 -1
- package/dist/theme/chart-palette.js.map +1 -1
- package/dist/theme/contrast-tokens.d.ts +3 -3
- package/dist/theme/contrast-tokens.js.map +1 -1
- package/dist/theme/contrast.d.ts +4 -4
- package/dist/theme/contrast.js.map +1 -1
- package/dist/tour/tour-overlay.js +2 -1
- package/dist/tour/tour-overlay.js.map +1 -1
- package/package.json +9 -12
- package/tokens.css +19 -54
- package/src/account/account-parts.ts +0 -47
- package/src/account/account-settings-labels.ts +0 -240
- package/src/account/account-settings.tsx +0 -698
- package/src/account/data-export-setting-labels.ts +0 -20
- package/src/account/data-export-setting.tsx +0 -200
- package/src/account/delete-account-setting-labels.ts +0 -33
- package/src/account/delete-account-setting.tsx +0 -342
- package/src/account/email-change-setting-labels.ts +0 -31
- package/src/account/email-change-setting.tsx +0 -443
- package/src/account/passkeys-setting.tsx +0 -445
- package/src/account/sessions-setting-labels.ts +0 -24
- package/src/account/sessions-setting.tsx +0 -283
- package/src/admin/admin-action-confirm-labels.ts +0 -19
- package/src/admin/admin-action-confirm.tsx +0 -509
- package/src/admin/admin-action-log-labels.ts +0 -83
- package/src/admin/admin-action-log.tsx +0 -464
- package/src/admin/admin-area-labels.ts +0 -114
- package/src/admin/admin-forbidden.tsx +0 -75
- package/src/admin/admin-overview.tsx +0 -258
- package/src/admin/admin-parts.ts +0 -68
- package/src/admin/admin-sections.tsx +0 -208
- package/src/admin/admin-tool-links.tsx +0 -90
- package/src/admin/invitations-panel-labels.ts +0 -31
- package/src/admin/invitations-panel.tsx +0 -516
- package/src/admin/mail-test-card-labels.ts +0 -19
- package/src/admin/mail-test-card.tsx +0 -189
- package/src/admin/plan-change-labels.ts +0 -5
- package/src/admin/plan-change.tsx +0 -474
- package/src/admin/reviewer-scope-editor-labels.ts +0 -16
- package/src/admin/reviewer-scope-editor.tsx +0 -224
- package/src/admin/role-select-labels.ts +0 -16
- package/src/admin/role-select.tsx +0 -282
- package/src/admin/transfer-ownership-dialog-labels.ts +0 -20
- package/src/admin/transfer-ownership-dialog.tsx +0 -162
- package/src/admin/user-roster-labels.ts +0 -17
- package/src/admin/user-roster.tsx +0 -559
- package/src/auth/accept-invitation-labels.ts +0 -21
- package/src/auth/accept-invitation.tsx +0 -210
- package/src/auth/auth-errors-labels.ts +0 -23
- package/src/auth/auth-errors.ts +0 -439
- package/src/auth/complete-name-dialog-labels.ts +0 -16
- package/src/auth/complete-name-dialog.tsx +0 -253
- package/src/auth/email-tag.ts +0 -75
- package/src/auth/forgot-password-form-labels.ts +0 -20
- package/src/auth/forgot-password-form.tsx +0 -221
- package/src/auth/form-rules.ts +0 -40
- package/src/auth/new-password-fields.tsx +0 -85
- package/src/auth/not-found-page-labels.ts +0 -12
- package/src/auth/not-found-page.tsx +0 -95
- package/src/auth/register-form-labels.ts +0 -31
- package/src/auth/register-form.tsx +0 -456
- package/src/auth/reset-password-form-labels.ts +0 -27
- package/src/auth/reset-password-form.tsx +0 -341
- package/src/auth/sign-in-form-labels.ts +0 -44
- package/src/auth/sign-in-form.tsx +0 -858
- package/src/auth/status-parts.tsx +0 -132
- package/src/auth/verify-email-labels.ts +0 -26
- package/src/auth/verify-email.tsx +0 -445
- package/src/billing/billing-banner.tsx +0 -258
- package/src/billing/billing-labels.ts +0 -381
- package/src/billing/billing-lock.ts +0 -108
- package/src/billing/billing-overview.ts +0 -157
- package/src/billing/billing-standing.ts +0 -80
- package/src/billing/cancel-request.ts +0 -97
- package/src/billing/cancel-subscription.tsx +0 -98
- package/src/billing/checkout-processing.ts +0 -394
- package/src/billing/checkout-return.ts +0 -90
- package/src/billing/pay-page.ts +0 -330
- package/src/billing/plan-card.tsx +0 -562
- package/src/billing/plan-change-labels.ts +0 -66
- package/src/billing/plan-limit-notice.tsx +0 -148
- package/src/billing/plan-limit-toast.tsx +0 -90
- package/src/billing/plan-limit.ts +0 -52
- package/src/billing/plan-price.ts +0 -98
- package/src/billing/plan-switch.tsx +0 -216
- package/src/billing/provider-page.ts +0 -84
- package/src/billing/subscription-actions.tsx +0 -247
- package/src/billing/subscription-status-chip.tsx +0 -95
- package/src/chart.ts +0 -103
- package/src/components/account-chips-labels.ts +0 -16
- package/src/components/account-chips.tsx +0 -474
- package/src/components/alert-banner.tsx +0 -670
- package/src/components/amount-input.tsx +0 -816
- package/src/components/appearance-labels.ts +0 -63
- package/src/components/authed-image-labels.ts +0 -11
- package/src/components/authed-image.tsx +0 -209
- package/src/components/autocomplete.tsx +0 -645
- package/src/components/breadcrumbs-labels.ts +0 -10
- package/src/components/breadcrumbs.tsx +0 -205
- package/src/components/bulk-action-bar-labels.ts +0 -11
- package/src/components/bulk-action-bar.tsx +0 -443
- package/src/components/button-group.tsx +0 -223
- package/src/components/button-look.ts +0 -256
- package/src/components/button.tsx +0 -339
- package/src/components/calculator.tsx +0 -341
- package/src/components/calendar-heatmap-labels.ts +0 -15
- package/src/components/calendar-heatmap.tsx +0 -600
- package/src/components/card.tsx +0 -377
- package/src/components/chart-edge.ts +0 -106
- package/src/components/chart-figure.tsx +0 -35
- package/src/components/chart-height.ts +0 -30
- package/src/components/chart-zoom-core.tsx +0 -627
- package/src/components/chart-zoom.tsx +0 -22
- package/src/components/chart.tsx +0 -554
- package/src/components/checkbox-group.tsx +0 -247
- package/src/components/checkbox.tsx +0 -346
- package/src/components/chip-input.tsx +0 -370
- package/src/components/chip-labels.ts +0 -13
- package/src/components/chip.tsx +0 -843
- package/src/components/choice-card.tsx +0 -544
- package/src/components/column-mapper-labels.ts +0 -38
- package/src/components/column-mapper.tsx +0 -655
- package/src/components/combobox-core.tsx +0 -1321
- package/src/components/combobox-suggestions.tsx +0 -131
- package/src/components/combobox.tsx +0 -716
- package/src/components/confirm-context.ts +0 -7
- package/src/components/confirm-dialog-labels.ts +0 -13
- package/src/components/confirm-dialog.tsx +0 -341
- package/src/components/copy-button-labels.ts +0 -13
- package/src/components/copy-button.tsx +0 -192
- package/src/components/country-select-labels.ts +0 -11
- package/src/components/country-select.tsx +0 -539
- package/src/components/currency-option-list.tsx +0 -188
- package/src/components/currency-select.tsx +0 -343
- package/src/components/danger-confirm-labels.ts +0 -20
- package/src/components/danger-confirm.tsx +0 -987
- package/src/components/data-table-cells.tsx +0 -118
- package/src/components/data-table-column-settings.tsx +0 -198
- package/src/components/data-table-filter-popover.tsx +0 -289
- package/src/components/data-table-filters.ts +0 -315
- package/src/components/data-table-fit.ts +0 -301
- package/src/components/data-table-groups.tsx +0 -288
- package/src/components/data-table-head.tsx +0 -280
- package/src/components/data-table-labels.ts +0 -198
- package/src/components/data-table-leading-row.tsx +0 -58
- package/src/components/data-table-mobile.tsx +0 -1117
- package/src/components/data-table-pagination.tsx +0 -202
- package/src/components/data-table-resize.ts +0 -188
- package/src/components/data-table-row-actions.tsx +0 -302
- package/src/components/data-table-row.tsx +0 -496
- package/src/components/data-table-selection.ts +0 -71
- package/src/components/data-table-shared.tsx +0 -287
- package/src/components/data-table-sort.ts +0 -163
- package/src/components/data-table-virtual.ts +0 -576
- package/src/components/data-table.tsx +0 -2598
- package/src/components/date-field.tsx +0 -684
- package/src/components/date-format-setting.tsx +0 -64
- package/src/components/date-picker.tsx +0 -404
- package/src/components/date-range-picker.tsx +0 -518
- package/src/components/description-list-labels.ts +0 -9
- package/src/components/description-list.tsx +0 -386
- package/src/components/dialog-frame-labels.ts +0 -7
- package/src/components/dialog-frame.tsx +0 -284
- package/src/components/disclosure.tsx +0 -476
- package/src/components/dropdown.tsx +0 -461
- package/src/components/empty-state.tsx +0 -136
- package/src/components/entity-combobox.tsx +0 -422
- package/src/components/error-boundary-labels.ts +0 -20
- package/src/components/error-boundary.tsx +0 -675
- package/src/components/facing-pair.ts +0 -93
- package/src/components/field-base-labels.ts +0 -20
- package/src/components/field-base.tsx +0 -656
- package/src/components/field-parts.tsx +0 -825
- package/src/components/field-strip.tsx +0 -129
- package/src/components/field.tsx +0 -206
- package/src/components/file-button.tsx +0 -295
- package/src/components/file-dropzone.tsx +0 -559
- package/src/components/floating-panel-labels.ts +0 -10
- package/src/components/floating-panel.tsx +0 -828
- package/src/components/focus-ring.ts +0 -16
- package/src/components/form-actions-labels.ts +0 -11
- package/src/components/form-actions.tsx +0 -578
- package/src/components/full-bleed-dialog.tsx +0 -294
- package/src/components/grouped-picker.tsx +0 -184
- package/src/components/help-popover.tsx +0 -117
- package/src/components/hover-menu.tsx +0 -343
- package/src/components/iban-input-labels.ts +0 -14
- package/src/components/iban-input.tsx +0 -236
- package/src/components/icon-button.tsx +0 -959
- package/src/components/icon-picker-labels.ts +0 -13
- package/src/components/icon-picker.tsx +0 -232
- package/src/components/image-grid-labels.ts +0 -11
- package/src/components/image-grid.tsx +0 -202
- package/src/components/inline-confirm.tsx +0 -116
- package/src/components/inline-edit-field-labels.ts +0 -11
- package/src/components/inline-edit-field.tsx +0 -552
- package/src/components/inline-entity-combobox.tsx +0 -849
- package/src/components/input.tsx +0 -394
- package/src/components/jump-calendar.tsx +0 -265
- package/src/components/language-select.tsx +0 -93
- package/src/components/legal-labels.ts +0 -105
- package/src/components/legal-page.tsx +0 -711
- package/src/components/legal.tsx +0 -668
- package/src/components/lightbox-labels.ts +0 -18
- package/src/components/lightbox.tsx +0 -399
- package/src/components/line-items-labels.ts +0 -14
- package/src/components/line-items.tsx +0 -602
- package/src/components/list-labels.ts +0 -12
- package/src/components/list.tsx +0 -870
- package/src/components/loading-state.tsx +0 -78
- package/src/components/measured-grid-labels.ts +0 -25
- package/src/components/measured-grid.tsx +0 -837
- package/src/components/menu-item.tsx +0 -241
- package/src/components/mini-calendar-labels.ts +0 -17
- package/src/components/mini-calendar.tsx +0 -792
- package/src/components/modal.tsx +0 -534
- package/src/components/money-draft.ts +0 -83
- package/src/components/money-field.tsx +0 -76
- package/src/components/month-grid.tsx +0 -229
- package/src/components/month-picker-labels.ts +0 -22
- package/src/components/month-picker.tsx +0 -1087
- package/src/components/multi-entity-combobox.tsx +0 -369
- package/src/components/multi-select.tsx +0 -376
- package/src/components/nav-pills.tsx +0 -198
- package/src/components/number-field.tsx +0 -327
- package/src/components/number-input.tsx +0 -559
- package/src/components/numeric-field.ts +0 -169
- package/src/components/numpad-sheet.tsx +0 -285
- package/src/components/one-time-code-input.tsx +0 -270
- package/src/components/page-contents-labels.ts +0 -9
- package/src/components/page-contents.tsx +0 -282
- package/src/components/page-header-context.ts +0 -8
- package/src/components/page-header.tsx +0 -298
- package/src/components/password-strength-labels.ts +0 -22
- package/src/components/password-strength.tsx +0 -241
- package/src/components/phone-input-labels.ts +0 -10
- package/src/components/phone-input.tsx +0 -282
- package/src/components/picker-sheet.tsx +0 -330
- package/src/components/pie-chart-labels.ts +0 -40
- package/src/components/pie-chart.tsx +0 -480
- package/src/components/popover-labels.ts +0 -14
- package/src/components/popover.tsx +0 -268
- package/src/components/progress-bar-labels.ts +0 -10
- package/src/components/progress-bar.tsx +0 -479
- package/src/components/qr-code.tsx +0 -76
- package/src/components/reauth-dialog-labels.ts +0 -13
- package/src/components/reauth-dialog.tsx +0 -265
- package/src/components/row-actions-labels.ts +0 -12
- package/src/components/row-actions.tsx +0 -795
- package/src/components/scroll-area.tsx +0 -123
- package/src/components/search-field.tsx +0 -192
- package/src/components/select.tsx +0 -294
- package/src/components/separator.tsx +0 -33
- package/src/components/series-chart-axes.ts +0 -342
- package/src/components/series-chart-budget.ts +0 -150
- package/src/components/series-chart-labels.ts +0 -33
- package/src/components/series-chart-thin.ts +0 -180
- package/src/components/series-chart-ticks.ts +0 -194
- package/src/components/series-chart.tsx +0 -1906
- package/src/components/server-wake-labels.ts +0 -11
- package/src/components/server-wake.tsx +0 -129
- package/src/components/settings-fields.tsx +0 -237
- package/src/components/share-card-labels.ts +0 -30
- package/src/components/share-card.tsx +0 -675
- package/src/components/signature-pad-labels.ts +0 -24
- package/src/components/signature-pad.tsx +0 -747
- package/src/components/signed-amount-labels.ts +0 -10
- package/src/components/signed-amount.tsx +0 -336
- package/src/components/skeleton.tsx +0 -80
- package/src/components/slider.tsx +0 -338
- package/src/components/sparkline-labels.ts +0 -14
- package/src/components/sparkline.tsx +0 -322
- package/src/components/spinner.tsx +0 -81
- package/src/components/stat-tile-labels.ts +0 -15
- package/src/components/stat-tile.tsx +0 -754
- package/src/components/status-dot.tsx +0 -170
- package/src/components/swatch-picker-labels.ts +0 -10
- package/src/components/swatch-picker.tsx +0 -283
- package/src/components/swipeable-row.tsx +0 -386
- package/src/components/switch.tsx +0 -273
- package/src/components/table-skeleton.tsx +0 -136
- package/src/components/table.tsx +0 -647
- package/src/components/tabs-labels.ts +0 -13
- package/src/components/tabs.tsx +0 -693
- package/src/components/text-link.tsx +0 -359
- package/src/components/text.tsx +0 -150
- package/src/components/textarea.tsx +0 -330
- package/src/components/tile-radio.tsx +0 -332
- package/src/components/time-input.tsx +0 -121
- package/src/components/toast-labels.ts +0 -12
- package/src/components/toast.tsx +0 -519
- package/src/components/toggle-group.tsx +0 -752
- package/src/components/toggle-legend.tsx +0 -394
- package/src/components/tooltip.tsx +0 -1149
- package/src/components/translation-review-editor.tsx +0 -290
- package/src/components/translation-review-labels.ts +0 -181
- package/src/components/translation-review-parts.tsx +0 -272
- package/src/components/translation-review.tsx +0 -1240
- package/src/components/tree-view.tsx +0 -589
- package/src/components/treemap-labels.ts +0 -47
- package/src/components/treemap-layout.ts +0 -210
- package/src/components/treemap.tsx +0 -1184
- package/src/components/trigger-aria.ts +0 -44
- package/src/components/use-anchor-dir.ts +0 -20
- package/src/components/use-mobile-reveal.ts +0 -62
- package/src/components/use-table-state.ts +0 -753
- package/src/components/user-avatar.tsx +0 -116
- package/src/components/wizard-stepper.tsx +0 -42
- package/src/components/write-lock-labels.ts +0 -10
- package/src/components/write-lock.tsx +0 -253
- package/src/currencies.ts +0 -90
- package/src/data-table.ts +0 -42
- package/src/demo/demo-banner.tsx +0 -153
- package/src/demo/demo-countdown.ts +0 -136
- package/src/demo/demo-ended.tsx +0 -90
- package/src/demo/demo-labels.ts +0 -78
- package/src/demo/demo-session.ts +0 -32
- package/src/demo/demo-start.tsx +0 -156
- package/src/eslint/index.ts +0 -161
- package/src/eslint/role-utilities.generated.ts +0 -146
- package/src/eslint/role-utilities.ts +0 -233
- package/src/feedback/feedback-attachment-download.tsx +0 -77
- package/src/feedback/feedback-attachment-labels.ts +0 -37
- package/src/feedback/feedback-attachment.tsx +0 -1239
- package/src/feedback/feedback-capture.ts +0 -287
- package/src/feedback/feedback-comment-thread.tsx +0 -353
- package/src/feedback/feedback-context-labels.ts +0 -11
- package/src/feedback/feedback-context.tsx +0 -245
- package/src/feedback/feedback-crash.ts +0 -547
- package/src/feedback/feedback-diagnostics.tsx +0 -41
- package/src/feedback/feedback-dialog-labels.ts +0 -29
- package/src/feedback/feedback-dialog.tsx +0 -452
- package/src/feedback/feedback-entry-file.tsx +0 -150
- package/src/feedback/feedback-inbox.tsx +0 -552
- package/src/feedback/feedback-labels.ts +0 -144
- package/src/feedback/feedback-menu-labels.ts +0 -12
- package/src/feedback/feedback-menu.tsx +0 -177
- package/src/feedback/feedback-mutation.ts +0 -20
- package/src/feedback/feedback-page-link.ts +0 -90
- package/src/feedback/feedback-public-labels.ts +0 -81
- package/src/feedback/feedback-public-list.tsx +0 -524
- package/src/feedback/feedback-public-switch.tsx +0 -102
- package/src/feedback/feedback-public-types.ts +0 -101
- package/src/feedback/feedback-record.ts +0 -428
- package/src/feedback/feedback-replies-context.ts +0 -9
- package/src/feedback/feedback-replies.tsx +0 -343
- package/src/feedback/feedback-rework-entry-chip.tsx +0 -18
- package/src/feedback/feedback-row-detail-labels.ts +0 -31
- package/src/feedback/feedback-row-detail.tsx +0 -871
- package/src/feedback/feedback-status-undo.ts +0 -109
- package/src/feedback/feedback-submit-dialog.tsx +0 -131
- package/src/feedback/feedback-submit.tsx +0 -270
- package/src/feedback/feedback-swipe.tsx +0 -192
- package/src/feedback/feedback-table-labels.ts +0 -27
- package/src/feedback/feedback-table.tsx +0 -912
- package/src/feedback/feedback-thread-labels.ts +0 -22
- package/src/feedback/feedback-thread-parts-labels.ts +0 -41
- package/src/feedback/feedback-thread.tsx +0 -905
- package/src/feedback/feedback-vocabulary.ts +0 -263
- package/src/feedback/feedback-vote-button.tsx +0 -124
- package/src/feedback.ts +0 -116
- package/src/hooks/use-anchored-panel.ts +0 -396
- package/src/hooks/use-anchored-rect.ts +0 -77
- package/src/hooks/use-announce.ts +0 -85
- package/src/hooks/use-authed-src.ts +0 -167
- package/src/hooks/use-body-scroll-lock.ts +0 -119
- package/src/hooks/use-breakpoint.ts +0 -133
- package/src/hooks/use-close-transition.ts +0 -107
- package/src/hooks/use-copy-to-clipboard.ts +0 -122
- package/src/hooks/use-debounce.ts +0 -114
- package/src/hooks/use-dismiss.ts +0 -371
- package/src/hooks/use-document-title.ts +0 -33
- package/src/hooks/use-file-drop.ts +0 -121
- package/src/hooks/use-file-picker-labels.ts +0 -28
- package/src/hooks/use-file-picker.tsx +0 -359
- package/src/hooks/use-focus-trap.ts +0 -199
- package/src/hooks/use-hotkey.ts +0 -212
- package/src/hooks/use-large-text.ts +0 -41
- package/src/hooks/use-long-press.ts +0 -140
- package/src/hooks/use-media-query.ts +0 -39
- package/src/hooks/use-mounted.ts +0 -39
- package/src/hooks/use-noindex.ts +0 -37
- package/src/hooks/use-overlay-history.ts +0 -714
- package/src/hooks/use-row-swipe.ts +0 -207
- package/src/hooks/use-search-param-state.ts +0 -434
- package/src/hooks/use-windowed-rows.ts +0 -225
- package/src/i18n/defaults.ts +0 -267
- package/src/i18n/german.ts +0 -2059
- package/src/i18n/kit-labels.tsx +0 -1003
- package/src/i18n/languages.ts +0 -349
- package/src/i18n/locales/de-CH.ts +0 -24
- package/src/i18n/locales/en.ts +0 -267
- package/src/i18n/locales/es.ts +0 -1999
- package/src/i18n/locales/fr.ts +0 -2037
- package/src/i18n/locales/hu.ts +0 -2004
- package/src/i18n/locales/it.ts +0 -2014
- package/src/i18n/locales/zh.ts +0 -1912
- package/src/i18n/plurals.ts +0 -86
- package/src/i18n/review.ts +0 -475
- package/src/i18n/shared-labels.ts +0 -138
- package/src/i18n/swiss.ts +0 -29
- package/src/index.ts +0 -1191
- package/src/landing/access.ts +0 -93
- package/src/landing/landing-actions.tsx +0 -97
- package/src/landing/landing-labels.ts +0 -59
- package/src/landing/landing-sections.tsx +0 -341
- package/src/landing/page-seo.ts +0 -261
- package/src/landing/public-header.tsx +0 -121
- package/src/landing/public-page.tsx +0 -106
- package/src/landing/routing.tsx +0 -225
- package/src/lib/broadcast.ts +0 -52
- package/src/lib/calc.ts +0 -323
- package/src/lib/chip-edge-snap.ts +0 -212
- package/src/lib/clipboard-minus.ts +0 -107
- package/src/lib/clipping.ts +0 -34
- package/src/lib/cn.ts +0 -28
- package/src/lib/column-mapping.ts +0 -234
- package/src/lib/countries.ts +0 -91
- package/src/lib/data-attributes.ts +0 -14
- package/src/lib/date-format.ts +0 -227
- package/src/lib/dates.ts +0 -288
- package/src/lib/day-format.ts +0 -96
- package/src/lib/decimal-marks.ts +0 -108
- package/src/lib/describe-failure.ts +0 -18
- package/src/lib/device-settings.ts +0 -147
- package/src/lib/direction.ts +0 -74
- package/src/lib/document-navigation.ts +0 -17
- package/src/lib/document-title.ts +0 -41
- package/src/lib/download.ts +0 -172
- package/src/lib/float-clearance.ts +0 -70
- package/src/lib/floating-stack.ts +0 -70
- package/src/lib/focus-left.ts +0 -156
- package/src/lib/format.ts +0 -585
- package/src/lib/http-status.ts +0 -38
- package/src/lib/iban.ts +0 -251
- package/src/lib/ime.ts +0 -24
- package/src/lib/intl-cache.ts +0 -27
- package/src/lib/iso-day.ts +0 -13
- package/src/lib/lazy-with-fallback.ts +0 -82
- package/src/lib/logger.ts +0 -69
- package/src/lib/minus.ts +0 -50
- package/src/lib/path-pattern.ts +0 -55
- package/src/lib/person-name.ts +0 -155
- package/src/lib/phone.ts +0 -208
- package/src/lib/plain-text.ts +0 -22
- package/src/lib/presence.ts +0 -18
- package/src/lib/qr-encode.ts +0 -444
- package/src/lib/quiet-focus.ts +0 -32
- package/src/lib/reduced-motion.ts +0 -22
- package/src/lib/refs.ts +0 -22
- package/src/lib/round.ts +0 -43
- package/src/lib/safe-storage.ts +0 -119
- package/src/lib/server-wake.ts +0 -315
- package/src/lib/session-refresh.ts +0 -472
- package/src/lib/share-format.ts +0 -18
- package/src/lib/status-tone.ts +0 -43
- package/src/lib/strip-fade.ts +0 -287
- package/src/lib/table-text.ts +0 -554
- package/src/lib/text-case.ts +0 -19
- package/src/lib/text-match.ts +0 -169
- package/src/lib/thenable.ts +0 -19
- package/src/lib/translation-review.ts +0 -769
- package/src/notifications/device-zone-report.ts +0 -67
- package/src/notifications/feedback-notification-types-labels.ts +0 -33
- package/src/notifications/feedback-notification-types.ts +0 -71
- package/src/notifications/notification-bell.tsx +0 -119
- package/src/notifications/notification-inbox.tsx +0 -309
- package/src/notifications/notification-parts.tsx +0 -81
- package/src/notifications/notification-types-setting.tsx +0 -406
- package/src/notifications/notification-types.ts +0 -89
- package/src/notifications/notifications-labels.ts +0 -287
- package/src/notifications/push-device-setting.tsx +0 -230
- package/src/notifications/push-devices-setting.tsx +0 -374
- package/src/notifications/push-worker.ts +0 -168
- package/src/notifications/quiet-hours-setting.tsx +0 -238
- package/src/notifications/unsubscribe-panel.tsx +0 -200
- package/src/notifications/use-push-device.ts +0 -448
- package/src/offline/local-first.ts +0 -100
- package/src/offline/pwa-update-prompt-labels.ts +0 -9
- package/src/offline/pwa-update-prompt.tsx +0 -78
- package/src/offline/query-persistence.ts +0 -391
- package/src/offline/service-worker-updates.ts +0 -81
- package/src/offline/shared-computer-labels.ts +0 -8
- package/src/offline/shared-computer.tsx +0 -87
- package/src/offline/sign-out-pending-dialog-labels.ts +0 -21
- package/src/offline/sign-out-pending-dialog.tsx +0 -135
- package/src/offline.ts +0 -37
- package/src/push-worker.ts +0 -25
- package/src/rhf/fields.tsx +0 -2187
- package/src/rhf/form-core.tsx +0 -324
- package/src/rhf/form.tsx +0 -12
- package/src/rhf/line-items.tsx +0 -135
- package/src/rhf/use-rhf-wizard-step.ts +0 -104
- package/src/rhf.ts +0 -21
- package/src/search/command-palette-labels.ts +0 -16
- package/src/search/command-palette.tsx +0 -624
- package/src/search/global-search-labels.ts +0 -13
- package/src/search/global-search.tsx +0 -660
- package/src/search/search-index.ts +0 -283
- package/src/search/use-command-key.ts +0 -23
- package/src/search.ts +0 -14
- package/src/settings/device-reset-setting-labels.ts +0 -20
- package/src/settings/device-reset-setting.tsx +0 -116
- package/src/settings/settings-card-classes.ts +0 -11
- package/src/settings/settings-catalogue.ts +0 -150
- package/src/settings/settings-context.ts +0 -33
- package/src/settings/settings-heading.tsx +0 -67
- package/src/settings/settings-labels.ts +0 -87
- package/src/settings/settings-layout.tsx +0 -471
- package/src/settings/settings-section.tsx +0 -108
- package/src/settings/use-account-appearance.ts +0 -148
- package/src/settings/use-account-language.ts +0 -146
- package/src/settings/use-settings-focus.ts +0 -128
- package/src/settings/use-settings-route.ts +0 -258
- package/src/shell/account-menu-language.tsx +0 -130
- package/src/shell/account-menu-text-size.tsx +0 -80
- package/src/shell/admin-menu.tsx +0 -183
- package/src/shell/app-shell-labels.ts +0 -11
- package/src/shell/app-shell.tsx +0 -1560
- package/src/shell/auth-layout.tsx +0 -186
- package/src/shell/company-switcher-labels.ts +0 -13
- package/src/shell/company-switcher.tsx +0 -136
- package/src/shell/dev-menu.tsx +0 -257
- package/src/shell/fill-height.tsx +0 -45
- package/src/shell/language-code.ts +0 -5
- package/src/shell/option-switcher-menu.tsx +0 -84
- package/src/shell/sync-status-indicator.tsx +0 -303
- package/src/shell/top-bar-actions.tsx +0 -87
- package/src/shell/top-bar-brand.tsx +0 -78
- package/src/shell/top-bar-parts-labels.ts +0 -148
- package/src/shell/top-bar.tsx +0 -40
- package/src/shell/topbar-action-menu.tsx +0 -567
- package/src/shell/topbar-controls.tsx +0 -269
- package/src/shell/tour-menu.tsx +0 -187
- package/src/shell.ts +0 -108
- package/src/sync/db.ts +0 -129
- package/src/sync/engine.ts +0 -1011
- package/src/sync/hooks.ts +0 -98
- package/src/sync/testing.ts +0 -73
- package/src/sync/wire.ts +0 -61
- package/src/sync.ts +0 -37
- package/src/table-text.ts +0 -8
- package/src/testing/css-variables.generated.ts +0 -112
- package/src/testing/css-variables.ts +0 -189
- package/src/testing/index.ts +0 -29
- package/src/testing/react.ts +0 -58
- package/src/testing/tour.ts +0 -41
- package/src/testing/viewport.ts +0 -357
- package/src/theme/chart-palette.ts +0 -232
- package/src/theme/color.ts +0 -272
- package/src/theme/contrast-tokens.ts +0 -268
- package/src/theme/contrast.ts +0 -250
- package/src/theme/palette-derive.ts +0 -825
- package/src/theme/palette-presets.ts +0 -544
- package/src/theme/palette-store.ts +0 -108
- package/src/theme/text-size.ts +0 -289
- package/src/theme/theme-store.ts +0 -157
- package/src/tour/tour-catalogue-labels.ts +0 -75
- package/src/tour/tour-catalogue.tsx +0 -335
- package/src/tour/tour-dock.ts +0 -134
- package/src/tour/tour-engine.ts +0 -37
- package/src/tour/tour-gates.ts +0 -218
- package/src/tour/tour-guide-button.tsx +0 -64
- package/src/tour/tour-guide-labels.ts +0 -15
- package/src/tour/tour-info.ts +0 -144
- package/src/tour/tour-labels.ts +0 -23
- package/src/tour/tour-overlay.tsx +0 -1170
- package/src/tour/tour.tsx +0 -750
- package/src/tour/use-tour-progress.ts +0 -671
- package/src/tour/use-tour-url-sync.ts +0 -266
- package/src/tour.ts +0 -21
- package/src/vite-env.d.ts +0 -23
- package/src/wizard/stepper-nav.tsx +0 -360
- package/src/wizard/types.ts +0 -275
- package/src/wizard/use-wizard.ts +0 -560
- package/src/wizard/validation.ts +0 -39
- package/src/wizard/wizard-context.tsx +0 -74
- package/src/wizard/wizard-labels.ts +0 -29
- package/src/wizard/wizard-step.tsx +0 -76
- package/src/wizard/wizard-summary.tsx +0 -84
- package/src/wizard.ts +0 -15
|
@@ -1,1906 +0,0 @@
|
|
|
1
|
-
// The measurement plot: series against a swept numeric abscissa, any number of y axes,
|
|
2
|
-
// dash patterns, vertical spans, and drag-to-zoom. Lifted out of lenkbank, where every
|
|
3
|
-
// chart on every screen is this one arrangement of the kit's shell — so the arrangement
|
|
4
|
-
// lives here once instead of as thirteen hand-assembled copies drifting apart.
|
|
5
|
-
//
|
|
6
|
-
// Built on `ChartContainer` + `ChartTooltipContent`, so it themes with the rest of the
|
|
7
|
-
// chart kit: series default to the `--chart-N` ramp, axis text and grid take the
|
|
8
|
-
// shell's tokens. It stays domain-free — every unit, title and number format is the
|
|
9
|
-
// caller's, and the few words it can say itself are the `seriesChart` label namespace.
|
|
10
|
-
//
|
|
11
|
-
// **Every series may keep its own scale.** Position runs in millimetres and jerk in
|
|
12
|
-
// hundreds of thousands of them per second cubed; on one axis the position line is
|
|
13
|
-
// flat against the bottom. Normalising each series to its peak makes the y axis mean
|
|
14
|
-
// nothing, so a caller declares an axis per incomparable channel instead, and may hide
|
|
15
|
-
// all but the ones worth a column of numbers.
|
|
16
|
-
//
|
|
17
|
-
// Charts are drawn left-to-right in every writing direction — an abscissa is a number
|
|
18
|
-
// line, not text — so `orientation` below is physical, and only the HTML chrome (the
|
|
19
|
-
// reset button) is placed by logical side.
|
|
20
|
-
//
|
|
21
|
-
// **Bars, areas and periods too (0.8.0).** keksdose drew five money charts in raw
|
|
22
|
-
// recharts — net worth, investments, income/expense, grouped payees, stacked categories
|
|
23
|
-
// — each re-deciding the grid, the tooltip, the axis width and the "—" for a gap. They
|
|
24
|
-
// are the same arrangement with a different mark, so a series now says `type: "bar" |
|
|
25
|
-
// "area"` (and `stack`), and the abscissa may be a row of PERIODS (`x.type:
|
|
26
|
-
// "category"`) or real dates (`x.type: "time"`) instead of a number the app had to
|
|
27
|
-
// invent. What each of those does to the zoom is decided in one place,
|
|
28
|
-
// `defaultZoomAxes` in `chart-zoom-core.tsx`.
|
|
29
|
-
//
|
|
30
|
-
// **An axis budget (0.15.1).** Every visible axis reserves its band, and four of them
|
|
31
|
-
// leave a phone nothing to plot. A chart draws at most `maxVisibleAxes`, and — on its
|
|
32
|
-
// own, when it is too narrow for the ones it has — one a side; the rest go hidden,
|
|
33
|
-
// still scaling their lines, and their series say the unit the title no longer does.
|
|
34
|
-
// The rule is `series-chart-budget.ts`.
|
|
35
|
-
//
|
|
36
|
-
// **A row budget (0.34, KS U2).** Opt-in: `maxRows` thins a long table to at most that
|
|
37
|
-
// many rows before recharts sees it, by ENVELOPE — each bucket's lowest and highest row
|
|
38
|
-
// of every drawn series — never by stride, which aliases a fast tone into a slow wave.
|
|
39
|
-
// A zoom thins the window on show, so it draws more detail, not the same rows larger.
|
|
40
|
-
// The rule is `series-chart-thin.ts`.
|
|
41
|
-
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
42
|
-
import type { KeyboardEvent, ReactNode, RefObject } from "react";
|
|
43
|
-
import {
|
|
44
|
-
Area,
|
|
45
|
-
Bar,
|
|
46
|
-
CartesianGrid,
|
|
47
|
-
ComposedChart,
|
|
48
|
-
Label,
|
|
49
|
-
Line,
|
|
50
|
-
ReferenceDot,
|
|
51
|
-
ReferenceLine,
|
|
52
|
-
Rectangle,
|
|
53
|
-
XAxis,
|
|
54
|
-
YAxis,
|
|
55
|
-
usePlotArea,
|
|
56
|
-
useXAxisScale,
|
|
57
|
-
type BarShapeProps,
|
|
58
|
-
} from "recharts";
|
|
59
|
-
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "./chart";
|
|
60
|
-
import { useFigureDescription } from "./chart-figure";
|
|
61
|
-
import { rovingTarget } from "../lib/direction";
|
|
62
|
-
import {
|
|
63
|
-
DEFAULT_Y_AXIS,
|
|
64
|
-
axisExtent,
|
|
65
|
-
withChartZoom,
|
|
66
|
-
type ZoomAxesSetting,
|
|
67
|
-
type ZoomBinding,
|
|
68
|
-
type ZoomFitSource,
|
|
69
|
-
} from "./chart-zoom-core";
|
|
70
|
-
import { STEP_DASH, strokeDash, type LegendEntry } from "./toggle-legend";
|
|
71
|
-
import { DEFAULT_SERIES_CHART_LABELS, type SeriesChartLabels } from "./series-chart-labels";
|
|
72
|
-
import {
|
|
73
|
-
categoryTicks,
|
|
74
|
-
integerTicks,
|
|
75
|
-
niceTicks,
|
|
76
|
-
tickTarget,
|
|
77
|
-
timeTicksWithUnit,
|
|
78
|
-
type TimeTickUnit,
|
|
79
|
-
} from "./series-chart-ticks";
|
|
80
|
-
// The tick module stays internal; the one type of it a public prop names is re-exported.
|
|
81
|
-
export type { TimeTickUnit } from "./series-chart-ticks";
|
|
82
|
-
import { autoAxisBudget, axisUnit, budgetedAxes, type SeriesChartAxisBudget } from "./series-chart-budget";
|
|
83
|
-
import { thinnedRows } from "./series-chart-thin";
|
|
84
|
-
// The rule stays internal, like the ticks; the one type a public prop names is re-exported.
|
|
85
|
-
export type { SeriesChartAxisBudget } from "./series-chart-budget";
|
|
86
|
-
import {
|
|
87
|
-
AXIS_TITLE_OFFSET,
|
|
88
|
-
MIN_TICK_GAP,
|
|
89
|
-
TIME_TICK_FORMAT,
|
|
90
|
-
anchoredBand,
|
|
91
|
-
axisBandWidth,
|
|
92
|
-
extend,
|
|
93
|
-
finite,
|
|
94
|
-
padBand,
|
|
95
|
-
resolveTicks,
|
|
96
|
-
soleSeriesColor,
|
|
97
|
-
tiltedTickBand,
|
|
98
|
-
xModel,
|
|
99
|
-
type XModel,
|
|
100
|
-
} from "./series-chart-axes";
|
|
101
|
-
// The pure axis and series helpers live in series-chart-axes.ts (MOD-9); their public
|
|
102
|
-
// names are still this module's, so `/chart` and the barrel export them as before.
|
|
103
|
-
export {
|
|
104
|
-
AXIS_TICK_WIDTH,
|
|
105
|
-
AXIS_TITLE_STRIP,
|
|
106
|
-
anchoredBand,
|
|
107
|
-
axisBandWidth,
|
|
108
|
-
mergeSeries,
|
|
109
|
-
oneAxis,
|
|
110
|
-
padBand,
|
|
111
|
-
paddedDomain,
|
|
112
|
-
seriesKey,
|
|
113
|
-
soleSeriesColor,
|
|
114
|
-
visibleSeries,
|
|
115
|
-
} from "./series-chart-axes";
|
|
116
|
-
export type { SeriesSource } from "./series-chart-axes";
|
|
117
|
-
import { paletteFor } from "../theme/chart-palette";
|
|
118
|
-
import {
|
|
119
|
-
useKitChartTooltipPlacement,
|
|
120
|
-
useKitLabels,
|
|
121
|
-
useKitLocale,
|
|
122
|
-
type ChartTooltipPlacement,
|
|
123
|
-
type LabelOverride,
|
|
124
|
-
} from "../i18n/kit-labels";
|
|
125
|
-
import { useBreakpoint } from "../hooks/use-breakpoint";
|
|
126
|
-
import { useTextSize } from "../theme/text-size";
|
|
127
|
-
import { chartHeightProps, type ChartHeight } from "./chart-height";
|
|
128
|
-
import { useChartEdge, useEdgesInForce } from "./chart-edge";
|
|
129
|
-
import { cn } from "../lib/cn";
|
|
130
|
-
import { formatWithMinus } from "../lib/minus";
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* One line, area or bar run of a {@link SeriesChart}.
|
|
134
|
-
*
|
|
135
|
-
* `TRow` is the chart's row type (0.53, keksdose after 0.52), and only `dot` reads it: its
|
|
136
|
-
* `point.row` is that type. Without a type argument a series is what it was, and a chart
|
|
137
|
-
* of typed rows still takes it — see {@link SeriesChartProps}.
|
|
138
|
-
*/
|
|
139
|
-
export interface SeriesChartSeries<TRow extends object = object> {
|
|
140
|
-
/** The row key this line reads — and the `--color-<key>` it is painted with, so it
|
|
141
|
-
* must be a CSS identifier. Build keys out of data with {@link seriesKey}. */
|
|
142
|
-
key: string;
|
|
143
|
-
label: ReactNode;
|
|
144
|
-
/** Any CSS colour the chart shell accepts (hex, rgb/hsl, `var(--token)`). Default:
|
|
145
|
-
* the kit's categorical ramp by position, `paletteFor(index)`. */
|
|
146
|
-
color?: string;
|
|
147
|
-
/** Marks the PAIRED line of a pair — the return stroke against the out-stroke, the
|
|
148
|
-
* reference against the measurement. Shorthand for `dash: 1`. */
|
|
149
|
-
dashed?: boolean;
|
|
150
|
-
/** Which of {@link STROKE_PATTERNS} this line takes, for charts where the stroke says
|
|
151
|
-
* WHICH QUANTITY and the colour says WHICH MEASUREMENT.
|
|
152
|
-
*
|
|
153
|
-
* Or an SVG `stroke-dasharray` string of the caller's own, for a pattern the five do
|
|
154
|
-
* not have: keksdose's `"4 3"`, a tighter dash than the ladder's `"5 4"` that its
|
|
155
|
-
* hand-drawn recharts lines used before the kit. The legend
|
|
156
|
-
* entry ({@link seriesLegendEntries}) carries the same string, so it draws the same
|
|
157
|
-
* pattern. */
|
|
158
|
-
dash?: number | string;
|
|
159
|
-
/** `stepAfter`, for a whole-number channel that jumps rather than travels — a
|
|
160
|
-
* straight line between index 0 and index 1 draws an index of 0.5, which does not
|
|
161
|
-
* exist. Drawn in the {@link STEP_DASH} pattern, whatever `dash` says. */
|
|
162
|
-
step?: boolean;
|
|
163
|
-
/** Which of `axes` this line is measured on. Default: `"y"`, the single one. */
|
|
164
|
-
axis?: string;
|
|
165
|
-
/**
|
|
166
|
-
* The mark. `"line"` (the default) is what every chart before 0.8.0 drew. `"bar"` and
|
|
167
|
-
* `"area"` are read as a LENGTH from zero, so the axis they stand on always includes
|
|
168
|
-
* zero (see `SeriesChartAxis.includeZero`) and the zoom treats them differently (see
|
|
169
|
-
* `defaultZoomAxes`). Bars without a `stack` stand side by side in each slot — the
|
|
170
|
-
* grouped bars of keksdose's payee report.
|
|
171
|
-
*/
|
|
172
|
-
type?: SeriesChartType;
|
|
173
|
-
/**
|
|
174
|
-
* Bars or areas with the same `stack` are drawn on top of each other and the axis is
|
|
175
|
-
* fitted to their SUM (positive and negative layers apart, like recharts'
|
|
176
|
-
* `stackOffset="sign"`). keksdose's spending-by-category area. Ignored on a line:
|
|
177
|
-
* recharts cannot stack one.
|
|
178
|
-
*/
|
|
179
|
-
stack?: string;
|
|
180
|
-
/**
|
|
181
|
-
* Marks on the line's (or area's) points. `true` rings every sample — the price
|
|
182
|
-
* history, where a shop has a value only on the days somebody shopped there and the
|
|
183
|
-
* dots are the only thing saying which points were MEASURED. A function decides per
|
|
184
|
-
* point: `true` for the default dot, `false`/`null` for none, or any SVG node drawn
|
|
185
|
-
* as-is at `point.cx`/`point.cy` — a buy/sell marker on keksdose's paper price.
|
|
186
|
-
* Never called for a point with no value. Bars have no points, and ignore it.
|
|
187
|
-
* `point.row` is the caller's own row, typed as the chart's rows are (0.53).
|
|
188
|
-
*/
|
|
189
|
-
dot?: boolean | ((point: SeriesChartPoint<TRow>) => ReactNode);
|
|
190
|
-
/** Line (or area outline) weight in px. Default 2, or 1.5 for a `step`. keksdose
|
|
191
|
-
* draws the subject of a chart at 2.5 and the reference it is read against at 1.5. */
|
|
192
|
-
strokeWidth?: number;
|
|
193
|
-
/** `"linear"` for a line that must not look smoothed — keksdose's cash-buffer
|
|
194
|
-
* PROJECTION, a straight extrapolation that a monotone curve would dress up as data.
|
|
195
|
-
* Default `"monotone"`; `step` wins over both. */
|
|
196
|
-
curve?: "monotone" | "linear";
|
|
197
|
-
/** An area's or bar's fill opacity. Default: 1 for a bar, 0.55 for a stacked area
|
|
198
|
-
* (the layers must stay tellable apart where they meet) and 0.2 for a single one. */
|
|
199
|
-
fillOpacity?: number;
|
|
200
|
-
/**
|
|
201
|
-
* The dot that follows the pointer along a line or an area. `false` takes it off a
|
|
202
|
-
* series that is not a measurement — keksdose's cash-buffer PROJECTION, where a hover
|
|
203
|
-
* ring on the extrapolated line reads as a sampled value (`cash-buffer-chart.tsx`).
|
|
204
|
-
* `{ r }` sets its radius. Default: recharts' dot. Bars have none, and ignore it.
|
|
205
|
-
*/
|
|
206
|
-
activeDot?: boolean | { r?: number };
|
|
207
|
-
/**
|
|
208
|
-
* The shortest a bar of this series is drawn, in px — recharts' `minPointSize`. A
|
|
209
|
-
* zero or a value too small to see keeps a visible stub, so an empty slot still reads
|
|
210
|
-
* as a slot with a value rather than a gap: keksdose's weekday pattern, where a
|
|
211
|
-
* Sunday with no spending drew a 2% stub by hand. Only the DRAWING changes: the axis
|
|
212
|
-
* is fitted to the values, and the tooltip, the keyboard stops and every accessible
|
|
213
|
-
* name still say 0. A hole (no value in the row) stays a hole. Overrides the chart's
|
|
214
|
-
* {@link SeriesChartProps.minBarLength}; `0` turns it off for this series. Meant for
|
|
215
|
-
* unstacked bars — in a `stack` the stub is drawn over the layer above it. Lines and
|
|
216
|
-
* areas ignore it.
|
|
217
|
-
*/
|
|
218
|
-
minBarLength?: number;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/** What a series draws. See {@link SeriesChartSeries.type}. */
|
|
222
|
-
export type SeriesChartType = "line" | "bar" | "area";
|
|
223
|
-
|
|
224
|
-
/** One point of a series, as a `dot` function is handed it. `TRow` is the chart's row
|
|
225
|
-
* type (0.53); without one, `row` is a {@link SeriesChartRow}, as before. */
|
|
226
|
-
export interface SeriesChartPoint<TRow extends object = object> {
|
|
227
|
-
/** The series' key. */
|
|
228
|
-
key: string;
|
|
229
|
-
/** The row's position in `rows`. */
|
|
230
|
-
index: number;
|
|
231
|
-
/** The caller's own row, with everything the chart did not plot still in it: the very
|
|
232
|
-
* object in `rows`, typed as `rows` is. */
|
|
233
|
-
row: SeriesChartRowOf<TRow>;
|
|
234
|
-
/** The abscissa in the caller's terms: the number, the category, or (time) a Date. */
|
|
235
|
-
x: SeriesChartXValue;
|
|
236
|
-
value: number;
|
|
237
|
-
/** Where the point is drawn, in the chart's pixels. */
|
|
238
|
-
cx: number;
|
|
239
|
-
cy: number;
|
|
240
|
-
/** The series' paint, `var(--color-<key>)`. */
|
|
241
|
-
color: string;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/** A row of a series chart: one abscissa value and the series' values at it. Anything
|
|
245
|
-
* else in it (a raw ISO period for a drilldown) rides along untouched and is handed
|
|
246
|
-
* back in {@link SeriesChartPoint.row} and {@link SeriesChartHit.row} — typed as the
|
|
247
|
-
* caller's rows are since 0.53, and as this where their type names no keys. */
|
|
248
|
-
export type SeriesChartRow = Readonly<Record<string, unknown>>;
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* The row a hit or a point hands back, for a chart whose rows are `TRow[]` (0.53, keksdose
|
|
252
|
-
* after 0.52): `TRow` itself, so a drilldown reads `hit.row.rawPeriod` as the string it
|
|
253
|
-
* is. A {@link SeriesChartRow} where `TRow` names no keys — `object`, the default, which
|
|
254
|
-
* keeps `SeriesChartHit` and `SeriesChartPoint` without a type argument what they were, and
|
|
255
|
-
* the `object[]` rows an app passes today; `{}`; and `any` or `never` (`rows={[]}`), which
|
|
256
|
-
* are both assignable to `null` while no object type is.
|
|
257
|
-
*
|
|
258
|
-
* Both tests take `TRow` in the CHECKED position, never in the `extends` one, so TypeScript
|
|
259
|
-
* measures every type below as covariant in it (`SeriesChartSeries`, through `dot`'s
|
|
260
|
-
* parameter, contravariant) and relates two of them by their type arguments alone: a
|
|
261
|
-
* `SeriesChartHit<Month>` is a `SeriesChartHit`, and a handler or a series typed without an
|
|
262
|
-
* argument fits a chart of `Month` rows, though an interface has no index signature and is
|
|
263
|
-
* not, field by field, a `SeriesChartRow`. Written `object extends TRow ?`, the type is
|
|
264
|
-
* invariant and both of those stop type-checking.
|
|
265
|
-
*/
|
|
266
|
-
type SeriesChartRowOf<TRow> = [TRow] extends [null]
|
|
267
|
-
? SeriesChartRow
|
|
268
|
-
: [keyof TRow] extends [never]
|
|
269
|
-
? SeriesChartRow
|
|
270
|
-
: TRow;
|
|
271
|
-
|
|
272
|
-
/** An abscissa value: a number (`x.type: "number"`), a category (a string, a number or
|
|
273
|
-
* a Date standing for a period), or a time (a Date, epoch ms or an ISO string). */
|
|
274
|
-
export type SeriesChartXValue = number | string | Date;
|
|
275
|
-
|
|
276
|
-
/** Ticks a caller decides — a list, or a function of the domain on show, so a zoom
|
|
277
|
-
* window gets ticks from the same rule instead of none. */
|
|
278
|
-
export type SeriesChartTickValues<T> = readonly T[] | ((domain: [number, number]) => readonly T[] | undefined);
|
|
279
|
-
|
|
280
|
-
interface SeriesChartAxisShape {
|
|
281
|
-
id: string;
|
|
282
|
-
/**
|
|
283
|
-
* Which side of the plot the ticks stand on. Left unless said otherwise — and said
|
|
284
|
-
* otherwise for the right-hand chart of a FACING pair (see `facingAxes`), whose
|
|
285
|
-
* scales go on the outside so neither column of numbers stands between two pictures
|
|
286
|
-
* being compared.
|
|
287
|
-
*/
|
|
288
|
-
orientation?: "left" | "right";
|
|
289
|
-
/** Tints the ticks — and the title too, when exactly one series is measured on this
|
|
290
|
-
* axis (see {@link soleSeriesColor}). */
|
|
291
|
-
color?: string;
|
|
292
|
-
/** What the TICKS need, in px. The title's strip is added on top. Default 48. */
|
|
293
|
-
width?: number;
|
|
294
|
-
/**
|
|
295
|
-
* The unit, bare — `"mm/s"`. The title says it while the axis is drawn; when it is not
|
|
296
|
-
* (`hide`, or over the chart's axis budget — see {@link SeriesChartProps.maxVisibleAxes})
|
|
297
|
-
* the series on it say it instead, as "Velocity (mm/s)": in the tooltip of a chart
|
|
298
|
-
* whose budget hid the axis, and in the legend {@link seriesLegendEntries} builds when
|
|
299
|
-
* handed the axes. Default: the parenthesised tail of `title` ("Load (N)" → "N").
|
|
300
|
-
* `""` for a quantity with no unit whose title merely ends in brackets.
|
|
301
|
-
*/
|
|
302
|
-
unit?: string;
|
|
303
|
-
/**
|
|
304
|
-
* Pin the scale instead of fitting it to this chart's data. For a ROW of charts
|
|
305
|
-
* read against each other: auto-fitted, a 200 N loop and a 2000 N one draw the
|
|
306
|
-
* identical picture, and the comparison the layout promises is the one it fails.
|
|
307
|
-
*/
|
|
308
|
-
domain?: [number, number];
|
|
309
|
-
/** A tick, formatted — as a BARE number. The unit is said once, in the title; the
|
|
310
|
-
* tooltip gets it from `valueFormat`. Default: `Intl.NumberFormat` in the kit's
|
|
311
|
-
* locale, up to two fraction digits. */
|
|
312
|
-
format?: (value: number) => string;
|
|
313
|
-
/**
|
|
314
|
-
* The tick values, instead of the round ones the chart picks. For a grid the DATA
|
|
315
|
-
* dictates — keksdose's price axes tick on whole cents (`pricePaddedDomain`), where a
|
|
316
|
-
* 1/2/5 ladder would print €1.25 under a formatter that can only say €1.3. Values
|
|
317
|
-
* outside the domain on show are dropped; a function is asked again for every zoom
|
|
318
|
-
* window, so the cent grid can refine with it.
|
|
319
|
-
*/
|
|
320
|
-
tickValues?: SeriesChartTickValues<number>;
|
|
321
|
-
/**
|
|
322
|
-
* Keep zero inside the fitted band. On by default for an axis carrying a bar or an
|
|
323
|
-
* area — their length IS the value, and a truncated baseline draws 40 as three times
|
|
324
|
-
* 20 — and off for lines, whose shape is the point (a stock price anchored at zero is
|
|
325
|
-
* a hairline). A pinned `domain` is left alone either way.
|
|
326
|
-
*/
|
|
327
|
-
includeZero?: boolean;
|
|
328
|
-
/**
|
|
329
|
-
* Tick only on whole numbers — the y counterpart of `SeriesChartX.integerTicks`, and
|
|
330
|
-
* what keksdose's user-count axis (`metrics-panel.tsx`, `wholeTicks`) and its runway
|
|
331
|
-
* in days (`cash-buffer-chart.tsx`, `wholeDayTicks`) each wrote by hand: a band of
|
|
332
|
-
* [0, 3.1] users is ticked 0 1 2 3, not 0 0.5 1 … 3, and a short runway is not ticked
|
|
333
|
-
* 0 / 0.5 / 1 under a rounding formatter that prints "1" twice. A (zoom) window that
|
|
334
|
-
* holds no whole number falls back to the ordinary ticks rather than to none.
|
|
335
|
-
*
|
|
336
|
-
* AUTOMATIC by default — on when every value this axis carries is a whole number
|
|
337
|
-
* (counts), because that is where a half tick is a value no sample can have, and it
|
|
338
|
-
* changes nothing on a span wider than about eight, which already ticks on whole
|
|
339
|
-
* steps. `true` forces it over fractional data (days of runway computed as 43.7);
|
|
340
|
-
* `false` keeps fractional ticks for a continuous quantity that merely happens to be
|
|
341
|
-
* whole in this sample. `tickValues` wins over either.
|
|
342
|
-
*/
|
|
343
|
-
integerTicks?: boolean;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* A y axis — and a VISIBLE one says what it measures.
|
|
348
|
-
*
|
|
349
|
-
* A union rather than an optional field, so the rule is the type's: a column of numbers
|
|
350
|
-
* whose quantity and unit are not written down is a column somebody reads as whatever
|
|
351
|
-
* they expected. `title: ""` is the explicit opt-out (the right-hand chart of a facing
|
|
352
|
-
* pair, whose neighbour already said it). A HIDDEN axis scales its lines and draws
|
|
353
|
-
* nothing, so there is nowhere for a title to go.
|
|
354
|
-
*/
|
|
355
|
-
export type SeriesChartAxis = SeriesChartAxisShape & ({ title: string; hide?: false } | { title?: string; hide: true });
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* What a tick or the tooltip heading of the abscissa is handed besides its position —
|
|
359
|
-
* the value in the caller's own terms, which on a category or time axis is not the
|
|
360
|
-
* number the plot runs on.
|
|
361
|
-
*/
|
|
362
|
-
export interface SeriesChartXTick {
|
|
363
|
-
/** The number itself, the row's category, or (time) a Date. */
|
|
364
|
-
value: SeriesChartXValue;
|
|
365
|
-
/** The slot, on a category axis: the row's index in `rows`. */
|
|
366
|
-
index?: number;
|
|
367
|
-
/** On a time axis: what one step of the ticks on show is, so a label can say as much
|
|
368
|
-
* as it means — a month start as "Mar 26", a midnight as "14 Mar". */
|
|
369
|
-
unit?: TimeTickUnit;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
export interface SeriesChartX {
|
|
373
|
-
/**
|
|
374
|
-
* What the abscissa is.
|
|
375
|
-
*
|
|
376
|
-
* - `"number"` (the default) — a number line, and all a chart before 0.8.0 could draw.
|
|
377
|
-
* - `"category"` — PERIODS or names, one evenly spaced slot per row, in row order:
|
|
378
|
-
* keksdose's months, quarters and budget categories, which it used to hand recharts
|
|
379
|
-
* preformatted. The values stay the caller's own — `"2026-05"`, a Date for the
|
|
380
|
-
* month, a category name — and need not be sortable, unique or numeric. The plot
|
|
381
|
-
* runs on the slot INDEX, which is what lets it zoom: a drag across the third to the
|
|
382
|
-
* ninth month shows those months, a tick on each whole slot and the bars clipped at
|
|
383
|
-
* the edge. What else zooms depends on the MARKS, not the axis — see `zoomAxes`.
|
|
384
|
-
* - `"time"` — real TIME: a Date, epoch ms or an ISO string per row, placed by when
|
|
385
|
-
* it happened. keksdose's price history and cash buffer, where a slot per row would
|
|
386
|
-
* draw two receipts a day apart and two five months apart the same width. Ticks fall
|
|
387
|
-
* on calendar boundaries (midnights, Mondays, month and quarter starts, new years)
|
|
388
|
-
* in local time; a date-only ISO string is LOCAL midnight, not the UTC one
|
|
389
|
-
* `new Date("2026-05-01")` gives, which lands on the previous day west of Greenwich.
|
|
390
|
-
* Zooms like a number line.
|
|
391
|
-
*/
|
|
392
|
-
type?: "number" | "category" | "time";
|
|
393
|
-
/** Row key of the abscissa. Default `"x"`, which is what {@link mergeSeries} writes. */
|
|
394
|
-
key?: string;
|
|
395
|
-
/** What the abscissa is, with its unit. Drawn under the axis. */
|
|
396
|
-
title?: string;
|
|
397
|
-
/**
|
|
398
|
-
* A tick, formatted — bare, like the y axes'.
|
|
399
|
-
*
|
|
400
|
-
* `value` is the POSITION on the number line the plot runs on — the number itself,
|
|
401
|
-
* epoch ms, or the slot index — so the one-argument formatters every chart before
|
|
402
|
-
* 0.8.0 passes keep their meaning, and a time axis' `(ms) => …` is the tickFormatter
|
|
403
|
-
* keksdose already has. The caller's own value (the category, the Date) is `tick.value`.
|
|
404
|
-
* Default: the kit's number format; a category as is (a number formatted, a Date as a
|
|
405
|
-
* medium date); a time as much of the date as the tick step means.
|
|
406
|
-
*/
|
|
407
|
-
format?: (value: number, tick: SeriesChartXTick) => string;
|
|
408
|
-
/**
|
|
409
|
-
* Whether this chart prints the abscissa's ticks. On by default; off for every chart
|
|
410
|
-
* of a stack sharing one x window but the bottom one, which prints them for all. It
|
|
411
|
-
* costs no alignment: the x mapping is decided by the margins and the y bands.
|
|
412
|
-
*/
|
|
413
|
-
ticks?: boolean;
|
|
414
|
-
/** The tooltip's heading. Default: `format` — or, on a time axis, a medium date (with
|
|
415
|
-
* the time for hourly data), since a tick's "Mar 26" is not which day it was. */
|
|
416
|
-
label?: (value: number, tick: SeriesChartXTick) => ReactNode;
|
|
417
|
-
/** The ticks instead of the automatic ones, in the caller's terms: numbers, the
|
|
418
|
-
* categories to label, or instants. See `SeriesChartAxis.tickValues`. */
|
|
419
|
-
tickValues?: SeriesChartTickValues<SeriesChartXValue>;
|
|
420
|
-
/**
|
|
421
|
-
* Tilt the tick labels by this many degrees — negative rises to the right. For long
|
|
422
|
-
* category names that do not fit side by side: keksdose's budget performance draws its
|
|
423
|
-
* categories at −45° (`budget-performance-tab.tsx`). The label is anchored by its END
|
|
424
|
-
* for a negative angle and its START for a positive one, so it hangs off the tick
|
|
425
|
-
* instead of being centred across it; the anchor is physical, like the plot (see
|
|
426
|
-
* `ChartContainer`), so it is the same in RTL. The band under the axis grows to the
|
|
427
|
-
* rotated height of the longest label on show, estimated from its length (at most
|
|
428
|
-
* 120 px × the text size's scale, past which a label is clipped). Default 0.
|
|
429
|
-
*/
|
|
430
|
-
tickAngle?: number;
|
|
431
|
-
/**
|
|
432
|
-
* On a `"number"` axis, tick only on whole numbers: a step of 1 at the least, so a
|
|
433
|
-
* five-point index series reads 0 1 2 3 4 rather than 0 0.5 1 … 4 — ticks at
|
|
434
|
-
* positions no row can have (keksdose's short step series). A zoom window that holds
|
|
435
|
-
* no whole number falls back to the ordinary ticks rather than to none.
|
|
436
|
-
*
|
|
437
|
-
* AUTOMATIC by default — on when every row's x is a whole number — because that is
|
|
438
|
-
* exactly the case the half ticks are wrong in, and it changes nothing elsewhere: a
|
|
439
|
-
* span wider than about eight already ticks on whole steps. `false` for a continuous
|
|
440
|
-
* quantity that merely happens to be sampled on whole numbers (1 Hz steps) and whose
|
|
441
|
-
* zoom should still be ruled in fractions; `true` to force it over rows that are not.
|
|
442
|
-
* Ignored on category (already one tick per slot) and time axes.
|
|
443
|
-
*/
|
|
444
|
-
integerTicks?: boolean;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/** Where the tooltip goes — see {@link SeriesChartTooltip.placement}. */
|
|
448
|
-
export type SeriesChartTooltipPlacement = ChartTooltipPlacement;
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* The placement a chart actually uses: its own, else the provider's, else `"cursor"`;
|
|
452
|
-
* `"auto"` is `"above"` on a phone (`phone`: below `sm`) and `"cursor"` from `sm` up.
|
|
453
|
-
*/
|
|
454
|
-
export function resolveTooltipPlacement(
|
|
455
|
-
own: SeriesChartTooltipPlacement | undefined,
|
|
456
|
-
fromProvider: SeriesChartTooltipPlacement | undefined,
|
|
457
|
-
phone: boolean,
|
|
458
|
-
): "cursor" | "above" | "below" {
|
|
459
|
-
const wanted = own ?? fromProvider ?? "cursor";
|
|
460
|
-
return wanted === "auto" ? (phone ? "above" : "cursor") : wanted;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/** Room for the tooltip beyond the chart — see {@link SeriesChartProps.tooltip}. */
|
|
464
|
-
export interface SeriesChartTooltip {
|
|
465
|
-
/**
|
|
466
|
-
* Where the values under the pointer are shown (keksdose #359: on a phone the box
|
|
467
|
-
* sat under the finger, on the very data it was reporting).
|
|
468
|
-
* - `"cursor"` (the default): the floating box that follows the pointer.
|
|
469
|
-
* - `"above"` / `"below"`: a READOUT row — the same heading and values, flat — in
|
|
470
|
-
* room reserved over or under the plot from the first render, so nothing jumps on
|
|
471
|
-
* the first tap. It follows hover, a tap and the keyboard's stops; the cursor line
|
|
472
|
-
* and the active dot stay on the plot, and no box floats. Idle, it lists the series
|
|
473
|
-
* with "—" under the x axis' title. The row is taken out of the chart's `height`
|
|
474
|
-
* (the plot gets shorter, the page around it does not move).
|
|
475
|
-
* - `"auto"`: `"above"` below Tailwind's `sm` (640 px), `"cursor"` from there up.
|
|
476
|
-
*
|
|
477
|
-
* Default: the provider's `chartTooltipPlacement`, else `"cursor"`.
|
|
478
|
-
*
|
|
479
|
-
* The row is deliberately NOT an `aria-live` region: scrubbing a line announces a
|
|
480
|
-
* value per pixel of travel. A keyboard reader already hears each stop's name
|
|
481
|
-
* ("period — series: value") from the stop itself, and the row stays in the
|
|
482
|
-
* document for a screen reader to read on its way past.
|
|
483
|
-
*/
|
|
484
|
-
placement?: SeriesChartTooltipPlacement;
|
|
485
|
-
/** Let the tooltip run past the chart's own box on that axis instead of recharts
|
|
486
|
-
* clamping it inside. Default: `{ x: true }` when `boundary` is set, else neither. */
|
|
487
|
-
allowEscapeViewBox?: { x?: boolean; y?: boolean };
|
|
488
|
-
/**
|
|
489
|
-
* The element that actually CLIPS the chart — usually a horizontal-scroll wrapper
|
|
490
|
-
* around a chart wider than the card. The tooltip then flips to the left of the cursor
|
|
491
|
-
* when it would spill past that element's visible right edge (see
|
|
492
|
-
* `ChartTooltipContent`'s `boundaryRef`), rather than against the wide chart's far edge
|
|
493
|
-
* the reader has not scrolled to. keksdose's budget performance, which keeps a scroll
|
|
494
|
-
* wrapper and a per-category `minWidth` (`budget-performance-tab.tsx`).
|
|
495
|
-
*/
|
|
496
|
-
boundary?: RefObject<HTMLElement | null>;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* A vertical segment in data coordinates — two y at one x, which a row-per-abscissa
|
|
501
|
-
* chart structurally cannot draw. For CLOSING a shape the series already drew: the
|
|
502
|
-
* turnarounds of a hysteresis loop, where the abscissa stands still while the value
|
|
503
|
-
* falls from one branch to the other.
|
|
504
|
-
*/
|
|
505
|
-
export interface SeriesChartSpan {
|
|
506
|
-
/** Distinct within the chart. */
|
|
507
|
-
key: string;
|
|
508
|
-
/** Which y axis `from`/`to` are measured on. Default `"y"`. */
|
|
509
|
-
axis?: string;
|
|
510
|
-
x: number;
|
|
511
|
-
from: number;
|
|
512
|
-
to: number;
|
|
513
|
-
/** Default: `var(--text-muted)`. */
|
|
514
|
-
color?: string;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
/** The colours a reference or a marker can take by name — the kit's semantic tokens,
|
|
518
|
-
* so a threshold reads the same on every chart and flips with the theme. */
|
|
519
|
-
export type SeriesChartTone =
|
|
520
|
-
"muted" | "brand" | "income" | "expense" | "net" | "success" | "warning" | "danger" | "info";
|
|
521
|
-
|
|
522
|
-
const TONE_COLOR: Record<SeriesChartTone, string> = {
|
|
523
|
-
muted: "var(--text-muted)",
|
|
524
|
-
brand: "var(--brand)",
|
|
525
|
-
income: "var(--money-income)",
|
|
526
|
-
expense: "var(--money-expense)",
|
|
527
|
-
net: "var(--money-net)",
|
|
528
|
-
success: "var(--success)",
|
|
529
|
-
warning: "var(--warning)",
|
|
530
|
-
danger: "var(--danger)",
|
|
531
|
-
info: "var(--info)",
|
|
532
|
-
};
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* A line across the whole plot at one value: a threshold, a target, an event.
|
|
536
|
-
*
|
|
537
|
-
* keksdose's cash buffer draws "one month of runway" across at y = 30 and the projected
|
|
538
|
-
* depletion date down at its x. Unlike a {@link SeriesChartSpan}, which closes a shape
|
|
539
|
-
* in data coordinates, a reference spans the plot, whatever the zoom.
|
|
540
|
-
*
|
|
541
|
-
* A reference is part of the FITTED band: one outside the data widens the axis to show
|
|
542
|
-
* it, because a threshold the reader cannot see is not a threshold. A pinned domain or a
|
|
543
|
-
* zoom window does not widen — there it is discarded when outside, like a span.
|
|
544
|
-
*/
|
|
545
|
-
export interface SeriesChartReference {
|
|
546
|
-
/** Distinct within the chart. Default: its position in the list. */
|
|
547
|
-
key?: string;
|
|
548
|
-
/** `"x"` for a vertical line at an abscissa, otherwise the id of the y axis the value
|
|
549
|
-
* is measured on. Default `"y"`, the single one — so no y axis may be called `"x"`. */
|
|
550
|
-
axis?: string;
|
|
551
|
-
/** An abscissa in the x axis' own terms (a category, a Date) for `axis: "x"`, a
|
|
552
|
-
* number on that axis otherwise. A category the rows do not have draws nothing. */
|
|
553
|
-
value: SeriesChartXValue;
|
|
554
|
-
/** Written along the line, inside the plot at its top-left. SVG text: a string. */
|
|
555
|
-
label?: string;
|
|
556
|
-
/** Default `"muted"`. `color` wins over it. */
|
|
557
|
-
tone?: SeriesChartTone;
|
|
558
|
-
color?: string;
|
|
559
|
-
/** Which of `STROKE_PATTERNS`. Default 1, dashed: a reference is not data, and a
|
|
560
|
-
* solid line reads as a series nobody put in the legend. */
|
|
561
|
-
dash?: number;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* A single labelled point — today's figure on keksdose's cash buffer, the month the
|
|
566
|
-
* projection runs dry. For a mark on EVERY sample, or on the samples that meet a test,
|
|
567
|
-
* use the series' `dot` instead; a marker is for a point that is a fact of its own.
|
|
568
|
-
* Fitted like a reference: it widens the band it would otherwise fall outside of.
|
|
569
|
-
*/
|
|
570
|
-
export interface SeriesChartMarker {
|
|
571
|
-
/** Distinct within the chart. Default: its position in the list. */
|
|
572
|
-
key?: string;
|
|
573
|
-
/** In the x axis' own terms, like a reference's `value`. */
|
|
574
|
-
x: SeriesChartXValue;
|
|
575
|
-
y: number;
|
|
576
|
-
/** The y axis `y` is measured on. Default `"y"`. */
|
|
577
|
-
axis?: string;
|
|
578
|
-
/** Written above the point. */
|
|
579
|
-
label?: string;
|
|
580
|
-
/** Default `"brand"`. `color` wins over it. */
|
|
581
|
-
tone?: SeriesChartTone;
|
|
582
|
-
color?: string;
|
|
583
|
-
/** Radius in px. Default 4.5. */
|
|
584
|
-
r?: number;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/** What a click on the plot picked. `TRow` is the chart's row type (0.53); without one,
|
|
588
|
-
* `row` is a {@link SeriesChartRow}, as before. */
|
|
589
|
-
export interface SeriesChartHit<TRow extends object = object> {
|
|
590
|
-
/** The row's position in `rows`. */
|
|
591
|
-
index: number;
|
|
592
|
-
/** The caller's own row — with its `rawPeriod`, id or whatever the drilldown needs: the
|
|
593
|
-
* very object in `rows`, typed as `rows` is, so it is read without a cast. */
|
|
594
|
-
row: SeriesChartRowOf<TRow>;
|
|
595
|
-
x: SeriesChartXValue;
|
|
596
|
-
/** The series, when the click landed ON a bar. A click anywhere else picks the slot
|
|
597
|
-
* (the period), not a series. */
|
|
598
|
-
key?: string;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* The props of {@link SeriesChart} and {@link StaticSeriesChart}, for rows of type `TRow`.
|
|
603
|
-
*
|
|
604
|
-
* `TRow` is inferred from `rows` (0.53, keksdose after 0.52), and what the chart hands back
|
|
605
|
-
* — `hit.row` in `onPointClick`, `point.row` in a series' `dot` — is that type, so a
|
|
606
|
-
* drilldown reads its own fields without narrowing an `unknown`. Without a type argument,
|
|
607
|
-
* `SeriesChartProps` is what it was: any object is a row, and a row comes back as a
|
|
608
|
-
* {@link SeriesChartRow}. So is `ComponentProps<typeof SeriesChart>`, which reads the
|
|
609
|
-
* constraint, `object`. A series, a handler or a `dot` typed without an argument fits a
|
|
610
|
-
* chart of typed rows too.
|
|
611
|
-
*/
|
|
612
|
-
export interface SeriesChartProps<TRow extends object = object> {
|
|
613
|
-
/**
|
|
614
|
-
* One row per abscissa value. A missing key is a hole (see `connectNulls`).
|
|
615
|
-
*
|
|
616
|
-
* Any object (0.52, refactor audit 2026-10-30, API-2): an `interface` has no index
|
|
617
|
-
* signature, so a typed sweep did not fit `SeriesChartRow` and Kurvenschmiede cast its
|
|
618
|
-
* Ackermann rows `as unknown as Record<string, number>[]`. The chart reads the keys
|
|
619
|
-
* `series` and `x` name, and hands the row back typed as these are (0.53).
|
|
620
|
-
*/
|
|
621
|
-
rows: readonly TRow[];
|
|
622
|
-
series: readonly SeriesChartSeries<TRow>[];
|
|
623
|
-
/** Default: one untitled axis, `"y"`. */
|
|
624
|
-
axes?: readonly SeriesChartAxis[];
|
|
625
|
-
x?: SeriesChartX;
|
|
626
|
-
/** A value in the tooltip, where a number stands on its own and needs its unit.
|
|
627
|
-
* Default: `Intl.NumberFormat` in the kit's locale. */
|
|
628
|
-
valueFormat?: (value: number) => string;
|
|
629
|
-
/**
|
|
630
|
-
* The chart's height: a CSS length, a Tailwind height class, or px. Default `h-72`
|
|
631
|
-
* (18rem). The empty state takes it too, so a chart losing its last line does not
|
|
632
|
-
* relayout the page under it.
|
|
633
|
-
*
|
|
634
|
-
* - **A CSS length** (0.32) — `"20rem"`, `"min(20rem, 60dvh)"` — set inline. The form
|
|
635
|
-
* for a height that should grow with the text size and still stop at the screen
|
|
636
|
-
* (docs/text-size-harmonization.md §10.10): `min(30rem, 60dvh)` is 480 px at Normal
|
|
637
|
-
* on a desktop and never more than 60 % of a phone at Extra large, where a scaled
|
|
638
|
-
* 480 px would be 720.
|
|
639
|
-
* - **A Tailwind class** — `"h-72"`, `"h-64 md:h-80"` — as before.
|
|
640
|
-
* - **A number** is px, set inline, and does NOT follow the text size: kept for a
|
|
641
|
-
* height the caller holds as a number (keksdose's report charts take
|
|
642
|
-
* `height = 260` as a prop). Prefer `"16.25rem"`, or a `min()` with a viewport cap.
|
|
643
|
-
*/
|
|
644
|
-
height?: ChartHeight;
|
|
645
|
-
/** Bridge holes left by sources sampled on different grids. See {@link mergeSeries}. */
|
|
646
|
-
connectNulls?: boolean;
|
|
647
|
-
/** Shown, centred at the chart's height, instead of an empty chart. Default: the
|
|
648
|
-
* `seriesChart.empty` label. `null` shows nothing. */
|
|
649
|
-
empty?: ReactNode;
|
|
650
|
-
/**
|
|
651
|
-
* Milliseconds for a line to draw itself in. Off by default: a chart beside a live
|
|
652
|
-
* editor re-renders on every keystroke, and an animation restarted mid-flight reads
|
|
653
|
-
* as the curve twitching. Turn it on where series come and go by choice.
|
|
654
|
-
*/
|
|
655
|
-
animationMs?: number;
|
|
656
|
-
spans?: readonly SeriesChartSpan[];
|
|
657
|
-
/** Lines across the plot at one value. */
|
|
658
|
-
references?: readonly SeriesChartReference[];
|
|
659
|
-
/** Single labelled points. */
|
|
660
|
-
markers?: readonly SeriesChartMarker[];
|
|
661
|
-
/**
|
|
662
|
-
* Which axes a drag may zoom: `"both"`, `"x"`, `"y"` or `"none"`. Default: read off
|
|
663
|
-
* the marks — see `defaultZoomAxes` (lines both, areas x, bars none). An axis carrying
|
|
664
|
-
* bars or areas never takes a DRAGGED y window: it refits to the x window, from zero.
|
|
665
|
-
* Ignored by `StaticSeriesChart`, which does not zoom.
|
|
666
|
-
*/
|
|
667
|
-
zoomAxes?: ZoomAxesSetting;
|
|
668
|
-
/**
|
|
669
|
-
* A click on the plot: the slot under the pointer, and the series when it landed on a
|
|
670
|
-
* bar. keksdose's drilldowns — a payee's month, a budget line, a spending category.
|
|
671
|
-
* A drag that zoomed is not a click.
|
|
672
|
-
*
|
|
673
|
-
* The keyboard's stops are there either way (0.52, DSP-5): one per bar, or per slot of
|
|
674
|
-
* a chart without bars, named "period — series: value", behind ONE tab stop. With this
|
|
675
|
-
* they are buttons that Enter and Space activate; without, images to read.
|
|
676
|
-
*/
|
|
677
|
-
onPointClick?: (hit: SeriesChartHit<TRow>) => void;
|
|
678
|
-
/** Where the tooltip may go: for a chart inside a scroll wrapper. See
|
|
679
|
-
* {@link SeriesChartTooltip}. */
|
|
680
|
-
tooltip?: SeriesChartTooltip;
|
|
681
|
-
/**
|
|
682
|
-
* The most y axes the chart DRAWS: a total, or `{ left, right }` per side. Axes over it
|
|
683
|
-
* are drawn as `hide: true` ones are — they still scale their lines and the zoom still
|
|
684
|
-
* refits them, but they draw no ticks or title and reserve no width — in declaration
|
|
685
|
-
* order, so the first axis of each side is the last to go (`series-chart-budget.ts`).
|
|
686
|
-
* The series on a hidden axis say its unit instead (see {@link SeriesChartAxis.unit}).
|
|
687
|
-
* Default: no cap — only the automatic one of `axisBudget`.
|
|
688
|
-
*/
|
|
689
|
-
maxVisibleAxes?: SeriesChartAxisBudget;
|
|
690
|
-
/**
|
|
691
|
-
* `"auto"` (the default): a chart so narrow that its axes' bands would leave the plot
|
|
692
|
-
* under 160 px (`MIN_PLOT_WIDTH`, × the text size's scale) draws ONE axis a side —
|
|
693
|
-
* lenkbank's four-axis curve plot on a phone, whose plot was 10 px wide. And a chart
|
|
694
|
-
* with an axis on EACH side that one a side still leaves too narrow (0.32: at 150 % a
|
|
695
|
-
* 390 px phone's plot kept about 80 px between its two bands) drops the right-hand,
|
|
696
|
-
* secondary axis too. Measured on the chart's own box (`ResizeObserver`), and applied
|
|
697
|
-
* on top of `maxVisibleAxes`. Either way the series on an axis it hid say the axis'
|
|
698
|
-
* unit in the tooltip and the readout ("Rack load (N)"), and in a legend built by
|
|
699
|
-
* {@link seriesLegendEntries} with `onAxisBudget`'s ids.
|
|
700
|
-
*
|
|
701
|
-
* On by default because it cannot touch a layout that works: it needs a plot that
|
|
702
|
-
* would otherwise be under 160 px — a four-axis chart below about 440 px at Normal, a
|
|
703
|
-
* two-left-axis one below about 300, a one-a-side one below about 290 — and the
|
|
704
|
-
* left-hand axis always stays. A chart with one axis (each chart of a facing pair,
|
|
705
|
-
* every single-axis chart) is never budgeted, at any width. `"off"` keeps every
|
|
706
|
-
* declared axis whatever the width: for a stack of multi-axis charts that must keep
|
|
707
|
-
* identical bands, or a caller budgeting itself. Without layout (jsdom, SSR) nothing is
|
|
708
|
-
* measured and nothing is hidden.
|
|
709
|
-
*/
|
|
710
|
-
axisBudget?: "auto" | "off";
|
|
711
|
-
/**
|
|
712
|
-
* The ids of the axes the budget hid (not those declared `hide`), every time that set
|
|
713
|
-
* changes — for a legend that says their units: pass it to {@link seriesLegendEntries}
|
|
714
|
-
* as `budgeted`. Called after the render that hid them; empty once the chart is wide
|
|
715
|
-
* again.
|
|
716
|
-
*/
|
|
717
|
-
onAxisBudget?: (hidden: readonly string[]) => void;
|
|
718
|
-
/** Supplied by `withChartZoom` and by nothing else. */
|
|
719
|
-
zoom?: ZoomBinding;
|
|
720
|
-
/** Per-chart strings over `<UiKitProvider labels={{ seriesChart }}>`. */
|
|
721
|
-
labels?: LabelOverride<SeriesChartLabels>;
|
|
722
|
-
/** BCP 47 tag for the default number formats. Default: the provider's. */
|
|
723
|
-
locale?: string;
|
|
724
|
-
/**
|
|
725
|
-
* The chart's name. The chart is a `role="figure"` (0.52, refactor audit 2026-10-30,
|
|
726
|
-
* DSP-5), and a figure is found and told apart by its name — "Net worth", "Load over
|
|
727
|
-
* travel". Its values are read stop by stop (see {@link SeriesChartProps.onPointClick}).
|
|
728
|
-
*/
|
|
729
|
-
"aria-label"?: string;
|
|
730
|
-
/**
|
|
731
|
-
* What the picture SHOWS, in a sentence — "Spending rose 12 % in May, led by rent." —
|
|
732
|
-
* the figure's accessible description: a line, an area and a ruler are nothing a screen
|
|
733
|
-
* reader can say. Followed, on a zoomable chart, by the drag gesture (`zoomHint`). Not
|
|
734
|
-
* drawn; a caption the eye should read too belongs in the page.
|
|
735
|
-
*/
|
|
736
|
-
description?: string;
|
|
737
|
-
/** Onto the chart's root (`ChartContainer`) — e.g. an app's own grid ink. */
|
|
738
|
-
className?: string;
|
|
739
|
-
/** The shortest bar drawn, in px, for every bar series that does not set its own
|
|
740
|
-
* {@link SeriesChartSeries.minBarLength}. Drawing only: domain, tooltip and names
|
|
741
|
-
* keep the real value. Default: none — a zero draws nothing. */
|
|
742
|
-
minBarLength?: number;
|
|
743
|
-
/**
|
|
744
|
-
* The most rows the chart hands recharts (0.34, KS U2). A longer table is THINNED, by
|
|
745
|
-
* envelope: cut into buckets, and from each the row where each drawn series is lowest
|
|
746
|
-
* and the row where it is highest, plus each series' first and last sample — so every
|
|
747
|
-
* line still reaches every peak and dip the table has, and a tone faster than the
|
|
748
|
-
* buckets draws as the band it fills, never as the slow wave a stride would alias it
|
|
749
|
-
* into. Nothing is averaged or invented; every point drawn is one of `rows`. There is
|
|
750
|
-
* no stride option, on purpose.
|
|
751
|
-
*
|
|
752
|
-
* Opt-in. Default: none — every row is drawn, as before. Kurvenschmiede draws 2000 for
|
|
753
|
-
* a 200-second profile at 1 kHz; a few thousand is about what a plot's pixels can show.
|
|
754
|
-
*
|
|
755
|
-
* - **Zoom** thins the window on show (with one row past each edge), so zooming in
|
|
756
|
-
* draws more of the samples there — all of them, once the window holds fewer than
|
|
757
|
-
* `maxRows` — rather than the same rows larger. That needs an abscissa that never
|
|
758
|
-
* decreases; where it doubles back (a loop against position) the whole table is
|
|
759
|
-
* thinned once, and the abscissa is enveloped too, so the path's turning points stay.
|
|
760
|
-
* - **Fitting** is not thinned: the axes, the zoom's refit and the automatic whole
|
|
761
|
-
* ticks read every row, so a pinned or fitted band is the same either way.
|
|
762
|
-
* - **Indices** stay the caller's: a `dot` function's `point.index` and a click's
|
|
763
|
-
* `hit.index` are positions in `rows`, not in the rows drawn.
|
|
764
|
-
* - **A category axis** (`x.type: "category"`) is never thinned: a slot is a period, and
|
|
765
|
-
* a period left out is a gap. Meant for lines and areas; stacked layers are each
|
|
766
|
-
* enveloped on their own.
|
|
767
|
-
*
|
|
768
|
-
* The budget is a cap for any `maxRows` of at least 2 + 4 × the drawn series (the
|
|
769
|
-
* fewest rows an envelope can be drawn with); a smaller one is raised to that.
|
|
770
|
-
*/
|
|
771
|
-
maxRows?: number;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
/** A series' name with its unit after it: "Velocity (mm/s)" — unless the name already
|
|
775
|
-
* ends with it. lenkbank's motion series carry "(mm/s)" in their label for the desktop
|
|
776
|
-
* tooltip, where every axis is drawn; the budget then read "… (mm/s) (mm/s)" (0.15.1).
|
|
777
|
-
* A label that says its unit keeps saying it once, whichever of the two an app chose. */
|
|
778
|
-
function withUnit(label: ReactNode, unit: string | undefined): ReactNode {
|
|
779
|
-
if (!unit) return label;
|
|
780
|
-
if (typeof label === "string" || typeof label === "number") {
|
|
781
|
-
const text = String(label);
|
|
782
|
-
return text.trimEnd().endsWith(`(${unit})`) ? label : `${text} (${unit})`;
|
|
783
|
-
}
|
|
784
|
-
return (
|
|
785
|
-
<>
|
|
786
|
-
{label} ({unit})
|
|
787
|
-
</>
|
|
788
|
-
);
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
/** Where a legend learns which axes are not drawn — see {@link seriesLegendEntries}. */
|
|
792
|
-
export interface SeriesLegendAxes {
|
|
793
|
-
/** The chart's axes. A series on one that is `hide`, or `budgeted`, says its unit. */
|
|
794
|
-
axes?: readonly SeriesChartAxis[];
|
|
795
|
-
/** What the chart's `onAxisBudget` last said. */
|
|
796
|
-
budgeted?: readonly string[];
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* The `ToggleLegend` entries for a chart's FULL series list — colours resolved the way
|
|
801
|
-
* the chart resolves them, and a stroke mark for a line drawn in a pattern (dashed,
|
|
802
|
-
* step) so the key promises the stroke the plot draws. A bar or an area is a swatch.
|
|
803
|
-
* Pair with {@link visibleSeries} for the chart itself.
|
|
804
|
-
*
|
|
805
|
-
* Handed the chart's `axes` (and the `budgeted` ids its `onAxisBudget` reports), a
|
|
806
|
-
* series whose axis is not drawn says the unit that axis would have: "Velocity (mm/s)"
|
|
807
|
-
* — see {@link SeriesChartAxis.unit}. Without them, the labels are as given.
|
|
808
|
-
*/
|
|
809
|
-
export function seriesLegendEntries<TRow extends object>(
|
|
810
|
-
// Generic only so a typed list fits (0.53): `SeriesChartSeries<Month>` is not a
|
|
811
|
-
// `SeriesChartSeries`, whose `dot` would be handed rows that are not `Month`s.
|
|
812
|
-
series: readonly SeriesChartSeries<TRow>[],
|
|
813
|
-
{ axes, budgeted }: SeriesLegendAxes = {},
|
|
814
|
-
): LegendEntry[] {
|
|
815
|
-
const undrawn = new Map<string, string | undefined>();
|
|
816
|
-
for (const axis of axes ?? []) {
|
|
817
|
-
if (axis.hide || budgeted?.includes(axis.id)) undrawn.set(axis.id, axisUnit(axis));
|
|
818
|
-
}
|
|
819
|
-
return series.map((entry, index) => {
|
|
820
|
-
// A custom dash array goes to the legend as it is, so the swatch draws what the plot does.
|
|
821
|
-
const own = entry.dash ?? (entry.dashed ? 1 : 0);
|
|
822
|
-
const dash = entry.step ? STEP_DASH : own;
|
|
823
|
-
const line = (entry.type ?? "line") === "line";
|
|
824
|
-
return {
|
|
825
|
-
key: entry.key,
|
|
826
|
-
label: withUnit(entry.label, undrawn.get(entry.axis ?? DEFAULT_Y_AXIS)),
|
|
827
|
-
color: entry.color ?? paletteFor(index),
|
|
828
|
-
...(line && dash !== 0 ? { marker: "stroke" as const, dash } : {}),
|
|
829
|
-
};
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
/** The number format every default falls back to. */
|
|
834
|
-
function useDefaultFormat(localeProp: string | undefined): (value: number) => string {
|
|
835
|
-
const locale = useKitLocale(localeProp);
|
|
836
|
-
return useMemo(() => {
|
|
837
|
-
const format = new Intl.NumberFormat(locale, { maximumFractionDigits: 2 });
|
|
838
|
-
// U+2212 on a negative tick and in the tooltip (0.49, KIT-1).
|
|
839
|
-
return (value: number) => formatWithMinus(format, value);
|
|
840
|
-
}, [locale]);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
/** The Y-axis list a chart draws when the caller gave none. */
|
|
844
|
-
const ONE_UNTITLED_AXIS: SeriesChartAxis[] = [{ id: DEFAULT_Y_AXIS, title: "" }];
|
|
845
|
-
|
|
846
|
-
/** The two numbers every mark type needs to agree on for the chart to read as one. */
|
|
847
|
-
const LINE_WIDTH = 2;
|
|
848
|
-
const STEP_WIDTH = 1.5;
|
|
849
|
-
|
|
850
|
-
/** Bars round their FREE end only, and a stacked bar has none but the top layer's —
|
|
851
|
-
* which recharts cannot tell apart per cell, so stacks stay square. */
|
|
852
|
-
const BAR_RADIUS: [number, number, number, number] = [3, 3, 0, 0];
|
|
853
|
-
|
|
854
|
-
/**
|
|
855
|
-
* One keyboard stop: a bar, or (a chart with no bars) a whole slot. `from`/`to` bound its
|
|
856
|
-
* slot on the plotted number line — half way to each neighbour, or to the edge of the
|
|
857
|
-
* window on show.
|
|
858
|
-
*/
|
|
859
|
-
interface PointStop {
|
|
860
|
-
index: number;
|
|
861
|
-
/** The bar's series; absent for a slot. */
|
|
862
|
-
key?: string;
|
|
863
|
-
from: number;
|
|
864
|
-
to: number;
|
|
865
|
-
/** The accessible name: where it is and what it says. Asked only of a stop that is
|
|
866
|
-
* drawn — see {@link ALL_STOPS_UP_TO}. */
|
|
867
|
-
name: () => string;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
/**
|
|
871
|
-
* Up to this many stops, every one is drawn; past it, only the roving one, its two
|
|
872
|
-
* neighbours and the two ends (0.52, DSP-5) — every stop is still reached, by the arrows,
|
|
873
|
-
* Home and End. Since every chart has stops, a measurement chart has one per row:
|
|
874
|
-
* Kurvenschmiede draws 2000-row profiles (`maxRows`), and 2000 named `<rect>`s, each
|
|
875
|
-
* named through `Intl` on every render, are a DOM and an accessibility tree nobody walks
|
|
876
|
-
* one by one. A year of months, or of weeks, stays whole for browse mode.
|
|
877
|
-
*/
|
|
878
|
-
const ALL_STOPS_UP_TO = 100;
|
|
879
|
-
|
|
880
|
-
/**
|
|
881
|
-
* The shape of a series whose bar has keyboard focus: recharts' own rectangle, with an
|
|
882
|
-
* outline on the one bar at `index` — drawn at the bar's exact geometry, which an
|
|
883
|
-
* overlay could only guess at. Not `activeBar`: that follows the tooltip's active index,
|
|
884
|
-
* which recharts stops taking from `defaultIndex` once a pointer has hovered the chart.
|
|
885
|
-
*/
|
|
886
|
-
function focusedBarShape(index: number) {
|
|
887
|
-
return function FocusedBar(props: BarShapeProps) {
|
|
888
|
-
const focused = props.originalDataIndex === index;
|
|
889
|
-
return <Rectangle {...props} {...(focused ? { stroke: "var(--text-primary)", strokeWidth: 2 } : {})} />;
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
/** A marker label's size in px at Normal — the one place both the text and its width
|
|
894
|
-
* estimate read it from. × the text size's scale where it is drawn (§10.10). */
|
|
895
|
-
const MARKER_LABEL_SIZE = 11;
|
|
896
|
-
|
|
897
|
-
/** A reference line's label, in px at Normal, × the scale likewise. */
|
|
898
|
-
const REFERENCE_LABEL_SIZE = 10;
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* A marker's label, centred over its point but clamped inside the plot. recharts'
|
|
902
|
-
* `position: "top"` centres on the point no matter where it is, so a marker near the
|
|
903
|
-
* plot's end (the last sample, a projection's end point) had half its label cut off by
|
|
904
|
-
* the card — "over the c" on a phone. The width is measured once drawn; the first
|
|
905
|
-
* frame (and a DOM without layout) uses a 0.6em-per-character estimate, which errs wide.
|
|
906
|
-
*/
|
|
907
|
-
function MarkerLabel({ viewBox, value }: { viewBox?: { x?: number; y?: number; width?: number }; value?: ReactNode }) {
|
|
908
|
-
const plot = usePlotArea();
|
|
909
|
-
const ref = useRef<SVGTextElement>(null);
|
|
910
|
-
const [measured, setMeasured] = useState<number>();
|
|
911
|
-
const fontSize = MARKER_LABEL_SIZE * useTextSize().scale;
|
|
912
|
-
const text = value == null ? "" : String(value);
|
|
913
|
-
useLayoutEffect(() => {
|
|
914
|
-
const el = ref.current;
|
|
915
|
-
if (!el || typeof el.getComputedTextLength !== "function") return;
|
|
916
|
-
const w = el.getComputedTextLength();
|
|
917
|
-
if (w > 0 && w !== measured) setMeasured(w);
|
|
918
|
-
}, [text, measured, fontSize]);
|
|
919
|
-
if (!viewBox || viewBox.x == null || viewBox.y == null || text === "") return null;
|
|
920
|
-
const cx = viewBox.x + (viewBox.width ?? 0) / 2;
|
|
921
|
-
const half = (measured ?? text.length * fontSize * 0.6) / 2;
|
|
922
|
-
// The start clamp applied last: a label wider than the plot keeps its start on screen.
|
|
923
|
-
const x = plot ? Math.max(plot.x + half, Math.min(cx, plot.x + plot.width - half)) : cx;
|
|
924
|
-
return (
|
|
925
|
-
<text
|
|
926
|
-
ref={ref}
|
|
927
|
-
x={x}
|
|
928
|
-
y={viewBox.y - 5}
|
|
929
|
-
textAnchor="middle"
|
|
930
|
-
fontSize={fontSize}
|
|
931
|
-
fontWeight={600}
|
|
932
|
-
fill="var(--text-primary)"
|
|
933
|
-
className="recharts-label"
|
|
934
|
-
>
|
|
935
|
-
{text}
|
|
936
|
-
</text>
|
|
937
|
-
);
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
/**
|
|
941
|
-
* The keyboard's way onto a chart: one focusable `<rect>` per bar, or per slot when there
|
|
942
|
-
* are no bars, laid over the plot INSIDE the recharts chart, where the x scale answers.
|
|
943
|
-
*
|
|
944
|
-
* keksdose drew its weekday pattern as seven real `<button>`s (spending-tab.tsx) because
|
|
945
|
-
* a recharts bar is reachable by nothing but the pointer. This is that, for every chart:
|
|
946
|
-
*
|
|
947
|
-
* - ONE tab stop (roving `tabIndex`): Tab moves past the chart, not through 30 bars.
|
|
948
|
-
* - ←/→ step through the stops in order, ↑/↓ between the bars of one slot, Home/End.
|
|
949
|
-
* - Each is named "period — series: value".
|
|
950
|
-
* - With `onPointClick` (`onPick`) each is a `role="button"`, and ↵ and Space report the
|
|
951
|
-
* stop as a click would — with the series for a bar. Without (0.52, refactor audit
|
|
952
|
-
* 2026-10-30, DSP-5) each is a `role="img"` to read, as PieChart's slices are: before,
|
|
953
|
-
* such a chart was recharts' unnamed `role="application"` stop, whose arrows moved a
|
|
954
|
-
* tooltip nothing announced.
|
|
955
|
-
*
|
|
956
|
-
* The stops take NO pointer events, so the drag-to-zoom layer, the tooltip and the
|
|
957
|
-
* pointer's own clicks underneath behave exactly as they did. Focus is shown by the
|
|
958
|
-
* slot tinted and, for a bar, its own outline (`focusedBarShape`) — and by the tooltip,
|
|
959
|
-
* which recharts' own pointer is stood on the stop for (`pointAt`).
|
|
960
|
-
*/
|
|
961
|
-
function PointKeys({
|
|
962
|
-
stops,
|
|
963
|
-
current,
|
|
964
|
-
label,
|
|
965
|
-
onFocusStop,
|
|
966
|
-
onBlurStops,
|
|
967
|
-
onPick,
|
|
968
|
-
}: {
|
|
969
|
-
stops: readonly PointStop[];
|
|
970
|
-
current: number;
|
|
971
|
-
label: string;
|
|
972
|
-
onFocusStop: (at: number) => void;
|
|
973
|
-
onBlurStops: () => void;
|
|
974
|
-
onPick?: (stop: PointStop) => void;
|
|
975
|
-
}) {
|
|
976
|
-
const plot = usePlotArea();
|
|
977
|
-
const scale = useXAxisScale();
|
|
978
|
-
const refs = useRef<(SVGRectElement | null)[]>([]);
|
|
979
|
-
if (!plot || !scale || plot.width <= 0 || plot.height <= 0) return null;
|
|
980
|
-
|
|
981
|
-
const onKeyDown = (at: number) => (event: KeyboardEvent<SVGRectElement>) => {
|
|
982
|
-
const stop = stops[at];
|
|
983
|
-
// ↑/↓ stay in the slot: the next or previous bar of the same period. The stops are
|
|
984
|
-
// in slot order, so a slot's bars are neighbours. ←/→, Home and End as Treemap's tiles
|
|
985
|
-
// take them (0.52 code review, deep, charts, finding 14): → is the next stop in any
|
|
986
|
-
// page, since the plot runs left to right in an RTL one too (see `ChartContainer`).
|
|
987
|
-
const inSlot = (step: 1 | -1) => (stops[at + step]?.index === stop.index ? at + step : at);
|
|
988
|
-
const target =
|
|
989
|
-
event.key === "ArrowDown"
|
|
990
|
-
? inSlot(1)
|
|
991
|
-
: event.key === "ArrowUp"
|
|
992
|
-
? inSlot(-1)
|
|
993
|
-
: rovingTarget(event.key, "ltr", at, stops.length, false);
|
|
994
|
-
if (target !== undefined) {
|
|
995
|
-
event.preventDefault();
|
|
996
|
-
refs.current[target]?.focus();
|
|
997
|
-
} else if (onPick && (event.key === "Enter" || event.key === " ")) {
|
|
998
|
-
event.preventDefault();
|
|
999
|
-
onPick(stop);
|
|
1000
|
-
}
|
|
1001
|
-
};
|
|
1002
|
-
|
|
1003
|
-
const left = plot.x;
|
|
1004
|
-
const right = plot.x + plot.width;
|
|
1005
|
-
const middle = plot.y + plot.height / 2;
|
|
1006
|
-
// Every target an arrow, Home or End can name from the roving stop — see ALL_STOPS_UP_TO.
|
|
1007
|
-
const drawn =
|
|
1008
|
-
stops.length <= ALL_STOPS_UP_TO ? undefined : new Set([0, current - 1, current, current + 1, stops.length - 1]);
|
|
1009
|
-
return (
|
|
1010
|
-
<g role="group" aria-label={label}>
|
|
1011
|
-
{stops.map((stop, at) => {
|
|
1012
|
-
if (drawn && !drawn.has(at)) return null;
|
|
1013
|
-
// An edge with no neighbour runs to the plot's edge.
|
|
1014
|
-
const a = finite(scale(stop.from)) ?? left;
|
|
1015
|
-
const b = finite(scale(stop.to)) ?? right;
|
|
1016
|
-
const x0 = Math.max(left, Math.min(a, b));
|
|
1017
|
-
const x1 = Math.min(right, Math.max(a, b));
|
|
1018
|
-
return (
|
|
1019
|
-
<rect
|
|
1020
|
-
key={`${stop.index}:${stop.key ?? ""}`}
|
|
1021
|
-
ref={(node) => {
|
|
1022
|
-
refs.current[at] = node;
|
|
1023
|
-
}}
|
|
1024
|
-
role={onPick ? "button" : "img"}
|
|
1025
|
-
tabIndex={at === current ? 0 : -1}
|
|
1026
|
-
aria-label={stop.name()}
|
|
1027
|
-
data-point-key={stop.key}
|
|
1028
|
-
x={x0}
|
|
1029
|
-
y={plot.y}
|
|
1030
|
-
width={Math.max(0, x1 - x0)}
|
|
1031
|
-
height={plot.height}
|
|
1032
|
-
fill="transparent"
|
|
1033
|
-
// Focus only: the pointer's drag, hover and click belong to what is below.
|
|
1034
|
-
pointerEvents="none"
|
|
1035
|
-
strokeWidth={2}
|
|
1036
|
-
className={cn(
|
|
1037
|
-
"outline-none focus-visible:fill-[var(--brand)]/10",
|
|
1038
|
-
// A bar outlines ITSELF (see `FOCUSED_BAR`); a slot has nothing else to.
|
|
1039
|
-
stop.key === undefined && "focus-visible:stroke-[var(--brand)]",
|
|
1040
|
-
)}
|
|
1041
|
-
onFocus={(event) => {
|
|
1042
|
-
onFocusStop(at);
|
|
1043
|
-
pointAt(event.currentTarget, (x0 + x1) / 2, middle);
|
|
1044
|
-
}}
|
|
1045
|
-
onBlur={(event) => {
|
|
1046
|
-
onBlurStops();
|
|
1047
|
-
// On to another stop: that one stands the pointer on itself. (`refs` holds a
|
|
1048
|
-
// null for every stop not drawn, so a blur to nowhere is no stop.)
|
|
1049
|
-
const next = event.relatedTarget as SVGRectElement | null;
|
|
1050
|
-
if (!next || !refs.current.includes(next)) {
|
|
1051
|
-
pointAt(event.currentTarget, left - 1, middle);
|
|
1052
|
-
}
|
|
1053
|
-
}}
|
|
1054
|
-
onKeyDown={onKeyDown(at)}
|
|
1055
|
-
/>
|
|
1056
|
-
);
|
|
1057
|
-
})}
|
|
1058
|
-
</g>
|
|
1059
|
-
);
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
/**
|
|
1063
|
-
* Stands recharts' pointer at (`x`, `y`) in the chart's own px, as a mouse moved there
|
|
1064
|
-
* would — what the keyboard's stops show their tooltip by (0.52 code review, deep, charts,
|
|
1065
|
-
* finding 4). Their `defaultIndex` alone moved it only until a pointer had hovered the
|
|
1066
|
-
* chart: recharts reads it no more once a hover has an index, and a mouse that has left
|
|
1067
|
-
* keeps its index. After one hover the arrows moved the tint, and the tooltip, the one
|
|
1068
|
-
* place the value is drawn, stayed where the mouse had left it. recharts' own keyboard
|
|
1069
|
-
* layer, which these stops replaced (DSP-5), drove the tooltip through its own state.
|
|
1070
|
-
*
|
|
1071
|
-
* A point off the plot (`x` left of it) takes the pointer off the chart: recharts hides
|
|
1072
|
-
* its tooltip there, through the same frame-throttled path a pending move takes, so a
|
|
1073
|
-
* blur right after a focus is never overtaken by it. recharts reads the pointer against
|
|
1074
|
-
* its wrapper's box, scaled as the box is drawn (`getRelativeCoordinate`); the point is
|
|
1075
|
-
* put back into that box.
|
|
1076
|
-
*/
|
|
1077
|
-
function pointAt(within: Element, x: number, y: number) {
|
|
1078
|
-
const wrapper = within.closest<HTMLElement>(".recharts-wrapper");
|
|
1079
|
-
if (!wrapper) return;
|
|
1080
|
-
const box = wrapper.getBoundingClientRect();
|
|
1081
|
-
const scaleX = wrapper.offsetWidth > 0 ? box.width / wrapper.offsetWidth : 1;
|
|
1082
|
-
const scaleY = wrapper.offsetHeight > 0 ? box.height / wrapper.offsetHeight : 1;
|
|
1083
|
-
wrapper.dispatchEvent(
|
|
1084
|
-
new MouseEvent("mousemove", { bubbles: true, clientX: box.left + x * scaleX, clientY: box.top + y * scaleY }),
|
|
1085
|
-
);
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
interface PlotProps extends Omit<SeriesChartProps, "rows" | "x"> {
|
|
1089
|
-
/** The rows AS PLOTTED — what the zoom fits on. The caller's are `model.source`. */
|
|
1090
|
-
rows: readonly SeriesChartRow[];
|
|
1091
|
-
/** What the zoom fits on: the plotted key. */
|
|
1092
|
-
x: { key: string };
|
|
1093
|
-
model: XModel;
|
|
1094
|
-
xAxis: SeriesChartX;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
/** The chart proper, over an abscissa already reduced to numbers (see {@link XModel}). */
|
|
1098
|
-
function SeriesPlot({
|
|
1099
|
-
model,
|
|
1100
|
-
xAxis,
|
|
1101
|
-
series,
|
|
1102
|
-
axes = ONE_UNTITLED_AXIS,
|
|
1103
|
-
valueFormat,
|
|
1104
|
-
height = "h-72",
|
|
1105
|
-
connectNulls,
|
|
1106
|
-
empty,
|
|
1107
|
-
animationMs = 0,
|
|
1108
|
-
spans,
|
|
1109
|
-
references,
|
|
1110
|
-
markers,
|
|
1111
|
-
onPointClick,
|
|
1112
|
-
tooltip,
|
|
1113
|
-
zoom,
|
|
1114
|
-
labels: labelsProp,
|
|
1115
|
-
locale: localeProp,
|
|
1116
|
-
className,
|
|
1117
|
-
minBarLength,
|
|
1118
|
-
maxVisibleAxes,
|
|
1119
|
-
axisBudget = "auto",
|
|
1120
|
-
onAxisBudget,
|
|
1121
|
-
maxRows,
|
|
1122
|
-
"aria-label": ariaLabel,
|
|
1123
|
-
description,
|
|
1124
|
-
}: PlotProps) {
|
|
1125
|
-
const labels = useKitLabels("seriesChart", DEFAULT_SERIES_CHART_LABELS, labelsProp);
|
|
1126
|
-
const locale = useKitLocale(localeProp);
|
|
1127
|
-
const number = useDefaultFormat(localeProp);
|
|
1128
|
-
// The text size (docs/text-size-harmonization.md §3.2, §4, §10.10): the axis bands, the
|
|
1129
|
-
// tick spacing and the labels drawn in px grow with it — the tick text is `text-xs` and
|
|
1130
|
-
// grows by itself — and the axes aim at three ticks instead of five from Large up.
|
|
1131
|
-
// Strokes, dashes and the grid stay px.
|
|
1132
|
-
const { scale } = useTextSize();
|
|
1133
|
-
const edgeFor = useChartEdge();
|
|
1134
|
-
// The tiles' rule (0.52, DSP-18, Marcel's decision 3): the ink edge under More contrast
|
|
1135
|
-
// only — at Standard it fell on 5 of 8 hues in light and on 2 in dark, the unevenness
|
|
1136
|
-
// #642 took off the tiles.
|
|
1137
|
-
const edges = useEdgesInForce("auto");
|
|
1138
|
-
const ticksAim = tickTarget(scale);
|
|
1139
|
-
const grow = (px: number) => (scale === 1 ? px : Math.round(px * scale));
|
|
1140
|
-
// The keyboard stops' roving tab stop, and the one that has focus (see `PointKeys`).
|
|
1141
|
-
// Up here, above the empty state's early return, like every hook.
|
|
1142
|
-
const [keyStop, setKeyStop] = useState(0);
|
|
1143
|
-
const [keyFocus, setKeyFocus] = useState<number | undefined>(undefined);
|
|
1144
|
-
// Where the tooltip goes, and — off the plot — the row it is portalled into.
|
|
1145
|
-
// Below `sm` (`max-sm:`, at the text size in force) — where `"auto"` takes the tooltip
|
|
1146
|
-
// off the plot. Narrower than the phone layout on purpose: a tablet's plot is wide
|
|
1147
|
-
// enough that the box beside the finger leaves the data in view; a phone's is not.
|
|
1148
|
-
const phone = useBreakpoint("max-sm", false);
|
|
1149
|
-
const placement = resolveTooltipPlacement(tooltip?.placement, useKitChartTooltipPlacement(), phone);
|
|
1150
|
-
const [readout, setReadout] = useState<HTMLDivElement | null>(null);
|
|
1151
|
-
|
|
1152
|
-
// The chart's own width, for the automatic axis budget. Its box, not the plot's: the
|
|
1153
|
-
// box does not change when an axis is hidden, so the rule cannot oscillate. Nothing
|
|
1154
|
-
// measured (jsdom, the first frame) is no automatic budget.
|
|
1155
|
-
const [box, setBox] = useState<HTMLDivElement | null>(null);
|
|
1156
|
-
const [width, setWidth] = useState<number | undefined>(undefined);
|
|
1157
|
-
useLayoutEffect(() => {
|
|
1158
|
-
if (!box || axisBudget === "off" || typeof ResizeObserver === "undefined") return;
|
|
1159
|
-
const measure = () => setWidth(box.getBoundingClientRect().width || undefined);
|
|
1160
|
-
measure();
|
|
1161
|
-
const observer = new ResizeObserver(measure);
|
|
1162
|
-
observer.observe(box);
|
|
1163
|
-
return () => observer.disconnect();
|
|
1164
|
-
}, [box, axisBudget]);
|
|
1165
|
-
// The caller's cap first, then — on what is left — the automatic one.
|
|
1166
|
-
const capped = budgetedAxes(axes, maxVisibleAxes);
|
|
1167
|
-
const afterCap = capped.length
|
|
1168
|
-
? axes.map((axis) => (capped.includes(axis.id) ? { ...axis, hide: true as const } : axis))
|
|
1169
|
-
: axes;
|
|
1170
|
-
const auto =
|
|
1171
|
-
axisBudget === "off"
|
|
1172
|
-
? []
|
|
1173
|
-
: budgetedAxes(
|
|
1174
|
-
afterCap,
|
|
1175
|
-
autoAxisBudget(afterCap, width, (axis) => axisBandWidth(axis.width, Boolean(axis.title), scale), scale),
|
|
1176
|
-
);
|
|
1177
|
-
const budgeted = [...capped, ...auto];
|
|
1178
|
-
const budgetKey = budgeted.join("\n");
|
|
1179
|
-
|
|
1180
|
-
// The rows drawn under `maxRows` (KS U2, `series-chart-thin.ts`): their indices into
|
|
1181
|
-
// the caller's rows, or `undefined` for all of them. Up here, above the empty state's
|
|
1182
|
-
// early return, like every hook; worked out again only when the rows, the series
|
|
1183
|
-
// drawn, the budget or the x window change — not on every render of a drag.
|
|
1184
|
-
const thinKeys = series.map((entry) => entry.key).join("\n");
|
|
1185
|
-
const [windowFrom, windowTo] = zoom?.xDomain ?? [undefined, undefined];
|
|
1186
|
-
const thin = useMemo(() => {
|
|
1187
|
-
if (model.kind === "category" || maxRows === undefined) return undefined;
|
|
1188
|
-
const keys = thinKeys ? thinKeys.split("\n") : [];
|
|
1189
|
-
const window: [number, number] | undefined =
|
|
1190
|
-
windowFrom !== undefined && windowTo !== undefined ? [windowFrom, windowTo] : undefined;
|
|
1191
|
-
const kept = thinnedRows(model.rows, model.plotKey, keys, maxRows, window);
|
|
1192
|
-
if (!kept) return undefined;
|
|
1193
|
-
return {
|
|
1194
|
-
kept,
|
|
1195
|
-
plotted: kept.map((index) => model.rows[index]),
|
|
1196
|
-
source: kept.map((index) => model.source[index]),
|
|
1197
|
-
};
|
|
1198
|
-
}, [model, thinKeys, maxRows, windowFrom, windowTo]);
|
|
1199
|
-
|
|
1200
|
-
// Reported when the SET changes, not on every render — an inline callback is a new
|
|
1201
|
-
// function each time, and the guard keeps it from being called again for nothing.
|
|
1202
|
-
const reported = useRef("");
|
|
1203
|
-
useEffect(() => {
|
|
1204
|
-
if (budgetKey === reported.current) return;
|
|
1205
|
-
reported.current = budgetKey;
|
|
1206
|
-
onAxisBudget?.(budgetKey ? budgetKey.split("\n") : []);
|
|
1207
|
-
}, [budgetKey, onAxisBudget]);
|
|
1208
|
-
|
|
1209
|
-
// A number or a CSS length is set inline; any other string is a class. Either way the
|
|
1210
|
-
// one value sizes both the chart and its empty state.
|
|
1211
|
-
const { className: heightClass, style: heightStyle } = chartHeightProps(height);
|
|
1212
|
-
|
|
1213
|
-
// A named figure, described by the caller's sentence and — where a drag zooms — the
|
|
1214
|
-
// gesture (0.52, refactor audit 2026-10-30, DSP-5). The hint used to be the name of the
|
|
1215
|
-
// zoom layer's rect, a `role="application"` that could not take focus. The description
|
|
1216
|
-
// is `hidden`: read through `aria-describedby`, never twice in browse mode.
|
|
1217
|
-
const drawable = model.source.length > 0 && series.length > 0;
|
|
1218
|
-
const spoken = [description, drawable && zoom?.layer ? labels.zoomHint : undefined].filter(Boolean).join(" ");
|
|
1219
|
-
// Inside the root, not after it as a sibling: a StaticSeriesChart then stopped being its
|
|
1220
|
-
// parent's last child, and a stack's `space-y-*` / `divide-y` gave it a margin or a rule
|
|
1221
|
-
// it never had (0.52 code review, deep, charts, findings 7 and 14 — Treemap's copy of this
|
|
1222
|
-
// went the same way). The plot's root is `ChartContainer`, which takes the sentence itself.
|
|
1223
|
-
const about = useFigureDescription(spoken || undefined);
|
|
1224
|
-
const figure = { role: "figure", "aria-label": ariaLabel, "aria-describedby": about.describedBy } as const;
|
|
1225
|
-
|
|
1226
|
-
// The empty state takes the chart's own height and is centred in it: a chart that
|
|
1227
|
-
// shrank to its "nothing to draw" sentence moved everything under it up the page
|
|
1228
|
-
// the moment a legend entry was switched off.
|
|
1229
|
-
if (!drawable) {
|
|
1230
|
-
return (
|
|
1231
|
-
<div
|
|
1232
|
-
{...figure}
|
|
1233
|
-
className={cn("flex w-full items-center justify-center px-2 text-center", heightClass)}
|
|
1234
|
-
style={heightStyle}
|
|
1235
|
-
>
|
|
1236
|
-
{empty !== undefined ? empty : <p className="text-xs text-muted">{labels.empty}</p>}
|
|
1237
|
-
{about.node}
|
|
1238
|
-
</div>
|
|
1239
|
-
);
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
const x = xAxis;
|
|
1243
|
-
const xKey = model.plotKey;
|
|
1244
|
-
// What is DRAWN — the thinned rows under `maxRows`, else the caller's — and what is
|
|
1245
|
-
// FITTED: every row, so a band, a whole-number tick and the zoom's refit are the same
|
|
1246
|
-
// with a budget as without one.
|
|
1247
|
-
const plotted = thin?.plotted ?? model.rows;
|
|
1248
|
-
const rows = thin?.source ?? model.source;
|
|
1249
|
-
const allPlotted = model.rows;
|
|
1250
|
-
/** A drawn row's position in the CALLER's rows, which dots and hits report. */
|
|
1251
|
-
const origin = (index: number) => thin?.kept[index] ?? index;
|
|
1252
|
-
// What the budget took off the chart: an axis drawn as `hide` — and its unit, which
|
|
1253
|
-
// the tooltip names now that no title says it. Axes the caller hid keep their series'
|
|
1254
|
-
// labels as given, as they always did.
|
|
1255
|
-
const drawnAxes = budgeted.length
|
|
1256
|
-
? axes.map((axis) => (budgeted.includes(axis.id) ? { ...axis, hide: true as const } : axis))
|
|
1257
|
-
: axes;
|
|
1258
|
-
const lostUnit = new Map(axes.filter((axis) => budgeted.includes(axis.id)).map((axis) => [axis.id, axisUnit(axis)]));
|
|
1259
|
-
const config: ChartConfig = Object.fromEntries(
|
|
1260
|
-
series.map((entry, index) => [
|
|
1261
|
-
entry.key,
|
|
1262
|
-
{
|
|
1263
|
-
label: withUnit(entry.label, lostUnit.get(entry.axis ?? DEFAULT_Y_AXIS)),
|
|
1264
|
-
color: entry.color ?? paletteFor(index),
|
|
1265
|
-
},
|
|
1266
|
-
]),
|
|
1267
|
-
);
|
|
1268
|
-
const visible = drawnAxes.filter((axis) => !axis.hide);
|
|
1269
|
-
// The grid hangs its horizontal rules off ONE y axis, and recharts looks for the one
|
|
1270
|
-
// whose id is its own default (`0`). Every axis here is named, so without saying
|
|
1271
|
-
// which, it finds none and draws no horizontal rules at all. The first visible axis,
|
|
1272
|
-
// because those are the ticks a reader puts a ruler on.
|
|
1273
|
-
const gridAxis = (visible[0] ?? drawnAxes[0])?.id ?? DEFAULT_Y_AXIS;
|
|
1274
|
-
const onLeft = visible.some((axis) => (axis.orientation ?? "left") === "left");
|
|
1275
|
-
const onRight = visible.some((axis) => axis.orientation === "right");
|
|
1276
|
-
// The margins are what is left once the axes have their bands: an axis band IS the
|
|
1277
|
-
// gutter on its side, so a margin beside one is a second gutter. What remains is the
|
|
1278
|
-
// overhang of the first/last x tick where no y axis covers it.
|
|
1279
|
-
const margin = {
|
|
1280
|
-
// Room for a marker's label over a point at the top of the band.
|
|
1281
|
-
top: markers?.some((marker) => marker.label) ? grow(22) : 8,
|
|
1282
|
-
// The first and last x tick's overhang: text, so it grows with it.
|
|
1283
|
-
right: onRight ? 0 : grow(10),
|
|
1284
|
-
left: onLeft ? 0 : grow(10),
|
|
1285
|
-
// Under the ticks, not under the whole axis: whatever comes next owns the gap.
|
|
1286
|
-
bottom: x.title ? grow(18) : 2,
|
|
1287
|
-
};
|
|
1288
|
-
|
|
1289
|
-
const refs = references ?? [];
|
|
1290
|
-
const xRefs = refs.filter((ref) => ref.axis === "x");
|
|
1291
|
-
const yRefs = refs.filter((ref) => ref.axis !== "x");
|
|
1292
|
-
const xPos = (value: SeriesChartXValue) => model.position(value);
|
|
1293
|
-
|
|
1294
|
-
// Fitted with air around it, unless the reader has zoomed or the caller pinned it.
|
|
1295
|
-
// Ticks are the round values INSIDE whichever domain that is (see
|
|
1296
|
-
// `series-chart-ticks.ts`), so a zoom window still gets round numbers, just finer.
|
|
1297
|
-
// A category axis is its slots, each half a slot of air either side — room for a
|
|
1298
|
-
// bar, and the tick under the middle of it.
|
|
1299
|
-
const fittedX: [number, number] | undefined =
|
|
1300
|
-
zoom?.xDomain ??
|
|
1301
|
-
(model.kind === "category"
|
|
1302
|
-
? [-0.5, rows.length - 0.5]
|
|
1303
|
-
: padBand(
|
|
1304
|
-
...(extend(undefined, [
|
|
1305
|
-
...allPlotted.map((row) => finite(row[xKey])),
|
|
1306
|
-
...xRefs.map((ref) => xPos(ref.value)),
|
|
1307
|
-
...(markers ?? []).map((marker) => xPos(marker.x)),
|
|
1308
|
-
]) ?? [Infinity, -Infinity]),
|
|
1309
|
-
));
|
|
1310
|
-
|
|
1311
|
-
const timeUnit = model.kind === "time" ? timeTicksWithUnit(fittedX, ticksAim) : undefined;
|
|
1312
|
-
// Whole-number ticks on a number line whose rows are all whole numbers — see
|
|
1313
|
-
// `SeriesChartX.integerTicks`.
|
|
1314
|
-
const integerX =
|
|
1315
|
-
model.kind === "number" &&
|
|
1316
|
-
(x.integerTicks ??
|
|
1317
|
-
allPlotted.every((row) => {
|
|
1318
|
-
const value = finite(row[xKey]);
|
|
1319
|
-
return value === undefined || Number.isInteger(value);
|
|
1320
|
-
}));
|
|
1321
|
-
const xTicks =
|
|
1322
|
-
resolveTicks(x.tickValues, fittedX, xPos) ??
|
|
1323
|
-
(model.kind === "category"
|
|
1324
|
-
? categoryTicks(fittedX, rows.length)
|
|
1325
|
-
: model.kind === "time"
|
|
1326
|
-
? timeUnit?.ticks
|
|
1327
|
-
: integerX
|
|
1328
|
-
? (integerTicks(fittedX, ticksAim) ?? niceTicks(fittedX, ticksAim))
|
|
1329
|
-
: niceTicks(fittedX, ticksAim));
|
|
1330
|
-
|
|
1331
|
-
// Ticks and the tooltip heading, back in the caller's terms.
|
|
1332
|
-
const timeFormat = new Intl.DateTimeFormat(locale, TIME_TICK_FORMAT[timeUnit?.unit ?? "day"]);
|
|
1333
|
-
const dateFormat = new Intl.DateTimeFormat(locale, {
|
|
1334
|
-
dateStyle: "medium",
|
|
1335
|
-
...(timeUnit?.unit === "hour" ? { timeStyle: "short" } : {}),
|
|
1336
|
-
});
|
|
1337
|
-
const categoryText = (value: SeriesChartXValue) =>
|
|
1338
|
-
value instanceof Date ? dateFormat.format(value) : typeof value === "number" ? number(value) : String(value ?? "");
|
|
1339
|
-
const tickAt = (position: number): SeriesChartXTick => ({
|
|
1340
|
-
value: model.valueAt(position),
|
|
1341
|
-
...(model.kind === "category" ? { index: Math.round(position) } : {}),
|
|
1342
|
-
...(timeUnit ? { unit: timeUnit.unit } : {}),
|
|
1343
|
-
});
|
|
1344
|
-
const defaultFormat = (position: number, tick: SeriesChartXTick) =>
|
|
1345
|
-
model.kind === "category"
|
|
1346
|
-
? categoryText(tick.value)
|
|
1347
|
-
: model.kind === "time"
|
|
1348
|
-
? timeFormat.format(position)
|
|
1349
|
-
: number(position);
|
|
1350
|
-
const format = x.format ?? defaultFormat;
|
|
1351
|
-
const xFormat = (position: number) => format(position, tickAt(position));
|
|
1352
|
-
const label = x.label ?? (model.kind === "time" ? (position: number) => dateFormat.format(position) : format);
|
|
1353
|
-
const xLabel = (position: number) => label(position, tickAt(position));
|
|
1354
|
-
|
|
1355
|
-
const tickAngle = x.ticks === false ? 0 : (x.tickAngle ?? 0);
|
|
1356
|
-
const tickBand = tiltedTickBand(
|
|
1357
|
-
(xTicks ?? []).map((tick) => xFormat(tick)),
|
|
1358
|
-
tickAngle,
|
|
1359
|
-
scale,
|
|
1360
|
-
);
|
|
1361
|
-
|
|
1362
|
-
const source: ZoomFitSource = {
|
|
1363
|
-
rows: allPlotted,
|
|
1364
|
-
series,
|
|
1365
|
-
axes,
|
|
1366
|
-
xKey,
|
|
1367
|
-
};
|
|
1368
|
-
// An axis a bar or an area stands on is read from zero (see `includeZero`).
|
|
1369
|
-
const anchored = (axis: SeriesChartAxis) =>
|
|
1370
|
-
axis.includeZero ??
|
|
1371
|
-
series.some((entry) => (entry.axis ?? DEFAULT_Y_AXIS) === axis.id && (entry.type ?? "line") !== "line");
|
|
1372
|
-
// Whole-number ticks on an axis whose values are all whole — see
|
|
1373
|
-
// `SeriesChartAxis.integerTicks`. A stack of whole layers sums to a whole number, so
|
|
1374
|
-
// the layers are enough to look at.
|
|
1375
|
-
const wholeOnly = (axis: SeriesChartAxis) =>
|
|
1376
|
-
axis.integerTicks ??
|
|
1377
|
-
series
|
|
1378
|
-
.filter((entry) => (entry.axis ?? DEFAULT_Y_AXIS) === axis.id)
|
|
1379
|
-
.every((entry) =>
|
|
1380
|
-
allPlotted.every((row) => {
|
|
1381
|
-
const value = finite(row[entry.key]);
|
|
1382
|
-
return value === undefined || Number.isInteger(value);
|
|
1383
|
-
}),
|
|
1384
|
-
);
|
|
1385
|
-
const onAxis = (axisId: string) => (ref: { axis?: string }) => (ref.axis ?? DEFAULT_Y_AXIS) === axisId;
|
|
1386
|
-
const fittedY = (axis: SeriesChartAxis): [number, number] | undefined => {
|
|
1387
|
-
const own = [
|
|
1388
|
-
...yRefs.filter(onAxis(axis.id)).map((ref) => finite(ref.value)),
|
|
1389
|
-
...(markers ?? []).filter(onAxis(axis.id)).map((marker) => finite(marker.y)),
|
|
1390
|
-
];
|
|
1391
|
-
if (anchored(axis)) {
|
|
1392
|
-
// Never a dragged y window: refitted to the x window, still from zero.
|
|
1393
|
-
if (zoom?.xDomain) return anchoredBand(axisExtent(source, axis.id, zoom.xDomain)) ?? axis.domain;
|
|
1394
|
-
return axis.domain ?? anchoredBand(extend(axisExtent(source, axis.id), own));
|
|
1395
|
-
}
|
|
1396
|
-
return (
|
|
1397
|
-
zoom?.yDomains[axis.id] ??
|
|
1398
|
-
axis.domain ??
|
|
1399
|
-
padBand(...(extend(axisExtent(source, axis.id), own) ?? [Infinity, -Infinity]))
|
|
1400
|
-
);
|
|
1401
|
-
};
|
|
1402
|
-
|
|
1403
|
-
// The abscissa of a row in the caller's terms: a category is its slot, which is
|
|
1404
|
-
// its index; a time or a number is read back from where it was plotted.
|
|
1405
|
-
const xOf = (index: number): SeriesChartXValue =>
|
|
1406
|
-
model.kind === "category"
|
|
1407
|
-
? (rows[index][model.sourceKey] as SeriesChartXValue)
|
|
1408
|
-
: model.valueAt(finite(plotted[index][xKey]) ?? NaN);
|
|
1409
|
-
const hitAt = (index: number, key?: string): SeriesChartHit | undefined => {
|
|
1410
|
-
const row = rows[index];
|
|
1411
|
-
return row ? { index: origin(index), row, x: xOf(index), key } : undefined;
|
|
1412
|
-
};
|
|
1413
|
-
|
|
1414
|
-
// The keyboard stops — every bar with a value, slot by slot; or, with no bars, every
|
|
1415
|
-
// slot with any value. Only what is inside the window on show. Named on demand: past
|
|
1416
|
-
// ALL_STOPS_UP_TO only five are drawn, and naming is a date and a number format each.
|
|
1417
|
-
const stops: PointStop[] = [];
|
|
1418
|
-
{
|
|
1419
|
-
const valueText = valueFormat ?? number;
|
|
1420
|
-
const nameOf = (entry: SeriesChartSeries) =>
|
|
1421
|
-
typeof entry.label === "string" || typeof entry.label === "number" ? String(entry.label) : entry.key;
|
|
1422
|
-
const cellText = (entry: SeriesChartSeries, value: number) => {
|
|
1423
|
-
const name = nameOf(entry);
|
|
1424
|
-
return name ? `${name}: ${valueText(value)}` : valueText(value);
|
|
1425
|
-
};
|
|
1426
|
-
const bars = series.filter((entry) => entry.type === "bar");
|
|
1427
|
-
const [low, high] = fittedX ?? [-Infinity, Infinity];
|
|
1428
|
-
const placed = plotted
|
|
1429
|
-
.map((row, index) => ({ index, at: model.kind === "category" ? index : finite(row[xKey]) }))
|
|
1430
|
-
.filter(
|
|
1431
|
-
(slot): slot is { index: number; at: number } => slot.at !== undefined && slot.at >= low && slot.at <= high,
|
|
1432
|
-
)
|
|
1433
|
-
.sort((a, b) => a.at - b.at);
|
|
1434
|
-
placed.forEach(({ index, at }, k) => {
|
|
1435
|
-
const from = k > 0 ? (placed[k - 1].at + at) / 2 : low;
|
|
1436
|
-
const to = k < placed.length - 1 ? (placed[k + 1].at + at) / 2 : high;
|
|
1437
|
-
// The heading the tooltip would give it, when that is text; else the tick.
|
|
1438
|
-
const where = () => {
|
|
1439
|
-
const heading = xLabel(at);
|
|
1440
|
-
return typeof heading === "string" && heading ? heading : xFormat(at);
|
|
1441
|
-
};
|
|
1442
|
-
const valued = (bars.length ? bars : series)
|
|
1443
|
-
.map((entry) => ({ entry, value: finite(rows[index]?.[entry.key]) }))
|
|
1444
|
-
.filter((cell): cell is { entry: SeriesChartSeries; value: number } => cell.value !== undefined);
|
|
1445
|
-
if (bars.length) {
|
|
1446
|
-
for (const { entry, value } of valued) {
|
|
1447
|
-
stops.push({ index, key: entry.key, from, to, name: () => `${where()} — ${cellText(entry, value)}` });
|
|
1448
|
-
}
|
|
1449
|
-
} else if (valued.length) {
|
|
1450
|
-
stops.push({
|
|
1451
|
-
index,
|
|
1452
|
-
from,
|
|
1453
|
-
to,
|
|
1454
|
-
name: () => `${where()} — ${valued.map(({ entry, value }) => cellText(entry, value)).join(", ")}`,
|
|
1455
|
-
});
|
|
1456
|
-
}
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1459
|
-
const focusedStop = keyFocus === undefined ? undefined : stops[keyFocus];
|
|
1460
|
-
|
|
1461
|
-
const dotFor = (entry: SeriesChartSeries) => {
|
|
1462
|
-
const want = entry.dot;
|
|
1463
|
-
if (!want) return false;
|
|
1464
|
-
const color = `var(--color-${entry.key})`;
|
|
1465
|
-
return (props: { cx?: number; cy?: number; index: number }) => {
|
|
1466
|
-
const { cx, cy, index } = props;
|
|
1467
|
-
const value = finite(rows[index]?.[entry.key]);
|
|
1468
|
-
if (value === undefined || !Number.isFinite(cx) || !Number.isFinite(cy)) return <g />;
|
|
1469
|
-
const point: SeriesChartPoint = {
|
|
1470
|
-
key: entry.key,
|
|
1471
|
-
index: origin(index),
|
|
1472
|
-
row: rows[index],
|
|
1473
|
-
x: xOf(index),
|
|
1474
|
-
value,
|
|
1475
|
-
cx: cx!,
|
|
1476
|
-
cy: cy!,
|
|
1477
|
-
color,
|
|
1478
|
-
};
|
|
1479
|
-
const drawn = want === true ? true : want(point);
|
|
1480
|
-
if (drawn === true) {
|
|
1481
|
-
return (
|
|
1482
|
-
<circle
|
|
1483
|
-
className="recharts-dot"
|
|
1484
|
-
cx={cx}
|
|
1485
|
-
cy={cy}
|
|
1486
|
-
r={3}
|
|
1487
|
-
fill={color}
|
|
1488
|
-
// Ringed in the surface, so a dot on a crossing line still reads as a dot.
|
|
1489
|
-
stroke="var(--bg-surface)"
|
|
1490
|
-
strokeWidth={1.5}
|
|
1491
|
-
/>
|
|
1492
|
-
);
|
|
1493
|
-
}
|
|
1494
|
-
if (drawn === false || drawn == null) return <g />;
|
|
1495
|
-
return <g>{drawn}</g>;
|
|
1496
|
-
};
|
|
1497
|
-
};
|
|
1498
|
-
|
|
1499
|
-
const animation = {
|
|
1500
|
-
isAnimationActive: animationMs > 0,
|
|
1501
|
-
animationDuration: animationMs,
|
|
1502
|
-
animationEasing: "ease-out" as const,
|
|
1503
|
-
};
|
|
1504
|
-
|
|
1505
|
-
const inRow = placement !== "cursor";
|
|
1506
|
-
const chart = (
|
|
1507
|
-
<ChartContainer
|
|
1508
|
-
{...(inRow ? {} : { role: "figure", "aria-label": ariaLabel, description: spoken || undefined })}
|
|
1509
|
-
ref={setBox}
|
|
1510
|
-
data-axis-budget={budgeted.length ? budgetKey.replace(/\n/g, " ") : undefined}
|
|
1511
|
-
// "drawn/all" while `maxRows` thins: what a reader of the DOM (a test, a bug
|
|
1512
|
-
// report) needs to know the picture is an envelope.
|
|
1513
|
-
data-thinned={thin ? `${thin.kept.length}/${allPlotted.length}` : undefined}
|
|
1514
|
-
config={config}
|
|
1515
|
-
className={cn(
|
|
1516
|
-
"w-full",
|
|
1517
|
-
// With a readout the chart's height is the whole block's, and the plot takes
|
|
1518
|
-
// what the row leaves.
|
|
1519
|
-
inRow ? "min-h-0 flex-1" : heightClass,
|
|
1520
|
-
className,
|
|
1521
|
-
onPointClick && "cursor-pointer",
|
|
1522
|
-
)}
|
|
1523
|
-
style={inRow ? undefined : heightStyle}
|
|
1524
|
-
>
|
|
1525
|
-
<ComposedChart
|
|
1526
|
-
data={plotted as Record<string, unknown>[]}
|
|
1527
|
-
margin={margin}
|
|
1528
|
-
// Positive and negative layers stacked apart, as `axisExtent` fits them — a
|
|
1529
|
-
// month's expenses hang below the axis instead of eating into its income.
|
|
1530
|
-
stackOffset="sign"
|
|
1531
|
-
// recharts' own keyboard layer makes the whole surface an unnamed
|
|
1532
|
-
// `role="application"` tab stop whose arrows move a tooltip nothing announces —
|
|
1533
|
-
// a second stop beside `PointKeys`, which every chart has since 0.52 (DSP-5).
|
|
1534
|
-
accessibilityLayer={false}
|
|
1535
|
-
onClick={
|
|
1536
|
-
onPointClick
|
|
1537
|
-
? (state) => {
|
|
1538
|
-
const index = Number(state?.activeTooltipIndex ?? state?.activeIndex);
|
|
1539
|
-
const hit = Number.isInteger(index) ? hitAt(index) : undefined;
|
|
1540
|
-
if (hit) onPointClick(hit);
|
|
1541
|
-
}
|
|
1542
|
-
: undefined
|
|
1543
|
-
}
|
|
1544
|
-
>
|
|
1545
|
-
{/* Both ways: a measurement plot is read by putting a ruler on it, and a
|
|
1546
|
-
horizontal-only grid answers half of those questions. */}
|
|
1547
|
-
<CartesianGrid yAxisId={gridAxis} />
|
|
1548
|
-
<XAxis
|
|
1549
|
-
dataKey={xKey}
|
|
1550
|
-
// Numeric, not categorical: a measured sweep is unevenly spaced, and a
|
|
1551
|
-
// category axis would straighten exactly the curvature the chart is for.
|
|
1552
|
-
// A category chart is numeric too — on the slot index — which is what lets
|
|
1553
|
-
// it zoom and keeps its ticks under the middle of each bar group.
|
|
1554
|
-
type="number"
|
|
1555
|
-
domain={fittedX ?? ["dataMin", "dataMax"]}
|
|
1556
|
-
ticks={xTicks}
|
|
1557
|
-
// Clip the lines to a zoom window instead of recharts widening it back out.
|
|
1558
|
-
allowDataOverflow={zoom?.xDomain !== undefined || model.kind === "category"}
|
|
1559
|
-
tickLine={false}
|
|
1560
|
-
axisLine={false}
|
|
1561
|
-
minTickGap={grow(MIN_TICK_GAP)}
|
|
1562
|
-
// Where the ticks crowd, drop every Nth rather than recharts' default
|
|
1563
|
-
// `preserveEnd`, which drops whichever single tick collides: a phone's whole-week
|
|
1564
|
-
// axis came out 2 4 6 8 _ 12, a doubled gap that reads as a missing week. Every
|
|
1565
|
-
// other tick, keeping the last, gives 4 8 12 — still an even ruler.
|
|
1566
|
-
interval="equidistantPreserveEnd"
|
|
1567
|
-
tick={x.ticks === false ? false : undefined}
|
|
1568
|
-
{...(tickAngle ? { angle: tickAngle, textAnchor: tickAngle < 0 ? "end" : "start" } : {})}
|
|
1569
|
-
// With neither ticks nor title there is nothing to reserve the band for, and
|
|
1570
|
-
// recharts' own 30 px would leave a gap under every chart of a stack.
|
|
1571
|
-
height={x.ticks === false && !x.title ? 4 : tickBand}
|
|
1572
|
-
tickFormatter={(value: number) => xFormat(Number(value))}
|
|
1573
|
-
>
|
|
1574
|
-
{x.title && (
|
|
1575
|
-
<Label value={x.title} position="insideBottom" offset={-grow(12)} className="fill-muted text-caption" />
|
|
1576
|
-
)}
|
|
1577
|
-
</XAxis>
|
|
1578
|
-
{drawnAxes.map((axis) => {
|
|
1579
|
-
const domain = fittedY(axis);
|
|
1580
|
-
const zoomed = anchored(axis) ? zoom?.xDomain !== undefined : zoom?.yDomains[axis.id] !== undefined;
|
|
1581
|
-
return (
|
|
1582
|
-
<YAxis
|
|
1583
|
-
key={axis.id}
|
|
1584
|
-
yAxisId={axis.id}
|
|
1585
|
-
hide={axis.hide}
|
|
1586
|
-
domain={domain}
|
|
1587
|
-
ticks={
|
|
1588
|
-
resolveTicks(axis.tickValues, domain, finite) ??
|
|
1589
|
-
(wholeOnly(axis)
|
|
1590
|
-
? (integerTicks(domain, ticksAim) ?? niceTicks(domain, ticksAim))
|
|
1591
|
-
: niceTicks(domain, ticksAim))
|
|
1592
|
-
}
|
|
1593
|
-
allowDataOverflow={zoomed}
|
|
1594
|
-
orientation={axis.orientation ?? "left"}
|
|
1595
|
-
// Nothing for a hidden axis. An axis that turns hidden on a MOUNTED chart —
|
|
1596
|
-
// what the budget does on every resize across its threshold — kept its old
|
|
1597
|
-
// width in recharts' stacking of that side, and pushed the axes still drawn
|
|
1598
|
-
// off the chart's edge. A zero width leaves nothing stale to count.
|
|
1599
|
-
width={axis.hide ? 0 : axisBandWidth(axis.width, Boolean(axis.title), scale)}
|
|
1600
|
-
tickLine={false}
|
|
1601
|
-
axisLine={false}
|
|
1602
|
-
tickFormatter={axis.format ?? number}
|
|
1603
|
-
// With an axis per channel the tint is the only thing saying which
|
|
1604
|
-
// numbers belong to which line.
|
|
1605
|
-
tick={axis.color ? { fill: axis.color } : undefined}
|
|
1606
|
-
>
|
|
1607
|
-
{axis.title && !axis.hide && (
|
|
1608
|
-
<Label
|
|
1609
|
-
value={axis.title}
|
|
1610
|
-
// Rotated so both sides read upward from the bottom of their axis.
|
|
1611
|
-
angle={axis.orientation === "right" ? 90 : -90}
|
|
1612
|
-
position={axis.orientation === "right" ? "insideRight" : "insideLeft"}
|
|
1613
|
-
// Inline, so a sole series' colour beats the class's neutral fill —
|
|
1614
|
-
// and absent for a shared axis, so the class draws it.
|
|
1615
|
-
style={{ textAnchor: "middle", fill: soleSeriesColor(axis, series) }}
|
|
1616
|
-
offset={grow(AXIS_TITLE_OFFSET)}
|
|
1617
|
-
className="fill-muted text-caption"
|
|
1618
|
-
/>
|
|
1619
|
-
)}
|
|
1620
|
-
</YAxis>
|
|
1621
|
-
);
|
|
1622
|
-
})}
|
|
1623
|
-
{inRow ? (
|
|
1624
|
-
// Not before the row exists: without its own portal recharts would float this
|
|
1625
|
-
// content over the plot for the first frame.
|
|
1626
|
-
readout && (
|
|
1627
|
-
<ChartTooltip
|
|
1628
|
-
portal={readout}
|
|
1629
|
-
// recharts hides an inactive tooltip; the row shows its idle state instead.
|
|
1630
|
-
wrapperStyle={{ visibility: "visible" }}
|
|
1631
|
-
defaultIndex={focusedStop?.index}
|
|
1632
|
-
content={
|
|
1633
|
-
<ChartTooltipContent
|
|
1634
|
-
variant="readout"
|
|
1635
|
-
idleKeys={series.map((entry) => entry.key)}
|
|
1636
|
-
idleLabel={x.title || undefined}
|
|
1637
|
-
labelFormatter={(value) => xLabel(Number(value))}
|
|
1638
|
-
valueFormatter={valueFormat ?? number}
|
|
1639
|
-
/>
|
|
1640
|
-
}
|
|
1641
|
-
/>
|
|
1642
|
-
)
|
|
1643
|
-
) : (
|
|
1644
|
-
<ChartTooltip
|
|
1645
|
-
{...(tooltip?.allowEscapeViewBox || tooltip?.boundary
|
|
1646
|
-
? { allowEscapeViewBox: tooltip.allowEscapeViewBox ?? { x: true } }
|
|
1647
|
-
: {})}
|
|
1648
|
-
// The content shifts itself 12 px off the cursor (or flips) against the
|
|
1649
|
-
// boundary; recharts' own offset on top would double it.
|
|
1650
|
-
{...(tooltip?.boundary ? { offset: 0 } : {})}
|
|
1651
|
-
// The keyboard's stop shows its tooltip as the pointer's would.
|
|
1652
|
-
defaultIndex={focusedStop?.index}
|
|
1653
|
-
content={
|
|
1654
|
-
<ChartTooltipContent
|
|
1655
|
-
labelFormatter={(value) => xLabel(Number(value))}
|
|
1656
|
-
valueFormatter={valueFormat ?? number}
|
|
1657
|
-
boundaryRef={tooltip?.boundary}
|
|
1658
|
-
/>
|
|
1659
|
-
}
|
|
1660
|
-
/>
|
|
1661
|
-
)}
|
|
1662
|
-
{series.map((entry) => {
|
|
1663
|
-
const type = entry.type ?? "line";
|
|
1664
|
-
const yAxisId = entry.axis ?? DEFAULT_Y_AXIS;
|
|
1665
|
-
const color = `var(--color-${entry.key})`;
|
|
1666
|
-
// Under More contrast, a filled mark in a hue under 3:1 against the ground gets
|
|
1667
|
-
// a 1px ink edge (WCAG 1.4.11, anyplot's rule) — measured on the colour the
|
|
1668
|
-
// config paints. At Standard none does (see `edges`).
|
|
1669
|
-
const edge = edges === "contrast" ? edgeFor(config[entry.key]?.color) : undefined;
|
|
1670
|
-
const own = entry.dash ?? (entry.dashed ? 1 : 0);
|
|
1671
|
-
const dash = entry.step ? strokeDash(STEP_DASH) : typeof own === "string" ? own : strokeDash(own);
|
|
1672
|
-
const curve = entry.step ? "stepAfter" : (entry.curve ?? "monotone");
|
|
1673
|
-
const width = entry.strokeWidth ?? (entry.step ? STEP_WIDTH : LINE_WIDTH);
|
|
1674
|
-
if (type === "bar") {
|
|
1675
|
-
const stub = entry.minBarLength ?? minBarLength;
|
|
1676
|
-
return (
|
|
1677
|
-
<Bar
|
|
1678
|
-
key={entry.key}
|
|
1679
|
-
yAxisId={yAxisId}
|
|
1680
|
-
dataKey={entry.key}
|
|
1681
|
-
stackId={entry.stack}
|
|
1682
|
-
fill={color}
|
|
1683
|
-
fillOpacity={entry.fillOpacity}
|
|
1684
|
-
{...(edge ? { stroke: edge, strokeWidth: 1 } : {})}
|
|
1685
|
-
radius={entry.stack === undefined ? BAR_RADIUS : 0}
|
|
1686
|
-
// Read off the row rather than recharts' `value`: in a stack that is the
|
|
1687
|
-
// layer's running top, which a hole has too — and a hole gets no stub.
|
|
1688
|
-
{...(stub
|
|
1689
|
-
? {
|
|
1690
|
-
minPointSize: (_value: unknown, index: number) =>
|
|
1691
|
-
finite(plotted[index]?.[entry.key]) === undefined ? 0 : stub,
|
|
1692
|
-
}
|
|
1693
|
-
: {})}
|
|
1694
|
-
// Only the focused stop's series swaps its shape, and only for as long
|
|
1695
|
-
// as it has focus: every other bar keeps recharts' own.
|
|
1696
|
-
{...(focusedStop?.key === entry.key ? { shape: focusedBarShape(focusedStop.index) } : {})}
|
|
1697
|
-
onClick={
|
|
1698
|
-
onPointClick
|
|
1699
|
-
? (_bar, index, event) => {
|
|
1700
|
-
// The plot's own click would report the same slot again,
|
|
1701
|
-
// without the series.
|
|
1702
|
-
event.stopPropagation();
|
|
1703
|
-
const hit = hitAt(index, entry.key);
|
|
1704
|
-
if (hit) onPointClick(hit);
|
|
1705
|
-
}
|
|
1706
|
-
: undefined
|
|
1707
|
-
}
|
|
1708
|
-
{...animation}
|
|
1709
|
-
/>
|
|
1710
|
-
);
|
|
1711
|
-
}
|
|
1712
|
-
if (type === "area") {
|
|
1713
|
-
return (
|
|
1714
|
-
<Area
|
|
1715
|
-
key={entry.key}
|
|
1716
|
-
yAxisId={yAxisId}
|
|
1717
|
-
type={curve}
|
|
1718
|
-
dataKey={entry.key}
|
|
1719
|
-
stackId={entry.stack}
|
|
1720
|
-
// The edge replaces the hue on the area's outline only; the fill keeps it,
|
|
1721
|
-
// and the outline its width (0.52, DSP-18: it was 1px, whatever
|
|
1722
|
-
// `strokeWidth` said).
|
|
1723
|
-
stroke={edge ?? color}
|
|
1724
|
-
strokeWidth={width}
|
|
1725
|
-
strokeDasharray={dash}
|
|
1726
|
-
fill={color}
|
|
1727
|
-
fillOpacity={entry.fillOpacity ?? (entry.stack !== undefined ? 0.55 : 0.2)}
|
|
1728
|
-
dot={dotFor(entry)}
|
|
1729
|
-
{...(entry.activeDot !== undefined ? { activeDot: entry.activeDot } : {})}
|
|
1730
|
-
connectNulls={connectNulls}
|
|
1731
|
-
{...animation}
|
|
1732
|
-
/>
|
|
1733
|
-
);
|
|
1734
|
-
}
|
|
1735
|
-
return (
|
|
1736
|
-
<Line
|
|
1737
|
-
key={entry.key}
|
|
1738
|
-
yAxisId={yAxisId}
|
|
1739
|
-
type={curve}
|
|
1740
|
-
dataKey={entry.key}
|
|
1741
|
-
stroke={color}
|
|
1742
|
-
strokeWidth={width}
|
|
1743
|
-
strokeDasharray={dash}
|
|
1744
|
-
dot={dotFor(entry)}
|
|
1745
|
-
{...(entry.activeDot !== undefined ? { activeDot: entry.activeDot } : {})}
|
|
1746
|
-
connectNulls={connectNulls}
|
|
1747
|
-
{...animation}
|
|
1748
|
-
/>
|
|
1749
|
-
);
|
|
1750
|
-
})}
|
|
1751
|
-
{spans?.map((span) => (
|
|
1752
|
-
<ReferenceLine
|
|
1753
|
-
key={span.key}
|
|
1754
|
-
yAxisId={span.axis ?? DEFAULT_Y_AXIS}
|
|
1755
|
-
segment={[
|
|
1756
|
-
{ x: span.x, y: span.from },
|
|
1757
|
-
{ x: span.x, y: span.to },
|
|
1758
|
-
]}
|
|
1759
|
-
stroke={span.color ?? "var(--text-muted)"}
|
|
1760
|
-
strokeWidth={2}
|
|
1761
|
-
// Discarded rather than clamped when zoomed past: a span clamped to the
|
|
1762
|
-
// window's edge draws a vertical line at an abscissa it never stood at.
|
|
1763
|
-
ifOverflow="discard"
|
|
1764
|
-
/>
|
|
1765
|
-
))}
|
|
1766
|
-
{refs.map((ref, index) => {
|
|
1767
|
-
const vertical = ref.axis === "x";
|
|
1768
|
-
const at = vertical ? xPos(ref.value) : finite(ref.value);
|
|
1769
|
-
if (at === undefined) return null;
|
|
1770
|
-
const color = ref.color ?? TONE_COLOR[ref.tone ?? "muted"];
|
|
1771
|
-
return (
|
|
1772
|
-
<ReferenceLine
|
|
1773
|
-
key={ref.key ?? `reference-${index}`}
|
|
1774
|
-
// A vertical line still needs a y axis to be drawn against, and every
|
|
1775
|
-
// axis here is named — the grid's is always there.
|
|
1776
|
-
yAxisId={vertical ? gridAxis : (ref.axis ?? DEFAULT_Y_AXIS)}
|
|
1777
|
-
{...(vertical ? { x: at } : { y: at })}
|
|
1778
|
-
stroke={color}
|
|
1779
|
-
strokeWidth={1}
|
|
1780
|
-
strokeDasharray={strokeDash(ref.dash ?? 1)}
|
|
1781
|
-
ifOverflow="discard"
|
|
1782
|
-
label={
|
|
1783
|
-
ref.label
|
|
1784
|
-
? {
|
|
1785
|
-
value: ref.label,
|
|
1786
|
-
position: "insideTopLeft",
|
|
1787
|
-
fontSize: REFERENCE_LABEL_SIZE * scale,
|
|
1788
|
-
fill: color,
|
|
1789
|
-
}
|
|
1790
|
-
: undefined
|
|
1791
|
-
}
|
|
1792
|
-
/>
|
|
1793
|
-
);
|
|
1794
|
-
})}
|
|
1795
|
-
{markers?.map((marker, index) => {
|
|
1796
|
-
const at = xPos(marker.x);
|
|
1797
|
-
if (at === undefined || finite(marker.y) === undefined) return null;
|
|
1798
|
-
const color = marker.color ?? TONE_COLOR[marker.tone ?? "brand"];
|
|
1799
|
-
return (
|
|
1800
|
-
<ReferenceDot
|
|
1801
|
-
key={marker.key ?? `marker-${index}`}
|
|
1802
|
-
yAxisId={marker.axis ?? DEFAULT_Y_AXIS}
|
|
1803
|
-
x={at}
|
|
1804
|
-
y={marker.y}
|
|
1805
|
-
r={marker.r ?? 4.5}
|
|
1806
|
-
fill={color}
|
|
1807
|
-
stroke="var(--bg-surface)"
|
|
1808
|
-
strokeWidth={1.5}
|
|
1809
|
-
ifOverflow="discard"
|
|
1810
|
-
label={marker.label ? { value: marker.label, position: "top", content: <MarkerLabel /> } : undefined}
|
|
1811
|
-
/>
|
|
1812
|
-
);
|
|
1813
|
-
})}
|
|
1814
|
-
{stops.length > 0 && (
|
|
1815
|
-
<PointKeys
|
|
1816
|
-
stops={stops}
|
|
1817
|
-
current={Math.min(keyStop, stops.length - 1)}
|
|
1818
|
-
label={labels.points}
|
|
1819
|
-
onFocusStop={(at) => {
|
|
1820
|
-
setKeyStop(at);
|
|
1821
|
-
setKeyFocus(at);
|
|
1822
|
-
}}
|
|
1823
|
-
onBlurStops={() => setKeyFocus(undefined)}
|
|
1824
|
-
onPick={
|
|
1825
|
-
onPointClick
|
|
1826
|
-
? (stop) => {
|
|
1827
|
-
const hit = hitAt(stop.index, stop.key);
|
|
1828
|
-
if (hit) onPointClick(hit);
|
|
1829
|
-
}
|
|
1830
|
-
: undefined
|
|
1831
|
-
}
|
|
1832
|
-
/>
|
|
1833
|
-
)}
|
|
1834
|
-
{zoom?.layer}
|
|
1835
|
-
</ComposedChart>
|
|
1836
|
-
</ChartContainer>
|
|
1837
|
-
);
|
|
1838
|
-
if (!inRow) return chart;
|
|
1839
|
-
// The row's own box, reserved from the first render: its idle state has the cells the
|
|
1840
|
-
// active one will, so the first tap fills it in rather than pushing the plot down.
|
|
1841
|
-
const row = (
|
|
1842
|
-
<div
|
|
1843
|
-
ref={setReadout}
|
|
1844
|
-
data-tooltip-readout={placement}
|
|
1845
|
-
className={cn(
|
|
1846
|
-
"shrink-0",
|
|
1847
|
-
// Above, the heading line shares the top corner with the zoom's reset button.
|
|
1848
|
-
placement === "above" ? "pb-2 [&_[data-readout-heading]]:pe-32" : "pt-2",
|
|
1849
|
-
)}
|
|
1850
|
-
/>
|
|
1851
|
-
);
|
|
1852
|
-
return (
|
|
1853
|
-
<div {...figure} className={cn("flex w-full flex-col", heightClass)} style={heightStyle}>
|
|
1854
|
-
{placement === "above" && row}
|
|
1855
|
-
{chart}
|
|
1856
|
-
{placement === "below" && row}
|
|
1857
|
-
{about.node}
|
|
1858
|
-
</div>
|
|
1859
|
-
);
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
const ZoomablePlot = withChartZoom(SeriesPlot);
|
|
1863
|
-
|
|
1864
|
-
/**
|
|
1865
|
-
* The caller's props, with the abscissa reduced to numbers for the plot and the zoom.
|
|
1866
|
-
* The reduction is kept while the rows and the two settings it reads stay the same — a
|
|
1867
|
-
* category or time chart otherwise re-maps every row on every render, and `maxRows`'
|
|
1868
|
-
* envelope would be worked out again with it.
|
|
1869
|
-
*/
|
|
1870
|
-
function usePlotProps<TRow extends object>(typed: SeriesChartProps<TRow>): PlotProps {
|
|
1871
|
-
// `TRow` types only what the caller is handed back, and that is its own row objects,
|
|
1872
|
-
// untouched (0.53): the plot reads them as the `object` rows they are. Through `unknown`
|
|
1873
|
-
// because the two are not comparable for an unresolved `TRow`: `SeriesChartSeries` is
|
|
1874
|
-
// contravariant in it (its `dot` is handed rows) and `rows` covariant.
|
|
1875
|
-
const props = typed as unknown as SeriesChartProps;
|
|
1876
|
-
const x = props.x ?? {};
|
|
1877
|
-
const { rows } = props;
|
|
1878
|
-
const { type, key } = x;
|
|
1879
|
-
// Read by key, so any object is a row (API-2); `SeriesChartRow` is how the plot reads it.
|
|
1880
|
-
const model = useMemo(() => xModel(rows as readonly SeriesChartRow[], { type, key }), [rows, type, key]);
|
|
1881
|
-
return { ...props, rows: model.rows, x: { key: model.plotKey }, model, xAxis: x };
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
/**
|
|
1885
|
-
* {@link SeriesChart} without the zoom: the same picture, no drag layer, no reset
|
|
1886
|
-
* button. For a thumbnail, a print view, or a chart the consumer wraps in its own
|
|
1887
|
-
* interaction.
|
|
1888
|
-
*/
|
|
1889
|
-
export function StaticSeriesChart<TRow extends object = object>(props: SeriesChartProps<TRow>) {
|
|
1890
|
-
return <SeriesPlot {...usePlotProps(props)} />;
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
/**
|
|
1894
|
-
* The series chart, zoomable. Drag across the plot to zoom (the drag's shape picks the
|
|
1895
|
-
* axes), double-click or press the reset button to go back; wrap several in
|
|
1896
|
-
* `SharedXZoom` to move their x windows together. Which axes zoom depends on the marks
|
|
1897
|
-
* — see {@link SeriesChartProps.zoomAxes}.
|
|
1898
|
-
*
|
|
1899
|
-
* Generic in its rows (0.53): `hit.row` and a `dot`'s `point.row` are typed as `rows` is —
|
|
1900
|
-
* see {@link SeriesChartProps}. A plain function, so the generic survives: a `memo` or a
|
|
1901
|
-
* `forwardRef` around it would read `TRow` as its constraint.
|
|
1902
|
-
*/
|
|
1903
|
-
export function SeriesChart<TRow extends object = object>(props: SeriesChartProps<TRow>) {
|
|
1904
|
-
// The zoom fits the PLOTTED rows — slot indices and epoch ms, not the caller's labels.
|
|
1905
|
-
return <ZoomablePlot {...usePlotProps(props)} />;
|
|
1906
|
-
}
|