glacia-native 0.5.2 → 0.6.1
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 +84 -17
- package/lib/module/Accordion.js +58 -0
- package/lib/module/ActionSheet.js +38 -0
- package/lib/module/Alert.js +23 -0
- package/lib/module/AlertDialog.js +47 -0
- package/lib/module/Avatar.js +48 -0
- package/lib/module/Badge.js +36 -0
- package/lib/module/Bars.js +13 -268
- package/lib/module/Button.js +57 -39
- package/lib/module/Card.js +31 -19
- package/lib/module/Checkbox.js +42 -0
- package/lib/module/Chip.js +80 -0
- package/lib/module/Collapsible.js +26 -0
- package/lib/module/ContextMenu.js +33 -0
- package/lib/module/Dialog.js +39 -123
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +10 -3
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +43 -38
- package/lib/module/Label.js +17 -0
- package/lib/module/MorphGroup.js +47 -0
- package/lib/module/Popover.js +29 -0
- package/lib/module/Progress.js +32 -0
- package/lib/module/RadioGroup.js +51 -0
- package/lib/module/Scrim.js +44 -0
- package/lib/module/SegmentedControl.js +70 -63
- package/lib/module/Select.js +51 -0
- package/lib/module/Separator.js +25 -0
- package/lib/module/Sheet.js +51 -0
- package/lib/module/Skeleton.js +48 -0
- package/lib/module/Slider.js +45 -34
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -55
- package/lib/module/TabBar.js +50 -44
- package/lib/module/Textarea.js +18 -0
- package/lib/module/Toast.js +55 -0
- package/lib/module/Toggle.js +47 -0
- package/lib/module/ToggleGroup.js +56 -0
- package/lib/module/Toolbar.js +37 -0
- package/lib/module/Tooltip.js +31 -0
- package/lib/module/glass-provider.js +28 -0
- package/lib/module/glass-stack.js +61 -0
- package/lib/module/index.js +78 -109
- package/lib/module/internal/GlassBackdrop.js +36 -0
- package/lib/module/internal/GlassView.js +43 -11
- package/lib/module/internal/blur-community.js +20 -0
- package/lib/module/internal/blur-community.web.js +9 -0
- package/lib/module/internal/blur.js +6 -9
- package/lib/module/internal/glass-routing.js +156 -30
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +16 -0
- package/lib/typescript/Accordion.d.ts +22 -0
- package/lib/typescript/ActionSheet.d.ts +24 -0
- package/lib/typescript/Alert.d.ts +15 -0
- package/lib/typescript/AlertDialog.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts +22 -0
- package/lib/typescript/Badge.d.ts +12 -0
- package/lib/typescript/Bars.d.ts +3 -188
- package/lib/typescript/Button.d.ts +44 -10
- package/lib/typescript/Card.d.ts +30 -3
- package/lib/typescript/Checkbox.d.ts +14 -0
- package/lib/typescript/Chip.d.ts +19 -0
- package/lib/typescript/Collapsible.d.ts +17 -0
- package/lib/typescript/ContextMenu.d.ts +23 -0
- package/lib/typescript/Dialog.d.ts +8 -68
- package/lib/typescript/DropdownMenu.d.ts +23 -0
- package/lib/typescript/Field.d.ts +19 -0
- package/lib/typescript/Glass.d.ts +11 -2
- package/lib/typescript/Group.d.ts +35 -0
- package/lib/typescript/IconButton.d.ts +21 -0
- package/lib/typescript/Input.d.ts +17 -18
- package/lib/typescript/Label.d.ts +14 -0
- package/lib/typescript/MorphGroup.d.ts +46 -0
- package/lib/typescript/Popover.d.ts +17 -0
- package/lib/typescript/Progress.d.ts +13 -0
- package/lib/typescript/RadioGroup.d.ts +21 -0
- package/lib/typescript/Scrim.d.ts +33 -0
- package/lib/typescript/SegmentedControl.d.ts +24 -13
- package/lib/typescript/Select.d.ts +19 -0
- package/lib/typescript/Separator.d.ts +10 -0
- package/lib/typescript/Sheet.d.ts +45 -0
- package/lib/typescript/Skeleton.d.ts +10 -0
- package/lib/typescript/Slider.d.ts +15 -7
- package/lib/typescript/Stepper.d.ts +49 -0
- package/lib/typescript/Switch.d.ts +19 -12
- package/lib/typescript/TabBar.d.ts +18 -6
- package/lib/typescript/Textarea.d.ts +6 -0
- package/lib/typescript/Toast.d.ts +40 -0
- package/lib/typescript/Toggle.d.ts +21 -0
- package/lib/typescript/ToggleGroup.d.ts +22 -0
- package/lib/typescript/Toolbar.d.ts +35 -0
- package/lib/typescript/Tooltip.d.ts +16 -0
- package/lib/typescript/glass-provider.d.ts +34 -0
- package/lib/typescript/glass-stack.d.ts +54 -0
- package/lib/typescript/index.d.ts +38 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +18 -2
- package/lib/typescript/internal/blur-community.d.ts +2 -0
- package/lib/typescript/internal/blur-community.web.d.ts +2 -0
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +11 -0
- package/package.json +12 -10
- package/src/Accordion.tsx +165 -0
- package/src/ActionSheet.tsx +149 -0
- package/src/Alert.tsx +85 -0
- package/src/AlertDialog.tsx +124 -0
- package/src/Avatar.tsx +102 -0
- package/src/Badge.tsx +80 -0
- package/src/Bars.tsx +10 -807
- package/src/Button.tsx +196 -67
- package/src/Card.tsx +105 -32
- package/src/Checkbox.tsx +98 -0
- package/src/Chip.tsx +149 -0
- package/src/Collapsible.tsx +66 -0
- package/src/ContextMenu.tsx +103 -0
- package/src/Dialog.tsx +85 -335
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +15 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +139 -87
- package/src/Label.tsx +56 -0
- package/src/MorphGroup.tsx +134 -0
- package/src/Popover.tsx +81 -0
- package/src/Progress.tsx +83 -0
- package/src/RadioGroup.tsx +122 -0
- package/src/Scrim.tsx +94 -0
- package/src/SegmentedControl.tsx +132 -99
- package/src/Select.tsx +136 -0
- package/src/Separator.tsx +52 -0
- package/src/Sheet.tsx +139 -0
- package/src/Skeleton.tsx +77 -0
- package/src/Slider.tsx +84 -47
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +81 -73
- package/src/TabBar.tsx +106 -93
- package/src/Textarea.tsx +34 -0
- package/src/Toast.tsx +131 -0
- package/src/Toggle.tsx +113 -0
- package/src/ToggleGroup.tsx +129 -0
- package/src/Toolbar.tsx +111 -0
- package/src/Tooltip.tsx +79 -0
- package/src/engine/CHANGELOG.md +430 -0
- package/src/engine/NOTICE +54 -0
- package/src/engine/README.md +975 -0
- package/src/engine/android/build.gradle +18 -0
- package/src/engine/android/src/main/AndroidManifest.xml +2 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
- package/src/engine/index.ts +24 -0
- package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
- package/src/engine/ios/Enums/GlassVariant.swift +86 -0
- package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
- package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
- package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
- package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
- package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
- package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
- package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
- package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
- package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
- package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
- package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
- package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
- package/src/engine/ios/Glass/StripCache.swift +545 -0
- package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
- package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
- package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
- package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
- package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
- package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
- package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
- package/src/engine/package.json +70 -0
- package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
- package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
- package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
- package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
- package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
- package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
- package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
- package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
- package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
- package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
- package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
- package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
- package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
- package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
- package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
- package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
- package/src/engine/src/components/index.ts +16 -0
- package/src/engine/src/constants/index.ts +4 -0
- package/src/engine/src/constants/metal.constants.ts +327 -0
- package/src/engine/src/constants/metrics.constants.ts +325 -0
- package/src/engine/src/constants/springs.constants.ts +107 -0
- package/src/engine/src/constants/styles.constants.ts +12 -0
- package/src/engine/src/context/glass-group.context.ts +65 -0
- package/src/engine/src/context/index.ts +6 -0
- package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
- package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
- package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
- package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
- package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
- package/src/engine/src/core/components/index.ts +4 -0
- package/src/engine/src/core/constants/glass.constants.ts +57 -0
- package/src/engine/src/core/constants/index.ts +20 -0
- package/src/engine/src/core/constants/native.constants.ts +16 -0
- package/src/engine/src/core/context/glass-stack.context.ts +30 -0
- package/src/engine/src/core/context/index.ts +4 -0
- package/src/engine/src/core/enum/index.ts +12 -0
- package/src/engine/src/core/index.ts +1 -0
- package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
- package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
- package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
- package/src/engine/src/core/interfaces/index.ts +31 -0
- package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
- package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
- package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
- package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
- package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
- package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
- package/src/engine/src/core/modules/index.ts +2 -0
- package/src/engine/src/core/root/index.ts +51 -0
- package/src/engine/src/core/types/glass.types.ts +25 -0
- package/src/engine/src/core/types/index.ts +8 -0
- package/src/engine/src/core/utils/debug.utils.ts +17 -0
- package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
- package/src/engine/src/core/utils/hdr.utils.ts +37 -0
- package/src/engine/src/core/utils/index.ts +5 -0
- package/src/engine/src/core/utils/native-view.utils.ts +33 -0
- package/src/engine/src/core/utils/platform.utils.ts +34 -0
- package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
- package/src/engine/src/core/views/index.ts +4 -0
- package/src/engine/src/hooks/index.ts +18 -0
- package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
- package/src/engine/src/hooks/use-damped-drag.ts +332 -0
- package/src/engine/src/hooks/use-echo-filter.ts +55 -0
- package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
- package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
- package/src/engine/src/hooks/use-press-progress.ts +44 -0
- package/src/engine/src/index.ts +120 -0
- package/src/engine/src/interfaces/index.ts +28 -0
- package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
- package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
- package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
- package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
- package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
- package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
- package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
- package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
- package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
- package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
- package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
- package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
- package/src/engine/src/theme/glass-ui-theme.ts +100 -0
- package/src/engine/src/theme/index.ts +2 -0
- package/src/engine/src/utils/button-press.utils.ts +63 -0
- package/src/engine/src/utils/index.ts +3 -0
- package/src/engine/src/utils/metal.utils.ts +164 -0
- package/src/glass-provider.tsx +60 -0
- package/src/glass-stack.tsx +115 -0
- package/src/index.ts +47 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +53 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +7 -8
- package/src/internal/glass-routing.ts +212 -34
- package/src/internal/initials.ts +7 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +23 -0
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -318
- package/lib/module/Feedback.js +0 -395
- package/lib/module/Form.js +0 -160
- package/lib/module/Forms2.js +0 -471
- package/lib/module/Message.js +0 -84
- package/lib/module/Overlays.js +0 -344
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -100
- package/lib/module/ai.js +0 -283
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -75
- package/lib/module/charts/FunnelChart.js +0 -50
- package/lib/module/charts/HeatmapChart.js +0 -71
- package/lib/module/charts/LineChart.js +0 -81
- package/lib/module/charts/PlotChart.js +0 -52
- package/lib/module/charts/RadarChart.js +0 -78
- package/lib/module/charts/RingChart.js +0 -52
- package/lib/module/charts/ScatterChart.js +0 -95
- package/lib/module/charts/WaterfallChart.js +0 -85
- package/lib/module/charts/advanced.js +0 -313
- package/lib/module/charts/extra.js +0 -108
- package/lib/module/charts/index.js +0 -50
- package/lib/module/charts/scales.js +0 -140
- package/lib/typescript/Carousel.d.ts +0 -47
- package/lib/typescript/Display.d.ts +0 -178
- package/lib/typescript/Feedback.d.ts +0 -196
- package/lib/typescript/Form.d.ts +0 -97
- package/lib/typescript/Forms2.d.ts +0 -209
- package/lib/typescript/Message.d.ts +0 -67
- package/lib/typescript/Overlays.d.ts +0 -146
- package/lib/typescript/Pickers.d.ts +0 -105
- package/lib/typescript/Table.d.ts +0 -64
- package/lib/typescript/ai.d.ts +0 -166
- package/lib/typescript/charts/AreaChart.d.ts +0 -44
- package/lib/typescript/charts/BarChart.d.ts +0 -19
- package/lib/typescript/charts/FunnelChart.d.ts +0 -25
- package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
- package/lib/typescript/charts/LineChart.d.ts +0 -30
- package/lib/typescript/charts/PlotChart.d.ts +0 -31
- package/lib/typescript/charts/RadarChart.d.ts +0 -27
- package/lib/typescript/charts/RingChart.d.ts +0 -28
- package/lib/typescript/charts/ScatterChart.d.ts +0 -34
- package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
- package/lib/typescript/charts/advanced.d.ts +0 -107
- package/lib/typescript/charts/extra.d.ts +0 -63
- package/lib/typescript/charts/index.d.ts +0 -13
- package/lib/typescript/charts/scales.d.ts +0 -35
- package/src/Carousel.tsx +0 -233
- package/src/Display.tsx +0 -781
- package/src/Feedback.tsx +0 -992
- package/src/Form.tsx +0 -445
- package/src/Forms2.tsx +0 -1055
- package/src/Message.tsx +0 -218
- package/src/Overlays.tsx +0 -704
- package/src/Pickers.tsx +0 -595
- package/src/Table.tsx +0 -232
- package/src/ai.tsx +0 -715
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -221
- package/src/charts/FunnelChart.tsx +0 -125
- package/src/charts/HeatmapChart.tsx +0 -155
- package/src/charts/LineChart.tsx +0 -247
- package/src/charts/PlotChart.tsx +0 -168
- package/src/charts/RadarChart.tsx +0 -208
- package/src/charts/RingChart.tsx +0 -133
- package/src/charts/ScatterChart.tsx +0 -223
- package/src/charts/WaterfallChart.tsx +0 -201
- package/src/charts/advanced.tsx +0 -676
- package/src/charts/extra.tsx +0 -242
- package/src/charts/index.ts +0 -86
- package/src/charts/scales.ts +0 -163
package/src/charts/extra.tsx
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { colors } from "../internal/tokens";
|
|
4
|
-
import { useIsDark } from "../internal/motion";
|
|
5
|
-
import { primitives } from "../internal/primitives";
|
|
6
|
-
import { NativeLineChart, type NativeLineSeries } from "./LineChart";
|
|
7
|
-
import { formatValue, seriesColor } from "./scales";
|
|
8
|
-
|
|
9
|
-
export interface NativePolarSegment {
|
|
10
|
-
label: string;
|
|
11
|
-
value: number;
|
|
12
|
-
color?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface NativePolarAreaChartProps {
|
|
16
|
-
segments: NativePolarSegment[];
|
|
17
|
-
size?: number;
|
|
18
|
-
/** Value mapped to the full radius. Defaults to the largest segment. */
|
|
19
|
-
max?: number;
|
|
20
|
-
isDark?: boolean;
|
|
21
|
-
palette?: readonly string[];
|
|
22
|
-
style?: any;
|
|
23
|
-
onSegmentPress?: (index: number) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const TAU = Math.PI * 2;
|
|
27
|
-
|
|
28
|
-
/** Point on a circle at `angle` radians, measured from 12 o'clock. */
|
|
29
|
-
function polar(angle: number, radius: number, cx: number, cy: number) {
|
|
30
|
-
return { x: cx + Math.sin(angle) * radius, y: cy - Math.cos(angle) * radius };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Equal-angle wedges whose radius encodes value.
|
|
35
|
-
*
|
|
36
|
-
* Unlike a pie chart, every wedge uses the same angle, so the reader compares
|
|
37
|
-
* one dimension (radius) rather than area. Each wedge is separately tappable
|
|
38
|
-
* because a phone has no hover.
|
|
39
|
-
*/
|
|
40
|
-
export function NativePolarAreaChart({
|
|
41
|
-
segments,
|
|
42
|
-
size = 240,
|
|
43
|
-
max,
|
|
44
|
-
isDark: isDarkProp,
|
|
45
|
-
palette,
|
|
46
|
-
style,
|
|
47
|
-
onSegmentPress,
|
|
48
|
-
}: NativePolarAreaChartProps) {
|
|
49
|
-
const [active, setActive] = useState<number | null>(null);
|
|
50
|
-
const isDark = useIsDark(isDarkProp);
|
|
51
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
52
|
-
const { View, Text, Pressable, Svg, G, Path, Circle } = primitives();
|
|
53
|
-
|
|
54
|
-
if (segments.length === 0) {
|
|
55
|
-
return (
|
|
56
|
-
<View style={[{ width: size, alignItems: "center", paddingVertical: 20 }, style]}>
|
|
57
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No segments to display</Text>
|
|
58
|
-
</View>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const centre = size / 2;
|
|
63
|
-
const outer = centre - 8;
|
|
64
|
-
const highest = Math.max(...segments.map((segment) => segment.value));
|
|
65
|
-
const scaleMax = max ?? (highest || 1);
|
|
66
|
-
const step = TAU / segments.length;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<View style={[{ width: size }, style]}>
|
|
70
|
-
<Svg width={size} height={size}>
|
|
71
|
-
{segments.map((segment, index) => {
|
|
72
|
-
const ratio = Math.max(0.04, Math.min(1, segment.value / scaleMax));
|
|
73
|
-
const radius = outer * ratio;
|
|
74
|
-
const start = index * step - step / 2;
|
|
75
|
-
const end = start + step;
|
|
76
|
-
const from = polar(start, radius, centre, centre);
|
|
77
|
-
const to = polar(end, radius, centre, centre);
|
|
78
|
-
const color = segment.color ?? seriesColor(index, palette);
|
|
79
|
-
|
|
80
|
-
// Large-arc is always 0 here: a wedge never exceeds half the circle.
|
|
81
|
-
const path = [
|
|
82
|
-
`M ${centre} ${centre}`,
|
|
83
|
-
`L ${from.x} ${from.y}`,
|
|
84
|
-
`A ${radius} ${radius} 0 0 1 ${to.x} ${to.y}`,
|
|
85
|
-
"Z",
|
|
86
|
-
].join(" ");
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<Path
|
|
90
|
-
key={segment.label}
|
|
91
|
-
d={path}
|
|
92
|
-
fill={color}
|
|
93
|
-
fillOpacity={active === null || active === index ? 0.85 : 0.4}
|
|
94
|
-
stroke={theme.edge}
|
|
95
|
-
strokeWidth={1}
|
|
96
|
-
onPress={() => {
|
|
97
|
-
setActive((current) => (current === index ? null : index));
|
|
98
|
-
onSegmentPress?.(index);
|
|
99
|
-
}}
|
|
100
|
-
/>
|
|
101
|
-
);
|
|
102
|
-
})}
|
|
103
|
-
<Circle cx={centre} cy={centre} r={outer * 0.18} fill={theme.glass} />
|
|
104
|
-
</Svg>
|
|
105
|
-
|
|
106
|
-
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8, marginTop: 8 }}>
|
|
107
|
-
{segments.map((segment, index) => (
|
|
108
|
-
<Pressable
|
|
109
|
-
key={segment.label}
|
|
110
|
-
accessibilityRole="button"
|
|
111
|
-
accessibilityLabel={`${segment.label}: ${formatValue(segment.value)}`}
|
|
112
|
-
onPress={() => {
|
|
113
|
-
setActive((current) => (current === index ? null : index));
|
|
114
|
-
onSegmentPress?.(index);
|
|
115
|
-
}}
|
|
116
|
-
style={{ flexDirection: "row", alignItems: "center", gap: 4 }}
|
|
117
|
-
>
|
|
118
|
-
<View
|
|
119
|
-
style={{
|
|
120
|
-
width: 8,
|
|
121
|
-
height: 8,
|
|
122
|
-
borderRadius: 4,
|
|
123
|
-
backgroundColor: segment.color ?? seriesColor(index, palette),
|
|
124
|
-
}}
|
|
125
|
-
/>
|
|
126
|
-
<Text style={{ fontSize: 10, color: theme.muted }}>{segment.label}</Text>
|
|
127
|
-
</Pressable>
|
|
128
|
-
))}
|
|
129
|
-
</View>
|
|
130
|
-
</View>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface NativePyramidLevel {
|
|
135
|
-
label: string;
|
|
136
|
-
value: number;
|
|
137
|
-
color?: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface NativePyramidChartProps {
|
|
141
|
-
levels: NativePyramidLevel[];
|
|
142
|
-
/** Height of each level band. */
|
|
143
|
-
levelHeight?: number;
|
|
144
|
-
width?: number;
|
|
145
|
-
isDark?: boolean;
|
|
146
|
-
palette?: readonly string[];
|
|
147
|
-
style?: any;
|
|
148
|
-
onLevelPress?: (index: number) => void;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Stacked bands that narrow toward the top.
|
|
153
|
-
*
|
|
154
|
-
* Bands are Views rather than SVG: each is a centred rectangle whose width is
|
|
155
|
-
* the band's share of the widest level, which native layout computes exactly.
|
|
156
|
-
*/
|
|
157
|
-
export function NativePyramidChart({
|
|
158
|
-
levels,
|
|
159
|
-
levelHeight = 34,
|
|
160
|
-
width = 320,
|
|
161
|
-
isDark: isDarkProp,
|
|
162
|
-
palette,
|
|
163
|
-
style,
|
|
164
|
-
onLevelPress,
|
|
165
|
-
}: NativePyramidChartProps) {
|
|
166
|
-
const [active, setActive] = useState<number | null>(null);
|
|
167
|
-
const isDark = useIsDark(isDarkProp);
|
|
168
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
169
|
-
const { View, Text, Pressable } = primitives();
|
|
170
|
-
|
|
171
|
-
if (levels.length === 0) {
|
|
172
|
-
return (
|
|
173
|
-
<View style={[{ width, alignItems: "center", paddingVertical: 20 }, style]}>
|
|
174
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No levels to display</Text>
|
|
175
|
-
</View>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const widest = Math.max(...levels.map((level) => level.value)) || 1;
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<View style={[{ width }, style]}>
|
|
183
|
-
{levels.map((level, index) => {
|
|
184
|
-
const share = Math.max(0.06, level.value / widest);
|
|
185
|
-
const color = level.color ?? seriesColor(index, palette);
|
|
186
|
-
|
|
187
|
-
return (
|
|
188
|
-
<Pressable
|
|
189
|
-
key={level.label}
|
|
190
|
-
accessibilityRole="button"
|
|
191
|
-
accessibilityLabel={`${level.label}: ${formatValue(level.value)}`}
|
|
192
|
-
onPress={() => {
|
|
193
|
-
setActive((current) => (current === index ? null : index));
|
|
194
|
-
onLevelPress?.(index);
|
|
195
|
-
}}
|
|
196
|
-
style={{ alignItems: "center", marginBottom: 2 }}
|
|
197
|
-
>
|
|
198
|
-
<View
|
|
199
|
-
style={{
|
|
200
|
-
width: `${share * 100}%`,
|
|
201
|
-
height: levelHeight,
|
|
202
|
-
borderRadius: 4,
|
|
203
|
-
backgroundColor: color,
|
|
204
|
-
opacity: active === null || active === index ? 1 : 0.45,
|
|
205
|
-
alignItems: "center",
|
|
206
|
-
justifyContent: "center",
|
|
207
|
-
}}
|
|
208
|
-
>
|
|
209
|
-
<Text
|
|
210
|
-
style={{ fontSize: 10, fontWeight: "600", color: "#fff" }}
|
|
211
|
-
numberOfLines={1}
|
|
212
|
-
>
|
|
213
|
-
{level.label} · {formatValue(level.value, { compact: true })}
|
|
214
|
-
</Text>
|
|
215
|
-
</View>
|
|
216
|
-
</Pressable>
|
|
217
|
-
);
|
|
218
|
-
})}
|
|
219
|
-
</View>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export interface NativeLiveLineChartProps {
|
|
224
|
-
labels: string[];
|
|
225
|
-
series: NativeLineSeries[];
|
|
226
|
-
width?: number;
|
|
227
|
-
height?: number;
|
|
228
|
-
isDark?: boolean;
|
|
229
|
-
palette?: readonly string[];
|
|
230
|
-
style?: any;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* A line chart that keeps only the most recent window of points.
|
|
235
|
-
*
|
|
236
|
-
* The caller pushes new values; this trims to `labels.length` so the window
|
|
237
|
-
* slides instead of growing without bound. Pausing is the caller's decision —
|
|
238
|
-
* a chart that stops itself would hide data the user expects to see arrive.
|
|
239
|
-
*/
|
|
240
|
-
export function NativeLiveLineChart(props: NativeLiveLineChartProps) {
|
|
241
|
-
return <NativeLineChart {...props} smooth={false} showDots={false} />;
|
|
242
|
-
}
|
package/src/charts/index.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// Native charts, drawn with react-native-svg.
|
|
2
|
-
//
|
|
3
|
-
// These share their scale maths and colour ramp with the web package, so the
|
|
4
|
-
// same series produces the same axis values on both platforms. Touch replaces
|
|
5
|
-
// hover: tapping a bar, point or slice selects it.
|
|
6
|
-
|
|
7
|
-
export { NativeLineChart, type NativeLineChartProps, type NativeLineSeries } from "./LineChart";
|
|
8
|
-
export { NativeBarChart, type NativeBarChartProps, type NativeBarSeries } from "./BarChart";
|
|
9
|
-
export { NativeRingChart, type NativeRingChartProps, type NativeRingSlice } from "./RingChart";
|
|
10
|
-
export {
|
|
11
|
-
NativeAreaChart,
|
|
12
|
-
NativeMirrorAreaChart,
|
|
13
|
-
type NativeAreaChartProps,
|
|
14
|
-
type NativeMirrorAreaChartProps,
|
|
15
|
-
type NativeMirrorAreaSeries,
|
|
16
|
-
} from "./AreaChart";
|
|
17
|
-
export {
|
|
18
|
-
NativeScatterChart,
|
|
19
|
-
NativeBubbleChart,
|
|
20
|
-
type NativeScatterChartProps,
|
|
21
|
-
type NativeScatterSeries,
|
|
22
|
-
type NativeScatterPoint,
|
|
23
|
-
} from "./ScatterChart";
|
|
24
|
-
export {
|
|
25
|
-
NativeFunnelChart,
|
|
26
|
-
type NativeFunnelChartProps,
|
|
27
|
-
type NativeFunnelStage,
|
|
28
|
-
} from "./FunnelChart";
|
|
29
|
-
export { NativeHeatmapChart, type NativeHeatmapChartProps } from "./HeatmapChart";
|
|
30
|
-
export {
|
|
31
|
-
NativeRadarChart,
|
|
32
|
-
type NativeRadarChartProps,
|
|
33
|
-
type NativeRadarSeries,
|
|
34
|
-
} from "./RadarChart";
|
|
35
|
-
export {
|
|
36
|
-
NativeWaterfallChart,
|
|
37
|
-
type NativeWaterfallChartProps,
|
|
38
|
-
type NativeWaterfallStep,
|
|
39
|
-
} from "./WaterfallChart";
|
|
40
|
-
export {
|
|
41
|
-
linearScale,
|
|
42
|
-
niceDomain,
|
|
43
|
-
ticks,
|
|
44
|
-
bandScale,
|
|
45
|
-
smoothPath,
|
|
46
|
-
arcPath,
|
|
47
|
-
formatValue,
|
|
48
|
-
seriesColor,
|
|
49
|
-
SERIES_COLORS,
|
|
50
|
-
type Scale,
|
|
51
|
-
} from "./scales";
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
NativePolarAreaChart,
|
|
55
|
-
NativePyramidChart,
|
|
56
|
-
NativeLiveLineChart,
|
|
57
|
-
type NativePolarAreaChartProps,
|
|
58
|
-
type NativePolarSegment,
|
|
59
|
-
type NativePyramidChartProps,
|
|
60
|
-
type NativePyramidLevel,
|
|
61
|
-
type NativeLiveLineChartProps,
|
|
62
|
-
} from "./extra";
|
|
63
|
-
export {
|
|
64
|
-
NativeCandlestickChart,
|
|
65
|
-
NativeTreemapChart,
|
|
66
|
-
NativeSankeyChart,
|
|
67
|
-
NativeBumpChart,
|
|
68
|
-
NativeHexChart,
|
|
69
|
-
type NativeCandlestickChartProps,
|
|
70
|
-
type NativeCandle,
|
|
71
|
-
type NativeTreemapChartProps,
|
|
72
|
-
type NativeTreemapItem,
|
|
73
|
-
type NativeSankeyChartProps,
|
|
74
|
-
type NativeSankeyNode,
|
|
75
|
-
type NativeSankeyLink,
|
|
76
|
-
type NativeBumpChartProps,
|
|
77
|
-
type NativeBumpSeries,
|
|
78
|
-
type NativeHexChartProps,
|
|
79
|
-
type NativeHexPoint,
|
|
80
|
-
} from "./advanced";
|
|
81
|
-
export {
|
|
82
|
-
NativePlotChart,
|
|
83
|
-
type NativePlotChartProps,
|
|
84
|
-
type NativePlotPoint,
|
|
85
|
-
type NativePlotRenderArgs,
|
|
86
|
-
} from "./PlotChart";
|
package/src/charts/scales.ts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// Native chart scales.
|
|
2
|
-
//
|
|
3
|
-
// This mirrors the web package's chart maths so a series drawn on a phone and
|
|
4
|
-
// the same series drawn in a browser land on the same axis values. It is
|
|
5
|
-
// deliberately duplicated rather than imported from `glacia`: glacia-native is
|
|
6
|
-
// a standalone package with no dependency on the web build.
|
|
7
|
-
|
|
8
|
-
/** Maps a value into pixel space along one axis. */
|
|
9
|
-
export interface Scale {
|
|
10
|
-
(value: number): number;
|
|
11
|
-
invert(pixel: number): number;
|
|
12
|
-
domain: [number, number];
|
|
13
|
-
range: [number, number];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function linearScale(
|
|
17
|
-
domain: [number, number],
|
|
18
|
-
range: [number, number],
|
|
19
|
-
options: { nice?: boolean; ticks?: number } = {},
|
|
20
|
-
): Scale {
|
|
21
|
-
let [d0, d1] = domain;
|
|
22
|
-
if (d0 === d1) {
|
|
23
|
-
d0 = d0 === 0 ? 0 : d0 * 0.9;
|
|
24
|
-
d1 = d1 === 0 ? 1 : d1 * 1.1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const base: [number, number] =
|
|
28
|
-
options.nice === false ? [d0, d1] : niceDomain(d0, d1, options.ticks ?? 5);
|
|
29
|
-
const [a, b] = base;
|
|
30
|
-
const [r0, r1] = range;
|
|
31
|
-
const span = b - a || 1;
|
|
32
|
-
|
|
33
|
-
const scale = ((value: number) => r0 + ((value - a) / span) * (r1 - r0)) as Scale;
|
|
34
|
-
scale.invert = (pixel: number) => a + ((pixel - r0) / (r1 - r0)) * span;
|
|
35
|
-
scale.domain = [a, b];
|
|
36
|
-
scale.range = range;
|
|
37
|
-
return scale;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Rounds a domain outward to values that read cleanly on an axis. */
|
|
41
|
-
export function niceDomain(min: number, max: number, tickCount = 5): [number, number] {
|
|
42
|
-
if (min === max) return [min === 0 ? 0 : min * 0.9, max === 0 ? 1 : max * 1.1];
|
|
43
|
-
const span = max - min;
|
|
44
|
-
const step = Math.pow(10, Math.floor(Math.log10(span / tickCount)));
|
|
45
|
-
const error = span / tickCount / step;
|
|
46
|
-
const factor = error >= 7.5 ? 10 : error >= 3.5 ? 5 : error >= 1.5 ? 2 : 1;
|
|
47
|
-
const niceStep = step * factor;
|
|
48
|
-
return [Math.floor(min / niceStep) * niceStep, Math.ceil(max / niceStep) * niceStep];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function ticks(domain: [number, number], count = 4): number[] {
|
|
52
|
-
const [d0, d1] = domain;
|
|
53
|
-
if (d0 === d1) return [d0];
|
|
54
|
-
return Array.from({ length: count + 1 }, (_, i) => d0 + ((d1 - d0) * i) / count);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Evenly divided bands; returns the centre and width of each. */
|
|
58
|
-
export function bandScale(count: number, range: [number, number], padding = 0.2) {
|
|
59
|
-
const [r0, r1] = range;
|
|
60
|
-
const step = (r1 - r0) / Math.max(1, count);
|
|
61
|
-
const width = step * (1 - padding);
|
|
62
|
-
return {
|
|
63
|
-
bandWidth: step,
|
|
64
|
-
width,
|
|
65
|
-
start: (i: number) => r0 + i * step + (step - width) / 2,
|
|
66
|
-
center: (i: number) => r0 + i * step + step / 2,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Compact number formatting, matching the web charts. */
|
|
71
|
-
export function formatValue(
|
|
72
|
-
value: number,
|
|
73
|
-
options: { compact?: boolean; decimals?: number } = {},
|
|
74
|
-
): string {
|
|
75
|
-
if (Number.isNaN(value)) return "—";
|
|
76
|
-
if (options.compact) {
|
|
77
|
-
const abs = Math.abs(value);
|
|
78
|
-
if (abs >= 1_000_000_000) return trim(value / 1_000_000_000) + "B";
|
|
79
|
-
if (abs >= 1_000_000) return trim(value / 1_000_000) + "M";
|
|
80
|
-
if (abs >= 1_000) return trim(value / 1_000) + "k";
|
|
81
|
-
}
|
|
82
|
-
const fixed = options.decimals ?? (Number.isInteger(value) ? 0 : 2);
|
|
83
|
-
return value
|
|
84
|
-
.toFixed(fixed)
|
|
85
|
-
.replace(/(\.\d*?)0+$/, "$1")
|
|
86
|
-
.replace(/\.$/, "");
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function trim(value: number): string {
|
|
90
|
-
return (Math.round(value * 10) / 10).toString();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** Points along a smooth (monotone) path, as SVG path segments. */
|
|
94
|
-
export function smoothPath(points: { x: number; y: number }[]): string {
|
|
95
|
-
if (points.length === 0) return "";
|
|
96
|
-
if (points.length === 1) return `M ${points[0]!.x} ${points[0]!.y}`;
|
|
97
|
-
if (points.length === 2) return `M ${points[0]!.x} ${points[0]!.y} L ${points[1]!.x} ${points[1]!.y}`;
|
|
98
|
-
|
|
99
|
-
let d = `M ${points[0]!.x} ${points[0]!.y}`;
|
|
100
|
-
for (let i = 0; i < points.length - 1; i++) {
|
|
101
|
-
const p0 = points[i - 1] ?? points[i]!;
|
|
102
|
-
const p1 = points[i]!;
|
|
103
|
-
const p2 = points[i + 1]!;
|
|
104
|
-
const p3 = points[i + 2] ?? p2;
|
|
105
|
-
|
|
106
|
-
const t = 0.2;
|
|
107
|
-
const c1x = p1.x + (p2.x - p0.x) * t;
|
|
108
|
-
const c1y = p1.y + (p2.y - p0.y) * t;
|
|
109
|
-
const c2x = p2.x - (p3.x - p1.x) * t;
|
|
110
|
-
const c2y = p2.y - (p3.y - p1.y) * t;
|
|
111
|
-
|
|
112
|
-
// Clamp so the curve cannot overshoot the segment's own y-range.
|
|
113
|
-
const lo = Math.min(p1.y, p2.y);
|
|
114
|
-
const hi = Math.max(p1.y, p2.y);
|
|
115
|
-
d += ` C ${c1x} ${Math.min(hi, Math.max(lo, c1y))} ${c2x} ${Math.min(hi, Math.max(lo, c2y))} ${p2.x} ${p2.y}`;
|
|
116
|
-
}
|
|
117
|
-
return d;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** A pie/donut arc, with an optional inner radius. */
|
|
121
|
-
export function arcPath(
|
|
122
|
-
cx: number,
|
|
123
|
-
cy: number,
|
|
124
|
-
outer: number,
|
|
125
|
-
inner: number,
|
|
126
|
-
startAngle: number,
|
|
127
|
-
endAngle: number,
|
|
128
|
-
): string {
|
|
129
|
-
const sweep = endAngle - startAngle;
|
|
130
|
-
if (sweep >= Math.PI * 2 - 1e-6) {
|
|
131
|
-
const mid = startAngle + Math.PI;
|
|
132
|
-
return (
|
|
133
|
-
arcPath(cx, cy, outer, inner, startAngle, mid) +
|
|
134
|
-
" " +
|
|
135
|
-
arcPath(cx, cy, outer, inner, mid, endAngle - 1e-6)
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const p = (r: number, a: number) => [cx + r * Math.cos(a), cy + r * Math.sin(a)] as const;
|
|
140
|
-
const large = sweep > Math.PI ? 1 : 0;
|
|
141
|
-
const [x1, y1] = p(outer, startAngle);
|
|
142
|
-
const [x2, y2] = p(outer, endAngle);
|
|
143
|
-
|
|
144
|
-
if (inner <= 0) {
|
|
145
|
-
return `M ${cx} ${cy} L ${x1} ${y1} A ${outer} ${outer} 0 ${large} 1 ${x2} ${y2} Z`;
|
|
146
|
-
}
|
|
147
|
-
const [x3, y3] = p(inner, endAngle);
|
|
148
|
-
const [x4, y4] = p(inner, startAngle);
|
|
149
|
-
return `M ${x1} ${y1} A ${outer} ${outer} 0 ${large} 1 ${x2} ${y2} L ${x3} ${y3} A ${inner} ${inner} 0 ${large} 0 ${x4} ${y4} Z`;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export const SERIES_COLORS = [
|
|
153
|
-
"#0088ff",
|
|
154
|
-
"#34c759",
|
|
155
|
-
"#ff9f0a",
|
|
156
|
-
"#ff375f",
|
|
157
|
-
"#bf5af2",
|
|
158
|
-
"#64d2ff",
|
|
159
|
-
"#ffd60a",
|
|
160
|
-
] as const;
|
|
161
|
-
|
|
162
|
-
export const seriesColor = (index: number, palette?: readonly string[]): string =>
|
|
163
|
-
(palette ?? SERIES_COLORS)[index % (palette ?? SERIES_COLORS).length]!;
|