glacia-native 0.5.2 → 0.6.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 +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 +154 -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 +4 -2
- 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 +211 -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/LineChart.tsx
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { colors, radii } from "../internal/tokens";
|
|
4
|
-
import { useIsDark } from "../internal/motion";
|
|
5
|
-
import { primitives } from "../internal/primitives";
|
|
6
|
-
import {
|
|
7
|
-
bandScale,
|
|
8
|
-
formatValue,
|
|
9
|
-
linearScale,
|
|
10
|
-
niceDomain,
|
|
11
|
-
seriesColor,
|
|
12
|
-
smoothPath,
|
|
13
|
-
ticks,
|
|
14
|
-
} from "./scales";
|
|
15
|
-
|
|
16
|
-
export interface NativeLineSeries {
|
|
17
|
-
name: string;
|
|
18
|
-
values: number[];
|
|
19
|
-
color?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface NativeLineChartProps {
|
|
23
|
-
labels: string[];
|
|
24
|
-
series: NativeLineSeries[];
|
|
25
|
-
width?: number;
|
|
26
|
-
height?: number;
|
|
27
|
-
/** Fill beneath each line. */
|
|
28
|
-
area?: boolean;
|
|
29
|
-
smooth?: boolean;
|
|
30
|
-
showDots?: boolean;
|
|
31
|
-
isDark?: boolean;
|
|
32
|
-
palette?: readonly string[];
|
|
33
|
-
style?: StyleProps;
|
|
34
|
-
/** Called with the index of the touched point. */
|
|
35
|
-
onPointPress?: (index: number) => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const PADDING = { top: 12, right: 10, bottom: 24, left: 38 };
|
|
39
|
-
|
|
40
|
-
type StyleProps = any;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* A line chart drawn with react-native-svg.
|
|
44
|
-
*
|
|
45
|
-
* Uses the same scale maths as the web LineChart, so the same series produces
|
|
46
|
-
* the same axis values on both platforms. Touching a column selects that
|
|
47
|
-
* point, which is the touch equivalent of hovering on the web.
|
|
48
|
-
*/
|
|
49
|
-
export function NativeLineChart({
|
|
50
|
-
labels,
|
|
51
|
-
series,
|
|
52
|
-
width = 320,
|
|
53
|
-
height = 200,
|
|
54
|
-
area = false,
|
|
55
|
-
smooth = true,
|
|
56
|
-
showDots = false,
|
|
57
|
-
isDark: isDarkProp,
|
|
58
|
-
palette,
|
|
59
|
-
style,
|
|
60
|
-
onPointPress,
|
|
61
|
-
}: NativeLineChartProps) {
|
|
62
|
-
const [active, setActive] = useState<number | null>(null);
|
|
63
|
-
const isDark = useIsDark(isDarkProp);
|
|
64
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
65
|
-
const { View, Text, Pressable, Svg, G, Line, Path, Circle, SvgText } = primitives();
|
|
66
|
-
|
|
67
|
-
const plot = {
|
|
68
|
-
x: PADDING.left,
|
|
69
|
-
y: PADDING.top,
|
|
70
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
71
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
72
|
-
};
|
|
73
|
-
const bottom = plot.y + plot.height;
|
|
74
|
-
const right = plot.x + plot.width;
|
|
75
|
-
|
|
76
|
-
const all = series.flatMap((s) => s.values).filter(Number.isFinite);
|
|
77
|
-
|
|
78
|
-
const domain = useMemo(() => {
|
|
79
|
-
if (all.length === 0) return [0, 1] as [number, number];
|
|
80
|
-
const min = Math.min(...all);
|
|
81
|
-
const max = Math.max(...all);
|
|
82
|
-
return niceDomain(area ? Math.min(0, min) : min, max, 4);
|
|
83
|
-
}, [all.join(","), area]);
|
|
84
|
-
|
|
85
|
-
const y = linearScale(domain, [bottom, plot.y], { nice: false });
|
|
86
|
-
const x = bandScale(labels.length, [plot.x, right], 0);
|
|
87
|
-
const yTicks = ticks(domain, 4);
|
|
88
|
-
|
|
89
|
-
if (labels.length === 0 || series.length === 0) {
|
|
90
|
-
return (
|
|
91
|
-
<View style={[{ width, height, alignItems: "center", justifyContent: "center" }, style]}>
|
|
92
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No series to display</Text>
|
|
93
|
-
</View>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<View style={style}>
|
|
99
|
-
<Svg width={width} height={height}>
|
|
100
|
-
{/* Grid */}
|
|
101
|
-
{yTicks.map((tick, i) => (
|
|
102
|
-
<Line
|
|
103
|
-
key={`grid-${i}`}
|
|
104
|
-
x1={plot.x}
|
|
105
|
-
x2={right}
|
|
106
|
-
y1={y(tick)}
|
|
107
|
-
y2={y(tick)}
|
|
108
|
-
stroke={theme.axis}
|
|
109
|
-
strokeOpacity={0.24}
|
|
110
|
-
strokeWidth={1}
|
|
111
|
-
/>
|
|
112
|
-
))}
|
|
113
|
-
|
|
114
|
-
{series.map((s, si) => {
|
|
115
|
-
const color = s.color ?? seriesColor(si, palette);
|
|
116
|
-
const points = s.values.map((value, i) => ({
|
|
117
|
-
x: x.center(i),
|
|
118
|
-
y: Number.isFinite(value) ? y(value) : bottom,
|
|
119
|
-
}));
|
|
120
|
-
const line = smooth
|
|
121
|
-
? smoothPath(points)
|
|
122
|
-
: `M ${points.map((p) => `${p.x} ${p.y}`).join(" L ")}`;
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<G key={s.name}>
|
|
126
|
-
{area && (
|
|
127
|
-
<Path
|
|
128
|
-
d={`${line} L ${points[points.length - 1]!.x} ${bottom} L ${points[0]!.x} ${bottom} Z`}
|
|
129
|
-
fill={color}
|
|
130
|
-
fillOpacity={0.16}
|
|
131
|
-
/>
|
|
132
|
-
)}
|
|
133
|
-
<Path d={line} fill="none" stroke={color} strokeWidth={2} strokeLinecap="round" />
|
|
134
|
-
{(showDots || active !== null) &&
|
|
135
|
-
points.map((p, i) => (
|
|
136
|
-
<Circle
|
|
137
|
-
key={i}
|
|
138
|
-
cx={p.x}
|
|
139
|
-
cy={p.y}
|
|
140
|
-
r={active === i ? 4 : 2.5}
|
|
141
|
-
fill={color}
|
|
142
|
-
opacity={active === null || active === i ? 1 : 0.4}
|
|
143
|
-
/>
|
|
144
|
-
))}
|
|
145
|
-
</G>
|
|
146
|
-
);
|
|
147
|
-
})}
|
|
148
|
-
|
|
149
|
-
{/* Selected guide line */}
|
|
150
|
-
{active !== null && (
|
|
151
|
-
<Line
|
|
152
|
-
x1={x.center(active)}
|
|
153
|
-
x2={x.center(active)}
|
|
154
|
-
y1={plot.y}
|
|
155
|
-
y2={bottom}
|
|
156
|
-
stroke={theme.foreground}
|
|
157
|
-
strokeOpacity={0.24}
|
|
158
|
-
strokeWidth={1}
|
|
159
|
-
strokeDasharray="3 3"
|
|
160
|
-
/>
|
|
161
|
-
)}
|
|
162
|
-
|
|
163
|
-
{/* Axis labels */}
|
|
164
|
-
{yTicks.map((tick, i) => (
|
|
165
|
-
<SvgText
|
|
166
|
-
key={`y-${i}`}
|
|
167
|
-
x={plot.x - 6}
|
|
168
|
-
y={y(tick) + 3}
|
|
169
|
-
fill={theme.muted}
|
|
170
|
-
fontSize={9}
|
|
171
|
-
textAnchor="end"
|
|
172
|
-
>
|
|
173
|
-
{formatValue(tick, { compact: true })}
|
|
174
|
-
</SvgText>
|
|
175
|
-
))}
|
|
176
|
-
|
|
177
|
-
{labels.map((label, i) => (
|
|
178
|
-
<SvgText
|
|
179
|
-
key={`x-${i}`}
|
|
180
|
-
x={x.center(i)}
|
|
181
|
-
y={height - 8}
|
|
182
|
-
fill={theme.muted}
|
|
183
|
-
fontSize={9}
|
|
184
|
-
textAnchor="middle"
|
|
185
|
-
>
|
|
186
|
-
{label}
|
|
187
|
-
</SvgText>
|
|
188
|
-
))}
|
|
189
|
-
</Svg>
|
|
190
|
-
|
|
191
|
-
{/* Touch targets: one column per point, as wide as the band. */}
|
|
192
|
-
<View
|
|
193
|
-
style={{
|
|
194
|
-
position: "absolute",
|
|
195
|
-
left: plot.x,
|
|
196
|
-
top: plot.y,
|
|
197
|
-
width: plot.width,
|
|
198
|
-
height: plot.height,
|
|
199
|
-
flexDirection: "row",
|
|
200
|
-
}}
|
|
201
|
-
>
|
|
202
|
-
{labels.map((label, i) => (
|
|
203
|
-
<Pressable
|
|
204
|
-
key={label + i}
|
|
205
|
-
accessibilityRole="button"
|
|
206
|
-
accessibilityLabel={`${label}: ${series
|
|
207
|
-
.map((s) => `${s.name} ${formatValue(s.values[i] ?? 0)}`)
|
|
208
|
-
.join(", ")}`}
|
|
209
|
-
style={{ flex: 1 }}
|
|
210
|
-
onPress={() => {
|
|
211
|
-
setActive((current) => (current === i ? null : i));
|
|
212
|
-
onPointPress?.(i);
|
|
213
|
-
}}
|
|
214
|
-
/>
|
|
215
|
-
))}
|
|
216
|
-
</View>
|
|
217
|
-
|
|
218
|
-
{active !== null && (
|
|
219
|
-
<View
|
|
220
|
-
style={{
|
|
221
|
-
position: "absolute",
|
|
222
|
-
top: 0,
|
|
223
|
-
left: PADDING.left,
|
|
224
|
-
right: PADDING.right,
|
|
225
|
-
paddingVertical: 4,
|
|
226
|
-
paddingHorizontal: 8,
|
|
227
|
-
borderRadius: radii.sm,
|
|
228
|
-
backgroundColor: theme.glass,
|
|
229
|
-
flexDirection: "row",
|
|
230
|
-
flexWrap: "wrap",
|
|
231
|
-
gap: 8,
|
|
232
|
-
}}
|
|
233
|
-
pointerEvents="none"
|
|
234
|
-
>
|
|
235
|
-
<Text style={{ color: theme.foreground, fontSize: 10, fontWeight: "600" }}>
|
|
236
|
-
{labels[active]}
|
|
237
|
-
</Text>
|
|
238
|
-
{series.map((s, si) => (
|
|
239
|
-
<Text key={s.name} style={{ color: s.color ?? seriesColor(si, palette), fontSize: 10 }}>
|
|
240
|
-
{s.name} {formatValue(s.values[active] ?? 0)}
|
|
241
|
-
</Text>
|
|
242
|
-
))}
|
|
243
|
-
</View>
|
|
244
|
-
)}
|
|
245
|
-
</View>
|
|
246
|
-
);
|
|
247
|
-
}
|
package/src/charts/PlotChart.tsx
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { colors } from "../internal/tokens";
|
|
4
|
-
import { useIsDark } from "../internal/motion";
|
|
5
|
-
import { primitives } from "../internal/primitives";
|
|
6
|
-
import { formatValue, linearScale, niceDomain, ticks } from "./scales";
|
|
7
|
-
|
|
8
|
-
export interface NativePlotPoint {
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
label?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface NativePlotRenderArgs {
|
|
15
|
-
x: (value: number) => number;
|
|
16
|
-
y: (value: number) => number;
|
|
17
|
-
points: NativePlotPoint[];
|
|
18
|
-
width: number;
|
|
19
|
-
height: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface NativePlotChartProps {
|
|
23
|
-
points: NativePlotPoint[];
|
|
24
|
-
/** Draws the marks. Receives real pixel scales, not a fabricated viewBox. */
|
|
25
|
-
renderMark?: (args: NativePlotRenderArgs) => any;
|
|
26
|
-
width?: number;
|
|
27
|
-
height?: number;
|
|
28
|
-
xLabel?: string;
|
|
29
|
-
yLabel?: string;
|
|
30
|
-
isDark?: boolean;
|
|
31
|
-
style?: any;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const PADDING = { top: 12, right: 12, bottom: 26, left: 44 };
|
|
35
|
-
|
|
36
|
-
/** Reads the chart as one sentence for a screen reader. */
|
|
37
|
-
function plotSummary(
|
|
38
|
-
points: NativePlotPoint[],
|
|
39
|
-
xDomain: [number, number],
|
|
40
|
-
yDomain: [number, number],
|
|
41
|
-
): string {
|
|
42
|
-
return (
|
|
43
|
-
`Plot chart with ${points.length} points. ` +
|
|
44
|
-
`x from ${formatValue(xDomain[0], { compact: true })} to ${formatValue(xDomain[1], { compact: true })}, ` +
|
|
45
|
-
`y from ${formatValue(yDomain[0], { compact: true })} to ${formatValue(yDomain[1], { compact: true })}.`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* A numeric plot you supply the marks for.
|
|
51
|
-
*
|
|
52
|
-
* The axes, ticks and padding are handled here and the caller receives real
|
|
53
|
-
* pixel scales. That keeps stroke widths and text sizes honest regardless of
|
|
54
|
-
* the chart's width, instead of a scaled viewBox that would distort them.
|
|
55
|
-
*/
|
|
56
|
-
export function NativePlotChart({
|
|
57
|
-
points,
|
|
58
|
-
renderMark,
|
|
59
|
-
width = 320,
|
|
60
|
-
height = 200,
|
|
61
|
-
xLabel,
|
|
62
|
-
yLabel,
|
|
63
|
-
isDark: isDarkProp,
|
|
64
|
-
style,
|
|
65
|
-
}: NativePlotChartProps) {
|
|
66
|
-
const isDark = useIsDark(isDarkProp);
|
|
67
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
68
|
-
const { View, Text, Svg, G, Line, Circle, SvgText } = primitives();
|
|
69
|
-
|
|
70
|
-
const plot = {
|
|
71
|
-
x: PADDING.left,
|
|
72
|
-
y: PADDING.top,
|
|
73
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
74
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
75
|
-
};
|
|
76
|
-
const right = plot.x + plot.width;
|
|
77
|
-
const bottom = plot.y + plot.height;
|
|
78
|
-
|
|
79
|
-
const xDomain = useMemo(() => {
|
|
80
|
-
const values = points.map((point) => point.x).filter(Number.isFinite);
|
|
81
|
-
return niceDomain(values.length ? Math.min(...values) : 0, values.length ? Math.max(...values) : 1, 4);
|
|
82
|
-
}, [points.map((point) => point.x).join(",")]);
|
|
83
|
-
|
|
84
|
-
const yDomain = useMemo(() => {
|
|
85
|
-
const values = points.map((point) => point.y).filter(Number.isFinite);
|
|
86
|
-
return niceDomain(values.length ? Math.min(...values) : 0, values.length ? Math.max(...values) : 1, 4);
|
|
87
|
-
}, [points.map((point) => point.y).join(",")]);
|
|
88
|
-
|
|
89
|
-
const x = linearScale(xDomain, [plot.x, right], { nice: false });
|
|
90
|
-
const y = linearScale(yDomain, [bottom, plot.y], { nice: false });
|
|
91
|
-
|
|
92
|
-
if (points.length === 0) {
|
|
93
|
-
return (
|
|
94
|
-
<View style={[{ width, height, alignItems: "center", justifyContent: "center" }, style]}>
|
|
95
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No points to display</Text>
|
|
96
|
-
</View>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const yTicks = ticks(yDomain, 4);
|
|
101
|
-
const xTicks = ticks(xDomain, 4);
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<View
|
|
105
|
-
style={style}
|
|
106
|
-
accessible
|
|
107
|
-
accessibilityRole="image"
|
|
108
|
-
accessibilityLabel={plotSummary(points, xDomain, yDomain)}
|
|
109
|
-
>
|
|
110
|
-
<Svg width={width} height={height}>
|
|
111
|
-
{yTicks.map((tick, i) => (
|
|
112
|
-
<Line
|
|
113
|
-
key={`grid-${i}`}
|
|
114
|
-
x1={plot.x}
|
|
115
|
-
x2={right}
|
|
116
|
-
y1={y(tick)}
|
|
117
|
-
y2={y(tick)}
|
|
118
|
-
stroke={theme.axis}
|
|
119
|
-
strokeOpacity={0.22}
|
|
120
|
-
strokeWidth={1}
|
|
121
|
-
/>
|
|
122
|
-
))}
|
|
123
|
-
|
|
124
|
-
{renderMark ? (
|
|
125
|
-
renderMark({ x, y, points, width: plot.width, height: plot.height })
|
|
126
|
-
) : (
|
|
127
|
-
<G>
|
|
128
|
-
{points.map((point, index) => (
|
|
129
|
-
<Circle key={index} cx={x(point.x)} cy={y(point.y)} r={3.5} fill={theme.fill} />
|
|
130
|
-
))}
|
|
131
|
-
</G>
|
|
132
|
-
)}
|
|
133
|
-
|
|
134
|
-
{yTicks.map((tick, i) => (
|
|
135
|
-
<SvgText
|
|
136
|
-
key={`y-${i}`}
|
|
137
|
-
x={plot.x - 6}
|
|
138
|
-
y={y(tick) + 3}
|
|
139
|
-
fill={theme.muted}
|
|
140
|
-
fontSize={9}
|
|
141
|
-
textAnchor="end"
|
|
142
|
-
>
|
|
143
|
-
{formatValue(tick, { compact: true })}
|
|
144
|
-
</SvgText>
|
|
145
|
-
))}
|
|
146
|
-
|
|
147
|
-
{xTicks.map((tick, i) => (
|
|
148
|
-
<SvgText
|
|
149
|
-
key={`x-${i}`}
|
|
150
|
-
x={x(tick)}
|
|
151
|
-
y={height - 8}
|
|
152
|
-
fill={theme.muted}
|
|
153
|
-
fontSize={9}
|
|
154
|
-
textAnchor="middle"
|
|
155
|
-
>
|
|
156
|
-
{formatValue(tick, { compact: true })}
|
|
157
|
-
</SvgText>
|
|
158
|
-
))}
|
|
159
|
-
</Svg>
|
|
160
|
-
|
|
161
|
-
{(xLabel || yLabel) && (
|
|
162
|
-
<Text style={{ fontSize: 9, color: theme.muted, marginTop: 2 }}>
|
|
163
|
-
{[xLabel, yLabel].filter(Boolean).join(" · ")}
|
|
164
|
-
</Text>
|
|
165
|
-
)}
|
|
166
|
-
</View>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
@@ -1,208 +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 { formatValue, seriesColor } from "./scales";
|
|
7
|
-
|
|
8
|
-
export interface NativeRadarSeries {
|
|
9
|
-
name: string;
|
|
10
|
-
/** One value per axis, in the same order as `axes`. */
|
|
11
|
-
values: number[];
|
|
12
|
-
color?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface NativeRadarChartProps {
|
|
16
|
-
axes: string[];
|
|
17
|
-
series: NativeRadarSeries[];
|
|
18
|
-
size?: number;
|
|
19
|
-
/** Number of concentric rings behind the data. */
|
|
20
|
-
rings?: number;
|
|
21
|
-
/** Fixed maximum; defaults to the largest value across series. */
|
|
22
|
-
max?: number;
|
|
23
|
-
isDark?: boolean;
|
|
24
|
-
palette?: readonly string[];
|
|
25
|
-
style?: any;
|
|
26
|
-
onAxisPress?: (index: number) => void;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const TAU = Math.PI * 2;
|
|
30
|
-
|
|
31
|
-
/** Point on a circle at `index` of `count`, starting at 12 o'clock. */
|
|
32
|
-
function vertex(index: number, count: number, radius: number, cx: number, cy: number) {
|
|
33
|
-
const angle = (index / count) * TAU - Math.PI / 2;
|
|
34
|
-
return { x: cx + Math.cos(angle) * radius, y: cy + Math.sin(angle) * radius };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Several axes around a circle, one closed shape per series.
|
|
39
|
-
*
|
|
40
|
-
* Reading many dimensions off a phone is hard, so every axis label is also a
|
|
41
|
-
* touch target: tapping one lists that axis's values for all series instead of
|
|
42
|
-
* relying on a hover tooltip.
|
|
43
|
-
*/
|
|
44
|
-
export function NativeRadarChart({
|
|
45
|
-
axes,
|
|
46
|
-
series,
|
|
47
|
-
size = 260,
|
|
48
|
-
rings = 4,
|
|
49
|
-
max,
|
|
50
|
-
isDark: isDarkProp,
|
|
51
|
-
palette,
|
|
52
|
-
style,
|
|
53
|
-
onAxisPress,
|
|
54
|
-
}: NativeRadarChartProps) {
|
|
55
|
-
const [active, setActive] = useState<number | null>(null);
|
|
56
|
-
const isDark = useIsDark(isDarkProp);
|
|
57
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
58
|
-
const { View, Text, Pressable, Svg, G, Line, Polygon, Circle, SvgText } = primitives();
|
|
59
|
-
|
|
60
|
-
if (axes.length < 3 || series.length === 0) {
|
|
61
|
-
return (
|
|
62
|
-
<View style={[{ width: size, alignItems: "center", paddingVertical: 20 }, style]}>
|
|
63
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>
|
|
64
|
-
{axes.length < 3 ? "A radar chart needs at least 3 axes" : "No series to display"}
|
|
65
|
-
</Text>
|
|
66
|
-
</View>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const cx = size / 2;
|
|
71
|
-
const cy = size / 2;
|
|
72
|
-
// Leave room for the axis labels, which sit outside the outer ring.
|
|
73
|
-
const radius = size / 2 - 26;
|
|
74
|
-
|
|
75
|
-
const allValues = series.flatMap((s) => s.values).filter(Number.isFinite);
|
|
76
|
-
const highest = max ?? (allValues.length ? Math.max(...allValues) : 1);
|
|
77
|
-
const ceiling = highest > 0 ? highest : 1;
|
|
78
|
-
|
|
79
|
-
const ringPolygons = Array.from({ length: rings }, (_, i) => {
|
|
80
|
-
const r = (radius * (i + 1)) / rings;
|
|
81
|
-
return axes
|
|
82
|
-
.map((_, a) => {
|
|
83
|
-
const p = vertex(a, axes.length, r, cx, cy);
|
|
84
|
-
return `${p.x},${p.y}`;
|
|
85
|
-
})
|
|
86
|
-
.join(" ");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<View style={[{ width: size }, style]}>
|
|
91
|
-
<Svg width={size} height={size}>
|
|
92
|
-
{ringPolygons.map((points, i) => (
|
|
93
|
-
<Polygon
|
|
94
|
-
key={`ring-${i}`}
|
|
95
|
-
points={points}
|
|
96
|
-
fill="none"
|
|
97
|
-
stroke={theme.axis}
|
|
98
|
-
strokeOpacity={0.22}
|
|
99
|
-
strokeWidth={1}
|
|
100
|
-
/>
|
|
101
|
-
))}
|
|
102
|
-
|
|
103
|
-
{axes.map((_, a) => {
|
|
104
|
-
const p = vertex(a, axes.length, radius, cx, cy);
|
|
105
|
-
return (
|
|
106
|
-
<Line
|
|
107
|
-
key={`spoke-${a}`}
|
|
108
|
-
x1={cx}
|
|
109
|
-
y1={cy}
|
|
110
|
-
x2={p.x}
|
|
111
|
-
y2={p.y}
|
|
112
|
-
stroke={theme.axis}
|
|
113
|
-
strokeOpacity={0.22}
|
|
114
|
-
strokeWidth={1}
|
|
115
|
-
/>
|
|
116
|
-
);
|
|
117
|
-
})}
|
|
118
|
-
|
|
119
|
-
{series.map((s, si) => {
|
|
120
|
-
const color = s.color ?? seriesColor(si, palette);
|
|
121
|
-
const points = s.values
|
|
122
|
-
.map((value, a) => {
|
|
123
|
-
const ratio = Math.max(0, Math.min(1, value / ceiling));
|
|
124
|
-
const p = vertex(a, axes.length, radius * ratio, cx, cy);
|
|
125
|
-
return `${p.x},${p.y}`;
|
|
126
|
-
})
|
|
127
|
-
.join(" ");
|
|
128
|
-
|
|
129
|
-
return (
|
|
130
|
-
<G key={s.name}>
|
|
131
|
-
<Polygon
|
|
132
|
-
points={points}
|
|
133
|
-
fill={color}
|
|
134
|
-
fillOpacity={active === null ? 0.18 : 0.1}
|
|
135
|
-
stroke={color}
|
|
136
|
-
strokeWidth={2}
|
|
137
|
-
/>
|
|
138
|
-
{s.values.map((value, a) => {
|
|
139
|
-
const ratio = Math.max(0, Math.min(1, value / ceiling));
|
|
140
|
-
const p = vertex(a, axes.length, radius * ratio, cx, cy);
|
|
141
|
-
return (
|
|
142
|
-
<Circle
|
|
143
|
-
key={a}
|
|
144
|
-
cx={p.x}
|
|
145
|
-
cy={p.y}
|
|
146
|
-
r={active === a ? 4 : 2.5}
|
|
147
|
-
fill={color}
|
|
148
|
-
/>
|
|
149
|
-
);
|
|
150
|
-
})}
|
|
151
|
-
</G>
|
|
152
|
-
);
|
|
153
|
-
})}
|
|
154
|
-
|
|
155
|
-
{axes.map((axis, a) => {
|
|
156
|
-
const p = vertex(a, axes.length, radius + 13, cx, cy);
|
|
157
|
-
// Labels on the left half should end at the axis, not start from it.
|
|
158
|
-
const anchor = p.x < cx - 1 ? "end" : p.x > cx + 1 ? "start" : "middle";
|
|
159
|
-
return (
|
|
160
|
-
<SvgText
|
|
161
|
-
key={`label-${a}`}
|
|
162
|
-
x={p.x}
|
|
163
|
-
y={p.y + 3}
|
|
164
|
-
fill={active === a ? theme.foreground : theme.muted}
|
|
165
|
-
fontSize={9}
|
|
166
|
-
textAnchor={anchor}
|
|
167
|
-
>
|
|
168
|
-
{axis}
|
|
169
|
-
</SvgText>
|
|
170
|
-
);
|
|
171
|
-
})}
|
|
172
|
-
</Svg>
|
|
173
|
-
|
|
174
|
-
{/* Axis pickers: a phone has no hover, so each axis is separately tappable. */}
|
|
175
|
-
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 6, marginTop: 8 }}>
|
|
176
|
-
{axes.map((axis, a) => (
|
|
177
|
-
<Pressable
|
|
178
|
-
key={axis}
|
|
179
|
-
accessibilityRole="button"
|
|
180
|
-
accessibilityLabel={`${axis} axis`}
|
|
181
|
-
onPress={() => {
|
|
182
|
-
setActive((current) => (current === a ? null : a));
|
|
183
|
-
onAxisPress?.(a);
|
|
184
|
-
}}
|
|
185
|
-
style={{
|
|
186
|
-
paddingVertical: 3,
|
|
187
|
-
paddingHorizontal: 8,
|
|
188
|
-
borderRadius: 7,
|
|
189
|
-
backgroundColor: active === a ? theme.glassActive : theme.glass,
|
|
190
|
-
}}
|
|
191
|
-
>
|
|
192
|
-
<Text style={{ color: theme.foreground, fontSize: 10 }}>{axis}</Text>
|
|
193
|
-
</Pressable>
|
|
194
|
-
))}
|
|
195
|
-
</View>
|
|
196
|
-
|
|
197
|
-
{active !== null && (
|
|
198
|
-
<View style={{ marginTop: 8 }}>
|
|
199
|
-
{series.map((s, si) => (
|
|
200
|
-
<Text key={s.name} style={{ color: theme.muted, fontSize: 10, marginTop: 2 }}>
|
|
201
|
-
{s.name}: {formatValue(s.values[active] ?? 0)}
|
|
202
|
-
</Text>
|
|
203
|
-
))}
|
|
204
|
-
</View>
|
|
205
|
-
)}
|
|
206
|
-
</View>
|
|
207
|
-
);
|
|
208
|
-
}
|