react-native-chart-kit 7.0.0-next.1 → 7.0.0-next.3
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 +89 -521
- package/dist/charts/line/LineChart.d.ts +3 -3
- package/dist/charts/line/LineChart.js +1 -1
- package/dist/v2/core/data/index.d.ts +3 -0
- package/dist/v2/core/data/index.d.ts.map +1 -0
- package/dist/v2/core/data/index.js +1 -0
- package/dist/v2/core/data/normalize.d.ts +8 -0
- package/dist/v2/core/data/normalize.d.ts.map +1 -0
- package/dist/v2/core/data/normalize.js +229 -0
- package/dist/v2/core/data/normalizeValues.d.ts +16 -0
- package/dist/v2/core/data/normalizeValues.d.ts.map +1 -0
- package/dist/v2/core/data/normalizeValues.js +96 -0
- package/dist/v2/core/data/types.d.ts +161 -0
- package/dist/v2/core/data/types.d.ts.map +1 -0
- package/dist/v2/core/data/types.js +1 -0
- package/dist/v2/core/geometry/areaPath.d.ts +3 -0
- package/dist/v2/core/geometry/areaPath.d.ts.map +1 -0
- package/dist/v2/core/geometry/areaPath.js +36 -0
- package/dist/v2/core/geometry/barRects.d.ts +44 -0
- package/dist/v2/core/geometry/barRects.d.ts.map +1 -0
- package/dist/v2/core/geometry/barRects.js +201 -0
- package/dist/v2/core/geometry/contributionHeatmap.d.ts +49 -0
- package/dist/v2/core/geometry/contributionHeatmap.d.ts.map +1 -0
- package/dist/v2/core/geometry/contributionHeatmap.js +107 -0
- package/dist/v2/core/geometry/horizontalBarRects.d.ts +27 -0
- package/dist/v2/core/geometry/horizontalBarRects.d.ts.map +1 -0
- package/dist/v2/core/geometry/horizontalBarRects.js +202 -0
- package/dist/v2/core/geometry/index.d.ts +12 -0
- package/dist/v2/core/geometry/index.d.ts.map +1 -0
- package/dist/v2/core/geometry/index.js +11 -0
- package/dist/v2/core/geometry/lineDecimation.d.ts +8 -0
- package/dist/v2/core/geometry/lineDecimation.d.ts.map +1 -0
- package/dist/v2/core/geometry/lineDecimation.js +110 -0
- package/dist/v2/core/geometry/linePath.d.ts +5 -0
- package/dist/v2/core/geometry/linePath.d.ts.map +1 -0
- package/dist/v2/core/geometry/linePath.js +98 -0
- package/dist/v2/core/geometry/lineSeries.d.ts +29 -0
- package/dist/v2/core/geometry/lineSeries.d.ts.map +1 -0
- package/dist/v2/core/geometry/lineSeries.js +51 -0
- package/dist/v2/core/geometry/path.d.ts +6 -0
- package/dist/v2/core/geometry/path.d.ts.map +1 -0
- package/dist/v2/core/geometry/path.js +24 -0
- package/dist/v2/core/geometry/pieArcs.d.ts +29 -0
- package/dist/v2/core/geometry/pieArcs.d.ts.map +1 -0
- package/dist/v2/core/geometry/pieArcs.js +142 -0
- package/dist/v2/core/geometry/progressRings.d.ts +30 -0
- package/dist/v2/core/geometry/progressRings.d.ts.map +1 -0
- package/dist/v2/core/geometry/progressRings.js +104 -0
- package/dist/v2/core/geometry/types.d.ts +32 -0
- package/dist/v2/core/geometry/types.d.ts.map +1 -0
- package/dist/v2/core/geometry/types.js +1 -0
- package/dist/v2/core/index.d.ts +6 -0
- package/dist/v2/core/index.d.ts.map +1 -0
- package/dist/v2/core/index.js +6 -0
- package/dist/v2/core/interaction/index.d.ts +5 -0
- package/dist/v2/core/interaction/index.d.ts.map +1 -0
- package/dist/v2/core/interaction/index.js +2 -0
- package/dist/v2/core/interaction/viewport.d.ts +71 -0
- package/dist/v2/core/interaction/viewport.d.ts.map +1 -0
- package/dist/v2/core/interaction/viewport.js +216 -0
- package/dist/v2/core/interaction/viewportTransform.d.ts +17 -0
- package/dist/v2/core/interaction/viewportTransform.d.ts.map +1 -0
- package/dist/v2/core/interaction/viewportTransform.js +70 -0
- package/dist/v2/core/layout/autoPadding.d.ts +3 -0
- package/dist/v2/core/layout/autoPadding.d.ts.map +1 -0
- package/dist/v2/core/layout/autoPadding.js +33 -0
- package/dist/v2/core/layout/chartBox.d.ts +5 -0
- package/dist/v2/core/layout/chartBox.d.ts.map +1 -0
- package/dist/v2/core/layout/chartBox.js +22 -0
- package/dist/v2/core/layout/debugLayout.d.ts +3 -0
- package/dist/v2/core/layout/debugLayout.d.ts.map +1 -0
- package/dist/v2/core/layout/debugLayout.js +20 -0
- package/dist/v2/core/layout/index.d.ts +8 -0
- package/dist/v2/core/layout/index.d.ts.map +1 -0
- package/dist/v2/core/layout/index.js +6 -0
- package/dist/v2/core/layout/labelCollision.d.ts +3 -0
- package/dist/v2/core/layout/labelCollision.d.ts.map +1 -0
- package/dist/v2/core/layout/labelCollision.js +90 -0
- package/dist/v2/core/layout/legendLayout.d.ts +3 -0
- package/dist/v2/core/layout/legendLayout.d.ts.map +1 -0
- package/dist/v2/core/layout/legendLayout.js +39 -0
- package/dist/v2/core/layout/tooltipPlacement.d.ts +3 -0
- package/dist/v2/core/layout/tooltipPlacement.d.ts.map +1 -0
- package/dist/v2/core/layout/tooltipPlacement.js +76 -0
- package/dist/v2/core/layout/types.d.ts +114 -0
- package/dist/v2/core/layout/types.d.ts.map +1 -0
- package/dist/v2/core/layout/types.js +1 -0
- package/dist/v2/core/scales/band.d.ts +15 -0
- package/dist/v2/core/scales/band.d.ts.map +1 -0
- package/dist/v2/core/scales/band.js +34 -0
- package/dist/v2/core/scales/domain.d.ts +6 -0
- package/dist/v2/core/scales/domain.d.ts.map +1 -0
- package/dist/v2/core/scales/domain.js +109 -0
- package/dist/v2/core/scales/index.d.ts +7 -0
- package/dist/v2/core/scales/index.d.ts.map +1 -0
- package/dist/v2/core/scales/index.js +5 -0
- package/dist/v2/core/scales/linear.d.ts +8 -0
- package/dist/v2/core/scales/linear.d.ts.map +1 -0
- package/dist/v2/core/scales/linear.js +22 -0
- package/dist/v2/core/scales/ticks.d.ts +4 -0
- package/dist/v2/core/scales/ticks.d.ts.map +1 -0
- package/dist/v2/core/scales/ticks.js +111 -0
- package/dist/v2/core/scales/time.d.ts +8 -0
- package/dist/v2/core/scales/time.d.ts.map +1 -0
- package/dist/v2/core/scales/time.js +23 -0
- package/dist/v2/core/scales/types.d.ts +46 -0
- package/dist/v2/core/scales/types.d.ts.map +1 -0
- package/dist/v2/core/scales/types.js +1 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +1 -0
- package/dist/v2/react-native/charts/bar/BarChart.d.ts +6 -0
- package/dist/v2/react-native/charts/bar/BarChart.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/BarChart.js +199 -0
- package/dist/v2/react-native/charts/bar/BarChartSurface.d.ts +36 -0
- package/dist/v2/react-native/charts/bar/BarChartSurface.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/BarChartSurface.js +134 -0
- package/dist/v2/react-native/charts/bar/StackedBarChart.d.ts +4 -0
- package/dist/v2/react-native/charts/bar/StackedBarChart.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/StackedBarChart.js +9 -0
- package/dist/v2/react-native/charts/bar/accessibility.d.ts +31 -0
- package/dist/v2/react-native/charts/bar/accessibility.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/accessibility.js +87 -0
- package/dist/v2/react-native/charts/bar/interaction.d.ts +18 -0
- package/dist/v2/react-native/charts/bar/interaction.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/interaction.js +62 -0
- package/dist/v2/react-native/charts/bar/model.d.ts +3 -0
- package/dist/v2/react-native/charts/bar/model.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/model.js +326 -0
- package/dist/v2/react-native/charts/bar/modelUtils.d.ts +27 -0
- package/dist/v2/react-native/charts/bar/modelUtils.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/modelUtils.js +58 -0
- package/dist/v2/react-native/charts/bar/options.d.ts +7 -0
- package/dist/v2/react-native/charts/bar/options.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/options.js +49 -0
- package/dist/v2/react-native/charts/bar/rendererSafety.d.ts +12 -0
- package/dist/v2/react-native/charts/bar/rendererSafety.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/rendererSafety.js +31 -0
- package/dist/v2/react-native/charts/bar/selectionAnimation.d.ts +42 -0
- package/dist/v2/react-native/charts/bar/selectionAnimation.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/selectionAnimation.js +158 -0
- package/dist/v2/react-native/charts/bar/stackedCompat.d.ts +55 -0
- package/dist/v2/react-native/charts/bar/stackedCompat.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/stackedCompat.js +105 -0
- package/dist/v2/react-native/charts/bar/tooltip.d.ts +11 -0
- package/dist/v2/react-native/charts/bar/tooltip.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/tooltip.js +18 -0
- package/dist/v2/react-native/charts/bar/tooltipModel.d.ts +33 -0
- package/dist/v2/react-native/charts/bar/tooltipModel.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/tooltipModel.js +46 -0
- package/dist/v2/react-native/charts/bar/tooltipPlacement.d.ts +9 -0
- package/dist/v2/react-native/charts/bar/tooltipPlacement.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/tooltipPlacement.js +9 -0
- package/dist/v2/react-native/charts/bar/types.d.ts +211 -0
- package/dist/v2/react-native/charts/bar/types.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/types.js +1 -0
- package/dist/v2/react-native/charts/bar/useAnimatedTooltipModel.d.ts +10 -0
- package/dist/v2/react-native/charts/bar/useAnimatedTooltipModel.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/useAnimatedTooltipModel.js +87 -0
- package/dist/v2/react-native/charts/bar/viewport.d.ts +20 -0
- package/dist/v2/react-native/charts/bar/viewport.d.ts.map +1 -0
- package/dist/v2/react-native/charts/bar/viewport.js +47 -0
- package/dist/v2/react-native/charts/contribution/ContributionGraph.d.ts +13 -0
- package/dist/v2/react-native/charts/contribution/ContributionGraph.d.ts.map +1 -0
- package/dist/v2/react-native/charts/contribution/ContributionGraph.js +159 -0
- package/dist/v2/react-native/charts/contribution/accessibility.d.ts +25 -0
- package/dist/v2/react-native/charts/contribution/accessibility.d.ts.map +1 -0
- package/dist/v2/react-native/charts/contribution/accessibility.js +50 -0
- package/dist/v2/react-native/charts/contribution/interaction.d.ts +23 -0
- package/dist/v2/react-native/charts/contribution/interaction.d.ts.map +1 -0
- package/dist/v2/react-native/charts/contribution/interaction.js +75 -0
- package/dist/v2/react-native/charts/contribution/model.d.ts +17 -0
- package/dist/v2/react-native/charts/contribution/model.d.ts.map +1 -0
- package/dist/v2/react-native/charts/contribution/model.js +102 -0
- package/dist/v2/react-native/charts/contribution/types.d.ts +71 -0
- package/dist/v2/react-native/charts/contribution/types.d.ts.map +1 -0
- package/dist/v2/react-native/charts/contribution/types.js +1 -0
- package/dist/v2/react-native/charts/line/AreaChart.d.ts +3 -0
- package/dist/v2/react-native/charts/line/AreaChart.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/AreaChart.js +3 -0
- package/dist/v2/react-native/charts/line/ChartSurface.d.ts +16 -0
- package/dist/v2/react-native/charts/line/ChartSurface.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/ChartSurface.js +151 -0
- package/dist/v2/react-native/charts/line/LineChart.d.ts +6 -0
- package/dist/v2/react-native/charts/line/LineChart.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/LineChart.js +294 -0
- package/dist/v2/react-native/charts/line/StickyYAxis.d.ts +15 -0
- package/dist/v2/react-native/charts/line/StickyYAxis.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/StickyYAxis.js +26 -0
- package/dist/v2/react-native/charts/line/accessibility.d.ts +34 -0
- package/dist/v2/react-native/charts/line/accessibility.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/accessibility.js +103 -0
- package/dist/v2/react-native/charts/line/axisLabels.d.ts +37 -0
- package/dist/v2/react-native/charts/line/axisLabels.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/axisLabels.js +55 -0
- package/dist/v2/react-native/charts/line/debugLayout.d.ts +26 -0
- package/dist/v2/react-native/charts/line/debugLayout.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/debugLayout.js +77 -0
- package/dist/v2/react-native/charts/line/debugOverlay.d.ts +9 -0
- package/dist/v2/react-native/charts/line/debugOverlay.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/debugOverlay.js +30 -0
- package/dist/v2/react-native/charts/line/defaultTooltip.d.ts +3 -0
- package/dist/v2/react-native/charts/line/defaultTooltip.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/defaultTooltip.js +17 -0
- package/dist/v2/react-native/charts/line/interaction.d.ts +82 -0
- package/dist/v2/react-native/charts/line/interaction.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/interaction.js +94 -0
- package/dist/v2/react-native/charts/line/legend.d.ts +35 -0
- package/dist/v2/react-native/charts/line/legend.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/legend.js +95 -0
- package/dist/v2/react-native/charts/line/markers.d.ts +11 -0
- package/dist/v2/react-native/charts/line/markers.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/markers.js +52 -0
- package/dist/v2/react-native/charts/line/options.d.ts +172 -0
- package/dist/v2/react-native/charts/line/options.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/options.js +168 -0
- package/dist/v2/react-native/charts/line/outsidePressSurfaces.d.ts +15 -0
- package/dist/v2/react-native/charts/line/outsidePressSurfaces.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/outsidePressSurfaces.js +37 -0
- package/dist/v2/react-native/charts/line/overviewProps.d.ts +45 -0
- package/dist/v2/react-native/charts/line/overviewProps.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/overviewProps.js +4 -0
- package/dist/v2/react-native/charts/line/rangeSelector.d.ts +19 -0
- package/dist/v2/react-native/charts/line/rangeSelector.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/rangeSelector.js +185 -0
- package/dist/v2/react-native/charts/line/rangeSelectorConfig.d.ts +38 -0
- package/dist/v2/react-native/charts/line/rangeSelectorConfig.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/rangeSelectorConfig.js +41 -0
- package/dist/v2/react-native/charts/line/referenceLabelPlacement.d.ts +21 -0
- package/dist/v2/react-native/charts/line/referenceLabelPlacement.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/referenceLabelPlacement.js +113 -0
- package/dist/v2/react-native/charts/line/references.d.ts +62 -0
- package/dist/v2/react-native/charts/line/references.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/references.js +156 -0
- package/dist/v2/react-native/charts/line/renderer.d.ts +4 -0
- package/dist/v2/react-native/charts/line/renderer.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/renderer.js +23 -0
- package/dist/v2/react-native/charts/line/responders.d.ts +13 -0
- package/dist/v2/react-native/charts/line/responders.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/responders.js +62 -0
- package/dist/v2/react-native/charts/line/selection.d.ts +31 -0
- package/dist/v2/react-native/charts/line/selection.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/selection.js +26 -0
- package/dist/v2/react-native/charts/line/seriesInput.d.ts +4 -0
- package/dist/v2/react-native/charts/line/seriesInput.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/seriesInput.js +13 -0
- package/dist/v2/react-native/charts/line/seriesStyles.d.ts +20 -0
- package/dist/v2/react-native/charts/line/seriesStyles.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/seriesStyles.js +33 -0
- package/dist/v2/react-native/charts/line/stickyYAxisLayout.d.ts +6 -0
- package/dist/v2/react-native/charts/line/stickyYAxisLayout.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/stickyYAxisLayout.js +2 -0
- package/dist/v2/react-native/charts/line/text.d.ts +7 -0
- package/dist/v2/react-native/charts/line/text.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/text.js +7 -0
- package/dist/v2/react-native/charts/line/thresholdRendering.d.ts +28 -0
- package/dist/v2/react-native/charts/line/thresholdRendering.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/thresholdRendering.js +145 -0
- package/dist/v2/react-native/charts/line/tooltip.d.ts +70 -0
- package/dist/v2/react-native/charts/line/tooltip.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/tooltip.js +87 -0
- package/dist/v2/react-native/charts/line/types.d.ts +371 -0
- package/dist/v2/react-native/charts/line/types.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/types.js +1 -0
- package/dist/v2/react-native/charts/line/useAnimatedTooltipModel.d.ts +13 -0
- package/dist/v2/react-native/charts/line/useAnimatedTooltipModel.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/useAnimatedTooltipModel.js +84 -0
- package/dist/v2/react-native/charts/line/useAnimatedYAxisLabels.d.ts +5 -0
- package/dist/v2/react-native/charts/line/useAnimatedYAxisLabels.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/useAnimatedYAxisLabels.js +141 -0
- package/dist/v2/react-native/charts/line/useChartModel.d.ts +103 -0
- package/dist/v2/react-native/charts/line/useChartModel.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/useChartModel.js +367 -0
- package/dist/v2/react-native/charts/line/useDebugLayout.d.ts +16 -0
- package/dist/v2/react-native/charts/line/useDebugLayout.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/useDebugLayout.js +35 -0
- package/dist/v2/react-native/charts/line/utils.d.ts +10 -0
- package/dist/v2/react-native/charts/line/utils.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/utils.js +40 -0
- package/dist/v2/react-native/charts/line/viewportInteraction.d.ts +3 -0
- package/dist/v2/react-native/charts/line/viewportInteraction.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/viewportInteraction.js +1 -0
- package/dist/v2/react-native/charts/line/viewportPinchZoom.d.ts +2 -0
- package/dist/v2/react-native/charts/line/viewportPinchZoom.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/viewportPinchZoom.js +1 -0
- package/dist/v2/react-native/charts/line/xLabelCandidates.d.ts +13 -0
- package/dist/v2/react-native/charts/line/xLabelCandidates.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/xLabelCandidates.js +23 -0
- package/dist/v2/react-native/charts/line/xLabels.d.ts +39 -0
- package/dist/v2/react-native/charts/line/xLabels.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/xLabels.js +289 -0
- package/dist/v2/react-native/charts/line/xScale.d.ts +6 -0
- package/dist/v2/react-native/charts/line/xScale.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/xScale.js +25 -0
- package/dist/v2/react-native/charts/line/yAxisModel.d.ts +29 -0
- package/dist/v2/react-native/charts/line/yAxisModel.d.ts.map +1 -0
- package/dist/v2/react-native/charts/line/yAxisModel.js +39 -0
- package/dist/v2/react-native/charts/pie/PieChart.d.ts +7 -0
- package/dist/v2/react-native/charts/pie/PieChart.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/PieChart.js +253 -0
- package/dist/v2/react-native/charts/pie/accessibility.d.ts +28 -0
- package/dist/v2/react-native/charts/pie/accessibility.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/accessibility.js +49 -0
- package/dist/v2/react-native/charts/pie/activeSlice.d.ts +15 -0
- package/dist/v2/react-native/charts/pie/activeSlice.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/activeSlice.js +26 -0
- package/dist/v2/react-native/charts/pie/arcLabels.d.ts +32 -0
- package/dist/v2/react-native/charts/pie/arcLabels.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/arcLabels.js +191 -0
- package/dist/v2/react-native/charts/pie/interaction.d.ts +26 -0
- package/dist/v2/react-native/charts/pie/interaction.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/interaction.js +66 -0
- package/dist/v2/react-native/charts/pie/model.d.ts +15 -0
- package/dist/v2/react-native/charts/pie/model.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/model.js +157 -0
- package/dist/v2/react-native/charts/pie/selectionAnimation.d.ts +33 -0
- package/dist/v2/react-native/charts/pie/selectionAnimation.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/selectionAnimation.js +121 -0
- package/dist/v2/react-native/charts/pie/sliceSeparator.d.ts +7 -0
- package/dist/v2/react-native/charts/pie/sliceSeparator.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/sliceSeparator.js +26 -0
- package/dist/v2/react-native/charts/pie/slices.d.ts +20 -0
- package/dist/v2/react-native/charts/pie/slices.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/slices.js +54 -0
- package/dist/v2/react-native/charts/pie/types.d.ts +165 -0
- package/dist/v2/react-native/charts/pie/types.d.ts.map +1 -0
- package/dist/v2/react-native/charts/pie/types.js +1 -0
- package/dist/v2/react-native/charts/progress/ProgressChart.d.ts +7 -0
- package/dist/v2/react-native/charts/progress/ProgressChart.d.ts.map +1 -0
- package/dist/v2/react-native/charts/progress/ProgressChart.js +111 -0
- package/dist/v2/react-native/charts/progress/accessibility.d.ts +26 -0
- package/dist/v2/react-native/charts/progress/accessibility.d.ts.map +1 -0
- package/dist/v2/react-native/charts/progress/accessibility.js +71 -0
- package/dist/v2/react-native/charts/progress/animation.d.ts +36 -0
- package/dist/v2/react-native/charts/progress/animation.d.ts.map +1 -0
- package/dist/v2/react-native/charts/progress/animation.js +103 -0
- package/dist/v2/react-native/charts/progress/model.d.ts +14 -0
- package/dist/v2/react-native/charts/progress/model.d.ts.map +1 -0
- package/dist/v2/react-native/charts/progress/model.js +133 -0
- package/dist/v2/react-native/charts/progress/types.d.ts +72 -0
- package/dist/v2/react-native/charts/progress/types.d.ts.map +1 -0
- package/dist/v2/react-native/charts/progress/types.js +1 -0
- package/dist/v2/react-native/index.d.ts +24 -0
- package/dist/v2/react-native/index.d.ts.map +1 -0
- package/dist/v2/react-native/index.js +14 -0
- package/dist/v2/react-native/selection/ChartSelectionProvider.d.ts +27 -0
- package/dist/v2/react-native/selection/ChartSelectionProvider.d.ts.map +1 -0
- package/dist/v2/react-native/selection/ChartSelectionProvider.js +92 -0
- package/dist/v2/react-native/selection/index.d.ts +2 -0
- package/dist/v2/react-native/selection/index.d.ts.map +1 -0
- package/dist/v2/react-native/selection/index.js +1 -0
- package/dist/v2/react-native/selection/scope.d.ts +16 -0
- package/dist/v2/react-native/selection/scope.d.ts.map +1 -0
- package/dist/v2/react-native/selection/scope.js +18 -0
- package/dist/v2/react-native/theme/index.d.ts +4 -0
- package/dist/v2/react-native/theme/index.d.ts.map +1 -0
- package/dist/v2/react-native/theme/index.js +2 -0
- package/dist/v2/react-native/theme/presets.d.ts +84 -0
- package/dist/v2/react-native/theme/presets.d.ts.map +1 -0
- package/dist/v2/react-native/theme/presets.js +298 -0
- package/dist/v2/react-native/theme/provider.d.ts +20 -0
- package/dist/v2/react-native/theme/provider.d.ts.map +1 -0
- package/dist/v2/react-native/theme/provider.js +27 -0
- package/dist/v2/react-native/viewport/bounds.d.ts +7 -0
- package/dist/v2/react-native/viewport/bounds.d.ts.map +1 -0
- package/dist/v2/react-native/viewport/bounds.js +7 -0
- package/dist/v2/react-native/viewport/config.d.ts +13 -0
- package/dist/v2/react-native/viewport/config.d.ts.map +1 -0
- package/dist/v2/react-native/viewport/config.js +64 -0
- package/dist/v2/react-native/viewport/pan.d.ts +23 -0
- package/dist/v2/react-native/viewport/pan.d.ts.map +1 -0
- package/dist/v2/react-native/viewport/pan.js +110 -0
- package/dist/v2/react-native/viewport/pinchZoom.d.ts +17 -0
- package/dist/v2/react-native/viewport/pinchZoom.d.ts.map +1 -0
- package/dist/v2/react-native/viewport/pinchZoom.js +131 -0
- package/dist/v2/react-native/viewport/types.d.ts +55 -0
- package/dist/v2/react-native/viewport/types.d.ts.map +1 -0
- package/dist/v2/react-native/viewport/types.js +1 -0
- package/dist/v2/svg-renderer/capabilities.d.ts +3 -0
- package/dist/v2/svg-renderer/capabilities.d.ts.map +1 -0
- package/dist/v2/svg-renderer/capabilities.js +12 -0
- package/dist/v2/svg-renderer/clipPath.d.ts +4 -0
- package/dist/v2/svg-renderer/clipPath.d.ts.map +1 -0
- package/dist/v2/svg-renderer/clipPath.js +35 -0
- package/dist/v2/svg-renderer/defs.d.ts +6 -0
- package/dist/v2/svg-renderer/defs.d.ts.map +1 -0
- package/dist/v2/svg-renderer/defs.js +18 -0
- package/dist/v2/svg-renderer/ensureConsole.d.ts +4 -0
- package/dist/v2/svg-renderer/ensureConsole.d.ts.map +1 -0
- package/dist/v2/svg-renderer/ensureConsole.js +54 -0
- package/dist/v2/svg-renderer/hitRegions.d.ts +3 -0
- package/dist/v2/svg-renderer/hitRegions.d.ts.map +1 -0
- package/dist/v2/svg-renderer/hitRegions.js +6 -0
- package/dist/v2/svg-renderer/index.d.ts +14 -0
- package/dist/v2/svg-renderer/index.d.ts.map +1 -0
- package/dist/v2/svg-renderer/index.js +13 -0
- package/dist/v2/svg-renderer/layerOrder.d.ts +19 -0
- package/dist/v2/svg-renderer/layerOrder.d.ts.map +1 -0
- package/dist/v2/svg-renderer/layerOrder.js +18 -0
- package/dist/v2/svg-renderer/layers.d.ts +3 -0
- package/dist/v2/svg-renderer/layers.d.ts.map +1 -0
- package/dist/v2/svg-renderer/layers.js +4 -0
- package/dist/v2/svg-renderer/primitives.d.ts +12 -0
- package/dist/v2/svg-renderer/primitives.d.ts.map +1 -0
- package/dist/v2/svg-renderer/primitives.js +13 -0
- package/dist/v2/svg-renderer/renderer.d.ts +4 -0
- package/dist/v2/svg-renderer/renderer.d.ts.map +1 -0
- package/dist/v2/svg-renderer/renderer.js +24 -0
- package/dist/v2/svg-renderer/symbolGeometry.d.ts +6 -0
- package/dist/v2/svg-renderer/symbolGeometry.d.ts.map +1 -0
- package/dist/v2/svg-renderer/symbolGeometry.js +10 -0
- package/dist/v2/svg-renderer/symbols.d.ts +3 -0
- package/dist/v2/svg-renderer/symbols.d.ts.map +1 -0
- package/dist/v2/svg-renderer/symbols.js +23 -0
- package/dist/v2/svg-renderer/testIds.d.ts +2 -0
- package/dist/v2/svg-renderer/testIds.d.ts.map +1 -0
- package/dist/v2/svg-renderer/testIds.js +10 -0
- package/dist/v2/svg-renderer/textMeasurement.d.ts +4 -0
- package/dist/v2/svg-renderer/textMeasurement.d.ts.map +1 -0
- package/dist/v2/svg-renderer/textMeasurement.js +37 -0
- package/dist/v2/svg-renderer/types.d.ts +134 -0
- package/dist/v2/svg-renderer/types.d.ts.map +1 -0
- package/dist/v2/svg-renderer/types.js +1 -0
- package/package.json +56 -50
- package/v2/index.d.ts +1 -0
- package/v2/index.js +1 -0
- package/v2/package.json +6 -0
- package/scripts/chartkit-codemod.mjs +0 -256
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { resolveChartViewportWindowFromHandlePosition, resolveChartViewportWindowFromPosition } from "../../../core/index";
|
|
5
|
+
import { getLineChartRenderer } from "./renderer";
|
|
6
|
+
import { clamp } from "./utils";
|
|
7
|
+
export const LineChartRangeSelector = ({ config, dataLength, isVisible, model, onViewportChange, preventBrowserSelection, renderer: rendererProp, testID, viewportWindow, width }) => {
|
|
8
|
+
const interactionRef = useRef("move");
|
|
9
|
+
const rangeStartPoint = model.interactionPoints.find((point) => point.dataIndex === viewportWindow.startIndex);
|
|
10
|
+
const rangeEndPoint = model.interactionPoints.find((point) => point.dataIndex === Math.max(0, viewportWindow.endIndex - 1));
|
|
11
|
+
const windowX = rangeStartPoint?.x ?? model.boxes.plot.x;
|
|
12
|
+
const windowEndX = rangeEndPoint?.x ?? model.boxes.plot.x + model.boxes.plot.width;
|
|
13
|
+
const windowWidth = Math.max(10, windowEndX - windowX);
|
|
14
|
+
const emitViewportChange = useCallback((nextWindow, interaction) => {
|
|
15
|
+
onViewportChange?.({
|
|
16
|
+
viewport: {
|
|
17
|
+
startIndex: nextWindow.startIndex,
|
|
18
|
+
endIndex: nextWindow.endIndex
|
|
19
|
+
},
|
|
20
|
+
startIndex: nextWindow.startIndex,
|
|
21
|
+
endIndex: nextWindow.endIndex,
|
|
22
|
+
visibleCount: nextWindow.visibleCount,
|
|
23
|
+
itemCount: nextWindow.itemCount,
|
|
24
|
+
isWindowed: nextWindow.isWindowed,
|
|
25
|
+
source: "rangeSelector",
|
|
26
|
+
interaction
|
|
27
|
+
});
|
|
28
|
+
}, [onViewportChange]);
|
|
29
|
+
const isInteractive = isVisible && config.interactive && onViewportChange !== undefined;
|
|
30
|
+
const getInteraction = useCallback((locationX) => {
|
|
31
|
+
const handleHitSlop = Math.max(config.handleHitSlop, config.handleWidth * 2);
|
|
32
|
+
const startDistance = Math.abs(locationX - windowX);
|
|
33
|
+
const endDistance = Math.abs(locationX - windowEndX);
|
|
34
|
+
if (startDistance <= handleHitSlop && startDistance <= endDistance) {
|
|
35
|
+
return "resizeStart";
|
|
36
|
+
}
|
|
37
|
+
if (endDistance <= handleHitSlop) {
|
|
38
|
+
return "resizeEnd";
|
|
39
|
+
}
|
|
40
|
+
return "move";
|
|
41
|
+
}, [config.handleHitSlop, config.handleWidth, windowEndX, windowX]);
|
|
42
|
+
const handleInteraction = useCallback((event, interaction) => {
|
|
43
|
+
preventBrowserSelection(event);
|
|
44
|
+
if (!isInteractive) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const nextWindow = interaction === "move"
|
|
48
|
+
? resolveChartViewportWindowFromPosition({
|
|
49
|
+
itemCount: dataLength,
|
|
50
|
+
locationX: event.nativeEvent.locationX,
|
|
51
|
+
plotWidth: model.boxes.plot.width,
|
|
52
|
+
plotX: model.boxes.plot.x,
|
|
53
|
+
visibleCount: viewportWindow.visibleCount
|
|
54
|
+
})
|
|
55
|
+
: resolveChartViewportWindowFromHandlePosition({
|
|
56
|
+
currentWindow: viewportWindow,
|
|
57
|
+
handle: interaction === "resizeStart" ? "start" : "end",
|
|
58
|
+
itemCount: dataLength,
|
|
59
|
+
locationX: event.nativeEvent.locationX,
|
|
60
|
+
minVisibleCount: config.minVisiblePoints,
|
|
61
|
+
plotWidth: model.boxes.plot.width,
|
|
62
|
+
plotX: model.boxes.plot.x
|
|
63
|
+
});
|
|
64
|
+
if (nextWindow.startIndex === viewportWindow.startIndex &&
|
|
65
|
+
nextWindow.endIndex === viewportWindow.endIndex) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
emitViewportChange(nextWindow, interaction);
|
|
69
|
+
}, [
|
|
70
|
+
config.minVisiblePoints,
|
|
71
|
+
dataLength,
|
|
72
|
+
emitViewportChange,
|
|
73
|
+
isInteractive,
|
|
74
|
+
model.boxes.plot.width,
|
|
75
|
+
model.boxes.plot.x,
|
|
76
|
+
preventBrowserSelection,
|
|
77
|
+
viewportWindow
|
|
78
|
+
]);
|
|
79
|
+
const responderProps = isInteractive
|
|
80
|
+
? {
|
|
81
|
+
onStartShouldSetResponderCapture: () => true,
|
|
82
|
+
onMoveShouldSetResponderCapture: () => true,
|
|
83
|
+
onStartShouldSetResponder: () => true,
|
|
84
|
+
onMoveShouldSetResponder: () => true,
|
|
85
|
+
onResponderGrant: (event) => {
|
|
86
|
+
const interaction = getInteraction(event.nativeEvent.locationX);
|
|
87
|
+
interactionRef.current = interaction;
|
|
88
|
+
config.onGestureStart?.({ interaction });
|
|
89
|
+
handleInteraction(event, interaction);
|
|
90
|
+
},
|
|
91
|
+
onResponderMove: (event) => {
|
|
92
|
+
handleInteraction(event, interactionRef.current);
|
|
93
|
+
},
|
|
94
|
+
onResponderRelease: () => {
|
|
95
|
+
config.onGestureEnd?.({ interaction: interactionRef.current });
|
|
96
|
+
interactionRef.current = "move";
|
|
97
|
+
},
|
|
98
|
+
onResponderTerminate: () => {
|
|
99
|
+
config.onGestureEnd?.({ interaction: interactionRef.current });
|
|
100
|
+
interactionRef.current = "move";
|
|
101
|
+
},
|
|
102
|
+
onResponderTerminationRequest: () => false
|
|
103
|
+
}
|
|
104
|
+
: {};
|
|
105
|
+
if (!isVisible) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const plotX = model.boxes.plot.x;
|
|
109
|
+
const plotY = model.boxes.plot.y;
|
|
110
|
+
const plotWidth = model.boxes.plot.width;
|
|
111
|
+
const plotHeight = model.boxes.plot.height;
|
|
112
|
+
const handleWidth = config.handleWidth;
|
|
113
|
+
const handleColor = config.handleColor ?? config.windowStroke ?? model.resolvedTheme.axis;
|
|
114
|
+
const renderer = getLineChartRenderer(rendererProp);
|
|
115
|
+
const { Group, Path, Rect, Surface } = renderer;
|
|
116
|
+
const Layer = renderer.Layer ?? Group;
|
|
117
|
+
const handleMinX = model.boxes.plot.x;
|
|
118
|
+
const handleMaxX = model.boxes.plot.x + model.boxes.plot.width - handleWidth;
|
|
119
|
+
const startHandleX = clamp(windowX - handleWidth / 2, handleMinX, handleMaxX);
|
|
120
|
+
const endHandleX = clamp(windowEndX - handleWidth / 2, handleMinX, handleMaxX);
|
|
121
|
+
const handleHeight = Math.max(8, config.handleHeight ?? plotHeight - config.handleInset * 2);
|
|
122
|
+
const handleY = plotY + (plotHeight - handleHeight) / 2;
|
|
123
|
+
const handleRadius = config.handleRadius ?? handleWidth / 2;
|
|
124
|
+
const windowProps = {
|
|
125
|
+
x: windowX,
|
|
126
|
+
y: plotY,
|
|
127
|
+
width: windowWidth,
|
|
128
|
+
height: plotHeight,
|
|
129
|
+
radius: config.windowRadius,
|
|
130
|
+
fill: config.windowFill ?? model.resolvedTheme.axis,
|
|
131
|
+
opacity: config.windowOpacity,
|
|
132
|
+
stroke: config.windowStroke ?? model.resolvedTheme.axis,
|
|
133
|
+
strokeOpacity: config.windowStrokeOpacity,
|
|
134
|
+
strokeWidth: config.windowStrokeWidth,
|
|
135
|
+
theme: model.resolvedTheme
|
|
136
|
+
};
|
|
137
|
+
const renderWindow = () => config.renderWindow ? (config.renderWindow(windowProps)) : (_jsx(Rect, { x: windowProps.x, y: windowProps.y, width: windowProps.width, height: windowProps.height, rx: windowProps.radius, fill: windowProps.fill, opacity: windowProps.opacity, stroke: windowProps.stroke, strokeOpacity: windowProps.strokeOpacity, strokeWidth: windowProps.strokeWidth }));
|
|
138
|
+
const renderHandle = (side, x) => {
|
|
139
|
+
const handleProps = {
|
|
140
|
+
side,
|
|
141
|
+
x,
|
|
142
|
+
y: handleY,
|
|
143
|
+
width: handleWidth,
|
|
144
|
+
height: handleHeight,
|
|
145
|
+
radius: handleRadius,
|
|
146
|
+
color: handleColor,
|
|
147
|
+
opacity: config.handleOpacity,
|
|
148
|
+
theme: model.resolvedTheme,
|
|
149
|
+
window: windowProps
|
|
150
|
+
};
|
|
151
|
+
return config.renderHandle ? (config.renderHandle(handleProps)) : (_jsx(Rect, { x: handleProps.x, y: handleProps.y, width: handleProps.width, height: handleProps.height, rx: handleProps.radius, fill: handleProps.color, opacity: handleProps.opacity }));
|
|
152
|
+
};
|
|
153
|
+
const renderLine = (props) => config.renderLine ? (_jsx(Group, { children: config.renderLine(props) }, `range-line-${props.key}`)) : (_jsx(Path, { d: props.path, fill: "none", stroke: props.color, strokeLinecap: "round", strokeLinejoin: "round", strokeOpacity: props.opacity, strokeWidth: props.strokeWidth, ...(props.strokeDasharray
|
|
154
|
+
? { strokeDasharray: props.strokeDasharray }
|
|
155
|
+
: {}) }, `range-line-${props.key}`));
|
|
156
|
+
return (_jsxs(View, { collapsable: false, pointerEvents: isInteractive ? "auto" : "none", style: {
|
|
157
|
+
height: config.height,
|
|
158
|
+
marginTop: config.gap,
|
|
159
|
+
overflow: "hidden",
|
|
160
|
+
position: "relative",
|
|
161
|
+
width
|
|
162
|
+
}, testID: testID ? `${testID}-range-selector` : undefined, children: [_jsxs(Surface, { width: width, height: config.height, children: [_jsxs(Layer, { name: "background", children: [_jsx(Rect, { x: 0, y: 0, width: width, height: config.height, rx: 8, fill: config.backgroundFill ?? model.resolvedTheme.background }), _jsx(Rect, { x: plotX, y: plotY, width: plotWidth, height: plotHeight, rx: config.plotRadius, fill: config.plotFill ?? model.resolvedTheme.plotBackground })] }), _jsx(Layer, { name: "data", children: model.geometries.map(({ geometry, style }, index) => {
|
|
163
|
+
const seriesStyle = config.series?.[geometry.key];
|
|
164
|
+
const lineProps = {
|
|
165
|
+
color: seriesStyle?.color ?? style.color,
|
|
166
|
+
index,
|
|
167
|
+
key: geometry.key,
|
|
168
|
+
label: geometry.label,
|
|
169
|
+
opacity: seriesStyle?.opacity ?? config.lineOpacity,
|
|
170
|
+
path: geometry.line.path,
|
|
171
|
+
strokeDasharray: seriesStyle?.strokeDasharray,
|
|
172
|
+
strokeWidth: seriesStyle?.strokeWidth ??
|
|
173
|
+
config.lineStrokeWidth ??
|
|
174
|
+
Math.max(config.lineMinStrokeWidth, style.strokeWidth * config.lineStrokeWidthScale),
|
|
175
|
+
theme: model.resolvedTheme
|
|
176
|
+
};
|
|
177
|
+
return renderLine(lineProps);
|
|
178
|
+
}) }), _jsxs(Layer, { name: "overlays", children: [config.outsideOpacity > 0 ? (_jsxs(Group, { children: [_jsx(Rect, { x: plotX, y: plotY, width: Math.max(0, windowX - plotX), height: plotHeight, fill: config.outsideFill ?? model.resolvedTheme.background, opacity: config.outsideOpacity }, "range-selector-outside-start"), _jsx(Rect, { x: windowEndX, y: plotY, width: Math.max(0, plotX + plotWidth - windowEndX), height: plotHeight, fill: config.outsideFill ?? model.resolvedTheme.background, opacity: config.outsideOpacity }, "range-selector-outside-end")] }, "range-selector-outside")) : null, renderWindow(), isInteractive ? (_jsxs(Group, { children: [renderHandle("start", startHandleX), renderHandle("end", endHandleX)] }, "range-selector-handles")) : null] })] }), isInteractive ? (_jsx(View, { collapsable: false, pointerEvents: "auto", style: {
|
|
179
|
+
bottom: 0,
|
|
180
|
+
left: 0,
|
|
181
|
+
position: "absolute",
|
|
182
|
+
right: 0,
|
|
183
|
+
top: 0
|
|
184
|
+
}, ...responderProps })) : null] }));
|
|
185
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { LineChartProps } from "./types";
|
|
2
|
+
export declare const getRangeSelectorConfig: (rangeSelector: LineChartProps<Record<string, unknown>>["rangeSelector"]) => {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
height: number;
|
|
5
|
+
gap: number;
|
|
6
|
+
interactive: boolean;
|
|
7
|
+
minVisiblePoints: number;
|
|
8
|
+
backgroundFill: string | undefined;
|
|
9
|
+
plotFill: string | undefined;
|
|
10
|
+
plotRadius: number;
|
|
11
|
+
lineMinStrokeWidth: number;
|
|
12
|
+
lineStrokeWidth: number | undefined;
|
|
13
|
+
lineStrokeWidthScale: number;
|
|
14
|
+
series: Record<string, import("./types").LineChartRangeSelectorSeriesStyle> | undefined;
|
|
15
|
+
outsideFill: string | undefined;
|
|
16
|
+
outsideOpacity: number;
|
|
17
|
+
windowFill: string | undefined;
|
|
18
|
+
windowOpacity: number;
|
|
19
|
+
windowRadius: number;
|
|
20
|
+
windowStroke: string | undefined;
|
|
21
|
+
windowStrokeOpacity: number;
|
|
22
|
+
windowStrokeWidth: number;
|
|
23
|
+
lineOpacity: number;
|
|
24
|
+
handleColor: string | undefined;
|
|
25
|
+
handleHeight: number | undefined;
|
|
26
|
+
handleHitSlop: number;
|
|
27
|
+
handleInset: number;
|
|
28
|
+
handleOpacity: number;
|
|
29
|
+
handleRadius: number | undefined;
|
|
30
|
+
handleWidth: number;
|
|
31
|
+
renderHandle: ((props: import("./types").LineChartRangeSelectorHandleRenderProps) => import("react").ReactNode) | undefined;
|
|
32
|
+
renderLine: ((props: import("./types").LineChartRangeSelectorLineRenderProps) => import("react").ReactNode) | undefined;
|
|
33
|
+
renderWindow: ((props: import("./types").LineChartRangeSelectorWindowRenderProps) => import("react").ReactNode) | undefined;
|
|
34
|
+
onGestureEnd: ((event: import("./types").LineChartRangeSelectorGestureEvent) => void) | undefined;
|
|
35
|
+
onGestureStart: ((event: import("./types").LineChartRangeSelectorGestureEvent) => void) | undefined;
|
|
36
|
+
};
|
|
37
|
+
export type LineChartRangeSelectorResolvedConfig = ReturnType<typeof getRangeSelectorConfig>;
|
|
38
|
+
//# sourceMappingURL=rangeSelectorConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rangeSelectorConfig.d.ts","sourceRoot":"","sources":["../../../src/charts/line/rangeSelectorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,sBAAsB,GACjC,eAAe,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CxE,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG,UAAU,CAC3D,OAAO,sBAAsB,CAC9B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const getRangeSelectorConfig = (rangeSelector) => {
|
|
2
|
+
const config = typeof rangeSelector === "object" ? rangeSelector : {};
|
|
3
|
+
const visible = typeof rangeSelector === "boolean"
|
|
4
|
+
? rangeSelector
|
|
5
|
+
: rangeSelector !== undefined && config.visible !== false;
|
|
6
|
+
return {
|
|
7
|
+
visible,
|
|
8
|
+
height: config.height ?? 54,
|
|
9
|
+
gap: config.gap ?? 10,
|
|
10
|
+
interactive: config.interactive ?? false,
|
|
11
|
+
minVisiblePoints: config.minVisiblePoints ?? 2,
|
|
12
|
+
backgroundFill: config.backgroundFill,
|
|
13
|
+
plotFill: config.plotFill,
|
|
14
|
+
plotRadius: config.plotRadius ?? 6,
|
|
15
|
+
lineMinStrokeWidth: config.lineMinStrokeWidth ?? 1.5,
|
|
16
|
+
lineStrokeWidth: config.lineStrokeWidth,
|
|
17
|
+
lineStrokeWidthScale: config.lineStrokeWidthScale ?? 0.62,
|
|
18
|
+
series: config.series,
|
|
19
|
+
outsideFill: config.outsideFill,
|
|
20
|
+
outsideOpacity: config.outsideOpacity ?? 0,
|
|
21
|
+
windowFill: config.windowFill,
|
|
22
|
+
windowOpacity: config.windowOpacity ?? 0.1,
|
|
23
|
+
windowRadius: config.windowRadius ?? 6,
|
|
24
|
+
windowStroke: config.windowStroke,
|
|
25
|
+
windowStrokeOpacity: config.windowStrokeOpacity ?? 0.42,
|
|
26
|
+
windowStrokeWidth: config.windowStrokeWidth ?? 1,
|
|
27
|
+
lineOpacity: config.lineOpacity ?? 0.62,
|
|
28
|
+
handleColor: config.handleColor,
|
|
29
|
+
handleHeight: config.handleHeight,
|
|
30
|
+
handleHitSlop: config.handleHitSlop ?? 18,
|
|
31
|
+
handleInset: config.handleInset ?? 6,
|
|
32
|
+
handleOpacity: config.handleOpacity ?? 0.9,
|
|
33
|
+
handleRadius: config.handleRadius,
|
|
34
|
+
handleWidth: config.handleWidth ?? 3,
|
|
35
|
+
renderHandle: config.renderHandle,
|
|
36
|
+
renderLine: config.renderLine,
|
|
37
|
+
renderWindow: config.renderWindow,
|
|
38
|
+
onGestureEnd: config.onGestureEnd,
|
|
39
|
+
onGestureStart: config.onGestureStart
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GeometryPoint, Rect } from "../../../core/index";
|
|
2
|
+
import type { LineChartReferenceLabelPlacement } from "./types";
|
|
3
|
+
export type ReferenceCollisionGeometry = {
|
|
4
|
+
line: {
|
|
5
|
+
segments: Array<{
|
|
6
|
+
points: GeometryPoint[];
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const resolveReferenceLineLabelY: ({ geometries, labelOffset, labelPlacement, lineY, plot, text, textAnchor, fontSize, x }: {
|
|
11
|
+
geometries: ReferenceCollisionGeometry[] | undefined;
|
|
12
|
+
labelOffset: number;
|
|
13
|
+
labelPlacement: LineChartReferenceLabelPlacement | undefined;
|
|
14
|
+
lineY: number;
|
|
15
|
+
plot: Rect;
|
|
16
|
+
text: string;
|
|
17
|
+
textAnchor: "middle" | "start" | "end";
|
|
18
|
+
fontSize: number;
|
|
19
|
+
x: number;
|
|
20
|
+
}) => number;
|
|
21
|
+
//# sourceMappingURL=referenceLabelPlacement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referenceLabelPlacement.d.ts","sourceRoot":"","sources":["../../../src/charts/line/referenceLabelPlacement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAKhE,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE;QACJ,QAAQ,EAAE,KAAK,CAAC;YACd,MAAM,EAAE,aAAa,EAAE,CAAC;SACzB,CAAC,CAAC;KACJ,CAAC;CACH,CAAC;AAuMF,eAAO,MAAM,0BAA0B,GAAI,yFAUxC;IACD,UAAU,EAAE,0BAA0B,EAAE,GAAG,SAAS,CAAC;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,gCAAgC,GAAG,SAAS,CAAC;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,WAoBA,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const referenceLabelSeriesPadding = 10;
|
|
2
|
+
const referenceLabelSpacing = 3;
|
|
3
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
4
|
+
const estimateReferenceLabelWidth = (text, fontSize) => Math.max(fontSize, text.length * fontSize * 0.56);
|
|
5
|
+
const getReferenceLabelBox = ({ fontSize, text, textAnchor, x, y }) => {
|
|
6
|
+
const width = estimateReferenceLabelWidth(text, fontSize);
|
|
7
|
+
const left = textAnchor === "middle"
|
|
8
|
+
? x - width / 2
|
|
9
|
+
: textAnchor === "end"
|
|
10
|
+
? x - width
|
|
11
|
+
: x;
|
|
12
|
+
return {
|
|
13
|
+
x: left,
|
|
14
|
+
y: y - fontSize,
|
|
15
|
+
width,
|
|
16
|
+
height: fontSize
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const expandBox = (box, padding) => ({
|
|
20
|
+
x: box.x - padding,
|
|
21
|
+
y: box.y - padding,
|
|
22
|
+
width: box.width + padding * 2,
|
|
23
|
+
height: box.height + padding * 2
|
|
24
|
+
});
|
|
25
|
+
const containsPoint = (box, point) => point.x >= box.x &&
|
|
26
|
+
point.x <= box.x + box.width &&
|
|
27
|
+
point.y >= box.y &&
|
|
28
|
+
point.y <= box.y + box.height;
|
|
29
|
+
const orientation = (a, b, c) => (b.y - a.y) * (c.x - b.x) - (b.x - a.x) * (c.y - b.y);
|
|
30
|
+
const isBetween = (value, start, end) => value >= Math.min(start, end) && value <= Math.max(start, end);
|
|
31
|
+
const segmentsIntersect = (a, b, c, d) => {
|
|
32
|
+
const first = orientation(a, b, c);
|
|
33
|
+
const second = orientation(a, b, d);
|
|
34
|
+
const third = orientation(c, d, a);
|
|
35
|
+
const fourth = orientation(c, d, b);
|
|
36
|
+
if (first === 0 && isBetween(c.x, a.x, b.x) && isBetween(c.y, a.y, b.y)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (second === 0 && isBetween(d.x, a.x, b.x) && isBetween(d.y, a.y, b.y)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (third === 0 && isBetween(a.x, c.x, d.x) && isBetween(a.y, c.y, d.y)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
if (fourth === 0 && isBetween(b.x, c.x, d.x) && isBetween(b.y, c.y, d.y)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return first > 0 !== second > 0 && third > 0 !== fourth > 0;
|
|
49
|
+
};
|
|
50
|
+
const segmentIntersectsBox = (start, end, box) => {
|
|
51
|
+
if (containsPoint(box, start) || containsPoint(box, end)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
const left = box.x;
|
|
55
|
+
const right = box.x + box.width;
|
|
56
|
+
const top = box.y;
|
|
57
|
+
const bottom = box.y + box.height;
|
|
58
|
+
const topLeft = { x: left, y: top };
|
|
59
|
+
const topRight = { x: right, y: top };
|
|
60
|
+
const bottomRight = { x: right, y: bottom };
|
|
61
|
+
const bottomLeft = { x: left, y: bottom };
|
|
62
|
+
return (segmentsIntersect(start, end, topLeft, topRight) ||
|
|
63
|
+
segmentsIntersect(start, end, topRight, bottomRight) ||
|
|
64
|
+
segmentsIntersect(start, end, bottomRight, bottomLeft) ||
|
|
65
|
+
segmentsIntersect(start, end, bottomLeft, topLeft));
|
|
66
|
+
};
|
|
67
|
+
const collidesWithSeries = (box, geometries) => {
|
|
68
|
+
if (!geometries || geometries.length === 0) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const paddedBox = expandBox(box, referenceLabelSeriesPadding);
|
|
72
|
+
return geometries.some((geometry) => geometry.line.segments.some((segment) => segment.points.some((point, index) => {
|
|
73
|
+
const next = segment.points[index + 1];
|
|
74
|
+
return next ? segmentIntersectsBox(point, next, paddedBox) : false;
|
|
75
|
+
})));
|
|
76
|
+
};
|
|
77
|
+
const getReferenceLabelCandidate = ({ geometries, labelOffset, labelPlacement, lineY, plot, text, textAnchor, fontSize, x }) => {
|
|
78
|
+
const plotBottom = plot.y + plot.height;
|
|
79
|
+
const desiredY = labelPlacement === "above"
|
|
80
|
+
? lineY - labelOffset
|
|
81
|
+
: lineY + fontSize + labelOffset;
|
|
82
|
+
const y = clamp(desiredY, plot.y + fontSize, plotBottom - referenceLabelSpacing);
|
|
83
|
+
const box = getReferenceLabelBox({ fontSize, text, textAnchor, x, y });
|
|
84
|
+
const overflow = Math.max(0, plot.y - box.y) + Math.max(0, box.y + box.height - plotBottom);
|
|
85
|
+
const lineCollision = lineY >= box.y - referenceLabelSpacing &&
|
|
86
|
+
lineY <= box.y + box.height + referenceLabelSpacing;
|
|
87
|
+
const seriesCollision = collidesWithSeries(box, geometries);
|
|
88
|
+
return {
|
|
89
|
+
box,
|
|
90
|
+
y,
|
|
91
|
+
score: (labelPlacement === "below" ? 1 : 0) +
|
|
92
|
+
overflow * 20 +
|
|
93
|
+
(lineCollision ? 200 : 0) +
|
|
94
|
+
(seriesCollision ? 100 : 0)
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export const resolveReferenceLineLabelY = ({ geometries, labelOffset, labelPlacement, lineY, plot, text, textAnchor, fontSize, x }) => {
|
|
98
|
+
const placements = labelPlacement === "above" || labelPlacement === "below"
|
|
99
|
+
? [labelPlacement]
|
|
100
|
+
: ["above", "below"];
|
|
101
|
+
const candidates = placements.map((placement) => getReferenceLabelCandidate({
|
|
102
|
+
geometries,
|
|
103
|
+
labelOffset,
|
|
104
|
+
labelPlacement: placement,
|
|
105
|
+
lineY,
|
|
106
|
+
plot,
|
|
107
|
+
text,
|
|
108
|
+
textAnchor,
|
|
109
|
+
fontSize,
|
|
110
|
+
x
|
|
111
|
+
}));
|
|
112
|
+
return candidates.sort((a, b) => a.score - b.score)[0]?.y ?? lineY;
|
|
113
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { LinearScale, Rect } from "../../../core/index";
|
|
2
|
+
import type { ResolvedCartesianChartTheme } from "../../theme";
|
|
3
|
+
import { type ReferenceCollisionGeometry } from "./referenceLabelPlacement";
|
|
4
|
+
import type { LineChartReferenceBandConfig, LineChartReferenceLineConfig } from "./types";
|
|
5
|
+
export type LineChartReferenceLabelContainerModel = {
|
|
6
|
+
backgroundColor: string;
|
|
7
|
+
borderRadius: number;
|
|
8
|
+
opacity: number;
|
|
9
|
+
paddingX: number;
|
|
10
|
+
paddingY: number;
|
|
11
|
+
};
|
|
12
|
+
export type LineChartReferenceLineModel = {
|
|
13
|
+
key: string;
|
|
14
|
+
x1: number;
|
|
15
|
+
x2: number;
|
|
16
|
+
y: number;
|
|
17
|
+
color: string;
|
|
18
|
+
opacity: number;
|
|
19
|
+
strokeDasharray?: readonly number[];
|
|
20
|
+
strokeWidth: number;
|
|
21
|
+
label?: {
|
|
22
|
+
text: string;
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
color: string;
|
|
26
|
+
container?: LineChartReferenceLabelContainerModel;
|
|
27
|
+
fontSize: number;
|
|
28
|
+
textAnchor: "middle" | "start" | "end";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type LineChartReferenceBandModel = {
|
|
32
|
+
key: string;
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
color: string;
|
|
38
|
+
opacity: number;
|
|
39
|
+
label?: {
|
|
40
|
+
text: string;
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
color: string;
|
|
44
|
+
container?: LineChartReferenceLabelContainerModel;
|
|
45
|
+
fontSize: number;
|
|
46
|
+
textAnchor: "middle" | "start" | "end";
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare const buildLineChartReferenceLineModels: ({ geometries, lines, plot, theme, yScale }: {
|
|
50
|
+
geometries?: ReferenceCollisionGeometry[] | undefined;
|
|
51
|
+
lines: LineChartReferenceLineConfig[] | undefined;
|
|
52
|
+
plot: Rect;
|
|
53
|
+
theme: ResolvedCartesianChartTheme;
|
|
54
|
+
yScale: LinearScale;
|
|
55
|
+
}) => LineChartReferenceLineModel[];
|
|
56
|
+
export declare const buildLineChartReferenceBandModels: ({ bands, plot, theme, yScale }: {
|
|
57
|
+
bands: LineChartReferenceBandConfig[] | undefined;
|
|
58
|
+
plot: Rect;
|
|
59
|
+
theme: ResolvedCartesianChartTheme;
|
|
60
|
+
yScale: LinearScale;
|
|
61
|
+
}) => LineChartReferenceBandModel[];
|
|
62
|
+
//# sourceMappingURL=references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../src/charts/line/references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,4BAA4B,EAG5B,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,qCAAqC,GAAG;IAClD,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,qCAAqC,CAAC;QAClD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;KACxC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,qCAAqC,CAAC;QAClD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;KACxC,CAAC;CACH,CAAC;AAgGF,eAAO,MAAM,iCAAiC,GAAI,4CAM/C;IACD,UAAU,CAAC,EAAE,0BAA0B,EAAE,GAAG,SAAS,CAAC;IACtD,KAAK,EAAE,4BAA4B,EAAE,GAAG,SAAS,CAAC;IAClD,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,2BAA2B,CAAC;IACnC,MAAM,EAAE,WAAW,CAAC;CACrB,KAAG,2BAA2B,EAwE9B,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAAI,gCAK/C;IACD,KAAK,EAAE,4BAA4B,EAAE,GAAG,SAAS,CAAC;IAClD,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,2BAA2B,CAAC;IACnC,MAAM,EAAE,WAAW,CAAC;CACrB,KAAG,2BAA2B,EA8D9B,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { resolveReferenceLineLabelY } from "./referenceLabelPlacement";
|
|
2
|
+
const defaultReferenceLineOpacity = 0.86;
|
|
3
|
+
const defaultReferenceBandOpacity = 0.1;
|
|
4
|
+
const defaultReferenceLabelContainerBorderRadius = 4;
|
|
5
|
+
const defaultReferenceLabelContainerOpacity = 0.9;
|
|
6
|
+
const defaultReferenceLabelContainerPaddingX = 3;
|
|
7
|
+
const defaultReferenceLabelContainerPaddingY = 2;
|
|
8
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
9
|
+
const resolveOpacity = (value, fallback) => typeof value === "number" && Number.isFinite(value)
|
|
10
|
+
? clamp(value, 0, 1)
|
|
11
|
+
: fallback;
|
|
12
|
+
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
13
|
+
const resolveFiniteNumber = (value, fallback) => typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
14
|
+
const resolveReferenceLabelContainer = ({ container, theme }) => {
|
|
15
|
+
if (!container) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const config = typeof container === "object" ? container : {};
|
|
19
|
+
return {
|
|
20
|
+
backgroundColor: config.backgroundColor ?? theme.plotBackground,
|
|
21
|
+
borderRadius: Math.max(0, resolveFiniteNumber(config.borderRadius, defaultReferenceLabelContainerBorderRadius)),
|
|
22
|
+
opacity: resolveOpacity(config.opacity, defaultReferenceLabelContainerOpacity),
|
|
23
|
+
paddingX: Math.max(0, resolveFiniteNumber(config.paddingX, defaultReferenceLabelContainerPaddingX)),
|
|
24
|
+
paddingY: Math.max(0, resolveFiniteNumber(config.paddingY, defaultReferenceLabelContainerPaddingY))
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const getTextAnchor = (position) => {
|
|
28
|
+
if (position === "start") {
|
|
29
|
+
return "start";
|
|
30
|
+
}
|
|
31
|
+
if (position === "center") {
|
|
32
|
+
return "middle";
|
|
33
|
+
}
|
|
34
|
+
return "end";
|
|
35
|
+
};
|
|
36
|
+
const getReferenceLabelX = ({ plot, position }) => {
|
|
37
|
+
if (position === "start") {
|
|
38
|
+
return plot.x + 8;
|
|
39
|
+
}
|
|
40
|
+
if (position === "center") {
|
|
41
|
+
return plot.x + plot.width / 2;
|
|
42
|
+
}
|
|
43
|
+
return plot.x + plot.width - 8;
|
|
44
|
+
};
|
|
45
|
+
export const buildLineChartReferenceLineModels = ({ geometries, lines, plot, theme, yScale }) => {
|
|
46
|
+
if (!lines || lines.length === 0) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const plotBottom = plot.y + plot.height;
|
|
50
|
+
return lines.flatMap((line, index) => {
|
|
51
|
+
if (!isFiniteNumber(line.y)) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const y = yScale.scale(line.y);
|
|
55
|
+
if (y < plot.y || y > plotBottom) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
const labelPosition = line.labelPosition ?? "end";
|
|
59
|
+
const labelFontSize = typeof line.labelFontSize === "number" && line.labelFontSize > 0
|
|
60
|
+
? line.labelFontSize
|
|
61
|
+
: theme.typography.axisLabelSize;
|
|
62
|
+
const labelOffset = typeof line.labelOffset === "number" && Number.isFinite(line.labelOffset)
|
|
63
|
+
? line.labelOffset
|
|
64
|
+
: 6;
|
|
65
|
+
const model = {
|
|
66
|
+
key: `reference-line-${index}-${line.y}`,
|
|
67
|
+
x1: plot.x,
|
|
68
|
+
x2: plot.x + plot.width,
|
|
69
|
+
y,
|
|
70
|
+
color: line.color ?? theme.mutedText,
|
|
71
|
+
opacity: resolveOpacity(line.opacity, defaultReferenceLineOpacity),
|
|
72
|
+
strokeWidth: line.strokeWidth ?? 1
|
|
73
|
+
};
|
|
74
|
+
if (line.strokeDasharray !== undefined) {
|
|
75
|
+
model.strokeDasharray = line.strokeDasharray;
|
|
76
|
+
}
|
|
77
|
+
if (line.label) {
|
|
78
|
+
const textAnchor = getTextAnchor(labelPosition);
|
|
79
|
+
const labelX = getReferenceLabelX({ plot, position: labelPosition });
|
|
80
|
+
const labelContainer = resolveReferenceLabelContainer({
|
|
81
|
+
container: line.labelContainer,
|
|
82
|
+
theme
|
|
83
|
+
});
|
|
84
|
+
model.label = {
|
|
85
|
+
text: line.label,
|
|
86
|
+
x: labelX,
|
|
87
|
+
y: resolveReferenceLineLabelY({
|
|
88
|
+
geometries,
|
|
89
|
+
labelOffset,
|
|
90
|
+
labelPlacement: line.labelPlacement,
|
|
91
|
+
lineY: y,
|
|
92
|
+
plot,
|
|
93
|
+
text: line.label,
|
|
94
|
+
textAnchor,
|
|
95
|
+
fontSize: labelFontSize,
|
|
96
|
+
x: labelX
|
|
97
|
+
}),
|
|
98
|
+
color: line.labelColor ?? line.color ?? theme.mutedText,
|
|
99
|
+
...(labelContainer !== undefined ? { container: labelContainer } : {}),
|
|
100
|
+
fontSize: labelFontSize,
|
|
101
|
+
textAnchor
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return [model];
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
export const buildLineChartReferenceBandModels = ({ bands, plot, theme, yScale }) => {
|
|
108
|
+
if (!bands || bands.length === 0) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
const plotBottom = plot.y + plot.height;
|
|
112
|
+
return bands.flatMap((band, index) => {
|
|
113
|
+
if (!isFiniteNumber(band.y1) || !isFiniteNumber(band.y2)) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
const yA = yScale.scale(band.y1);
|
|
117
|
+
const yB = yScale.scale(band.y2);
|
|
118
|
+
const top = Math.min(yA, yB);
|
|
119
|
+
const bottom = Math.max(yA, yB);
|
|
120
|
+
const clampedTop = clamp(top, plot.y, plotBottom);
|
|
121
|
+
const clampedBottom = clamp(bottom, plot.y, plotBottom);
|
|
122
|
+
const height = clampedBottom - clampedTop;
|
|
123
|
+
if (height <= 0.5) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
const labelPosition = band.labelPosition ?? "start";
|
|
127
|
+
const labelFontSize = typeof band.labelFontSize === "number" && band.labelFontSize > 0
|
|
128
|
+
? band.labelFontSize
|
|
129
|
+
: theme.typography.axisLabelSize;
|
|
130
|
+
const model = {
|
|
131
|
+
key: `reference-band-${index}-${band.y1}-${band.y2}`,
|
|
132
|
+
x: plot.x,
|
|
133
|
+
y: clampedTop,
|
|
134
|
+
width: plot.width,
|
|
135
|
+
height,
|
|
136
|
+
color: band.color ?? theme.series[0] ?? theme.grid,
|
|
137
|
+
opacity: resolveOpacity(band.opacity, defaultReferenceBandOpacity)
|
|
138
|
+
};
|
|
139
|
+
if (band.label) {
|
|
140
|
+
const labelContainer = resolveReferenceLabelContainer({
|
|
141
|
+
container: band.labelContainer,
|
|
142
|
+
theme
|
|
143
|
+
});
|
|
144
|
+
model.label = {
|
|
145
|
+
text: band.label,
|
|
146
|
+
x: getReferenceLabelX({ plot, position: labelPosition }),
|
|
147
|
+
y: clamp(clampedTop + labelFontSize + 6, plot.y + labelFontSize, plotBottom - 4),
|
|
148
|
+
color: band.labelColor ?? band.color ?? theme.mutedText,
|
|
149
|
+
...(labelContainer !== undefined ? { container: labelContainer } : {}),
|
|
150
|
+
fontSize: labelFontSize,
|
|
151
|
+
textAnchor: getTextAnchor(labelPosition)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return [model];
|
|
155
|
+
});
|
|
156
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/charts/line/renderer.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,oBAAoB,EAAE,iBAoBlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAU,iBAAiB,GAAG,SAAS,sBAC1C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvgClipRect, SvgCircle, SvgDefs, SvgGroup, SvgLayer, SvgLine, SvgLinearGradientDef, SvgPath, SvgRect, SvgSurface, SvgText } from "../../../svg-renderer/index";
|
|
2
|
+
export const lineChartSvgRenderer = {
|
|
3
|
+
ClipRect: SvgClipRect,
|
|
4
|
+
Circle: SvgCircle,
|
|
5
|
+
Defs: SvgDefs,
|
|
6
|
+
Group: SvgGroup,
|
|
7
|
+
Layer: SvgLayer,
|
|
8
|
+
Line: SvgLine,
|
|
9
|
+
LinearGradient: SvgLinearGradientDef,
|
|
10
|
+
Path: SvgPath,
|
|
11
|
+
Rect: SvgRect,
|
|
12
|
+
Surface: SvgSurface,
|
|
13
|
+
Text: SvgText,
|
|
14
|
+
capabilities: {
|
|
15
|
+
clipPaths: true,
|
|
16
|
+
gradients: true,
|
|
17
|
+
pathGradients: false,
|
|
18
|
+
rectClips: false,
|
|
19
|
+
text: true
|
|
20
|
+
},
|
|
21
|
+
name: "svg"
|
|
22
|
+
};
|
|
23
|
+
export const getLineChartRenderer = (renderer) => renderer ?? lineChartSvgRenderer;
|