@lobehub/charts 5.7.0 → 5.7.2
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/es/AccuracyBarChart/index.d.mts +62 -0
- package/es/AccuracyBarChart/index.mjs +326 -0
- package/es/AccuracyBarChart/index.mjs.map +1 -0
- package/es/AccuracyBarChart/styles.d.mts +14 -0
- package/es/AccuracyBarChart/styles.mjs +71 -0
- package/es/AccuracyBarChart/styles.mjs.map +1 -0
- package/es/AreaChart/index.d.mts +13 -0
- package/es/AreaChart/index.mjs +308 -0
- package/es/AreaChart/index.mjs.map +1 -0
- package/es/AreaChart/styles.d.mts +9 -0
- package/es/AreaChart/styles.mjs +28 -0
- package/es/AreaChart/styles.mjs.map +1 -0
- package/es/BarChart/index.d.mts +11 -0
- package/es/BarChart/index.mjs +290 -0
- package/es/BarChart/index.mjs.map +1 -0
- package/es/BarChart/{renderShape.d.ts → renderShape.d.mts} +3 -1
- package/es/BarChart/renderShape.mjs +28 -0
- package/es/BarChart/renderShape.mjs.map +1 -0
- package/es/BarChart/styles.d.mts +9 -0
- package/es/BarChart/styles.mjs +28 -0
- package/es/BarChart/styles.mjs.map +1 -0
- package/es/BarList/index.d.mts +32 -0
- package/es/BarList/index.mjs +128 -0
- package/es/BarList/index.mjs.map +1 -0
- package/es/BarList/styles.d.mts +13 -0
- package/es/BarList/styles.mjs +63 -0
- package/es/BarList/styles.mjs.map +1 -0
- package/es/BenchmarkColumnChart/index.d.mts +144 -0
- package/es/BenchmarkColumnChart/index.mjs +514 -0
- package/es/BenchmarkColumnChart/index.mjs.map +1 -0
- package/es/BenchmarkColumnChart/styles.d.mts +19 -0
- package/es/BenchmarkColumnChart/styles.mjs +129 -0
- package/es/BenchmarkColumnChart/styles.mjs.map +1 -0
- package/es/BenchmarkRankingChart/index.d.mts +91 -0
- package/es/BenchmarkRankingChart/index.mjs +347 -0
- package/es/BenchmarkRankingChart/index.mjs.map +1 -0
- package/es/BenchmarkRankingChart/styles.d.mts +36 -0
- package/es/BenchmarkRankingChart/styles.mjs +265 -0
- package/es/BenchmarkRankingChart/styles.mjs.map +1 -0
- package/es/BenchmarkScatterChart/index.d.mts +148 -0
- package/es/BenchmarkScatterChart/index.mjs +668 -0
- package/es/BenchmarkScatterChart/index.mjs.map +1 -0
- package/es/BenchmarkScatterChart/styles.d.mts +28 -0
- package/es/BenchmarkScatterChart/styles.mjs +193 -0
- package/es/BenchmarkScatterChart/styles.mjs.map +1 -0
- package/es/BenchmarkScatterChart/{utils.d.ts → utils.d.mts} +32 -29
- package/es/BenchmarkScatterChart/utils.mjs +214 -0
- package/es/BenchmarkScatterChart/utils.mjs.map +1 -0
- package/es/ComposedChart/index.d.mts +6 -0
- package/es/ComposedChart/index.mjs +254 -0
- package/es/ComposedChart/index.mjs.map +1 -0
- package/es/ComposedChart/styles.d.mts +9 -0
- package/es/ComposedChart/styles.mjs +28 -0
- package/es/ComposedChart/styles.mjs.map +1 -0
- package/es/ComposedChart/types.d.mts +71 -0
- package/es/ComposedChart/types.mjs +0 -0
- package/es/DataBars/CategoryBar.d.mts +17 -0
- package/es/DataBars/CategoryBar.mjs +146 -0
- package/es/DataBars/CategoryBar.mjs.map +1 -0
- package/es/DataBars/DeltaBar.d.mts +16 -0
- package/es/DataBars/DeltaBar.mjs +102 -0
- package/es/DataBars/DeltaBar.mjs.map +1 -0
- package/es/DataBars/MarkerBar.d.mts +19 -0
- package/es/DataBars/MarkerBar.mjs +74 -0
- package/es/DataBars/MarkerBar.mjs.map +1 -0
- package/es/DataBars/ProgressBar.d.mts +15 -0
- package/es/DataBars/ProgressBar.mjs +53 -0
- package/es/DataBars/ProgressBar.mjs.map +1 -0
- package/es/DataBars/index.d.mts +5 -0
- package/es/DataBars/index.mjs +5 -0
- package/es/DataBars/styles.d.mts +10 -0
- package/es/DataBars/styles.mjs +31 -0
- package/es/DataBars/styles.mjs.map +1 -0
- package/es/DonutChart/DonutChartTooltip.d.mts +14 -0
- package/es/DonutChart/DonutChartTooltip.mjs +25 -0
- package/es/DonutChart/DonutChartTooltip.mjs.map +1 -0
- package/es/DonutChart/index.d.mts +33 -0
- package/es/DonutChart/index.mjs +160 -0
- package/es/DonutChart/index.mjs.map +1 -0
- package/es/DonutChart/inputParser.d.mts +5 -0
- package/es/DonutChart/inputParser.mjs +8 -0
- package/es/DonutChart/inputParser.mjs.map +1 -0
- package/es/DonutChart/renderInactiveShape.d.mts +4 -0
- package/es/DonutChart/renderInactiveShape.mjs +22 -0
- package/es/DonutChart/renderInactiveShape.mjs.map +1 -0
- package/es/DonutChart/styles.d.mts +9 -0
- package/es/DonutChart/styles.mjs +28 -0
- package/es/DonutChart/styles.mjs.map +1 -0
- package/es/FunnelChart/ArrowRightIcon.d.mts +8 -0
- package/es/FunnelChart/ArrowRightIcon.mjs +14 -0
- package/es/FunnelChart/ArrowRightIcon.mjs.map +1 -0
- package/es/FunnelChart/index.d.mts +21 -0
- package/es/FunnelChart/index.mjs +421 -0
- package/es/FunnelChart/index.mjs.map +1 -0
- package/es/FunnelChart/styles.d.mts +9 -0
- package/es/FunnelChart/styles.mjs +28 -0
- package/es/FunnelChart/styles.mjs.map +1 -0
- package/es/FunnelChart/types.d.mts +31 -0
- package/es/FunnelChart/types.mjs +0 -0
- package/es/Heatmaps/Calendar.d.mts +21 -0
- package/es/Heatmaps/Calendar.mjs +108 -0
- package/es/Heatmaps/Calendar.mjs.map +1 -0
- package/es/Heatmaps/ChartLabels.d.mts +17 -0
- package/es/Heatmaps/ChartLabels.mjs +84 -0
- package/es/Heatmaps/ChartLabels.mjs.map +1 -0
- package/es/Heatmaps/Footer.d.mts +24 -0
- package/es/Heatmaps/Footer.mjs +81 -0
- package/es/Heatmaps/Footer.mjs.map +1 -0
- package/es/Heatmaps/index.d.mts +31 -0
- package/es/Heatmaps/index.mjs +188 -0
- package/es/Heatmaps/index.mjs.map +1 -0
- package/es/Heatmaps/styles.d.mts +10 -0
- package/es/Heatmaps/styles.mjs +47 -0
- package/es/Heatmaps/styles.mjs.map +1 -0
- package/es/Legend/LegendItem.d.mts +12 -0
- package/es/Legend/LegendItem.mjs +65 -0
- package/es/Legend/LegendItem.mjs.map +1 -0
- package/es/Legend/ScrollButton.d.mts +11 -0
- package/es/Legend/ScrollButton.mjs +50 -0
- package/es/Legend/ScrollButton.mjs.map +1 -0
- package/es/Legend/index.d.mts +16 -0
- package/es/Legend/index.mjs +152 -0
- package/es/Legend/index.mjs.map +1 -0
- package/es/LineChart/index.d.mts +11 -0
- package/es/LineChart/index.mjs +271 -0
- package/es/LineChart/index.mjs.map +1 -0
- package/es/LineChart/styles.d.mts +9 -0
- package/es/LineChart/styles.mjs +28 -0
- package/es/LineChart/styles.mjs.map +1 -0
- package/es/RadarChart/index.d.mts +27 -0
- package/es/RadarChart/index.mjs +157 -0
- package/es/RadarChart/index.mjs.map +1 -0
- package/es/RadarChart/styles.d.mts +8 -0
- package/es/RadarChart/styles.mjs +23 -0
- package/es/RadarChart/styles.mjs.map +1 -0
- package/es/ScatterChart/ScatterChartTooltip.d.mts +19 -0
- package/es/ScatterChart/ScatterChartTooltip.mjs +52 -0
- package/es/ScatterChart/ScatterChartTooltip.mjs.map +1 -0
- package/es/ScatterChart/ScatterChartTooltipRow.d.mts +10 -0
- package/es/ScatterChart/ScatterChartTooltipRow.mjs +36 -0
- package/es/ScatterChart/ScatterChartTooltipRow.mjs.map +1 -0
- package/es/ScatterChart/index.d.mts +58 -0
- package/es/ScatterChart/index.mjs +241 -0
- package/es/ScatterChart/index.mjs.map +1 -0
- package/es/ScatterChart/{renderShape.d.ts → renderShape.d.mts} +4 -1
- package/es/ScatterChart/renderShape.mjs +18 -0
- package/es/ScatterChart/renderShape.mjs.map +1 -0
- package/es/ScatterChart/styles.d.mts +9 -0
- package/es/ScatterChart/styles.mjs +28 -0
- package/es/ScatterChart/styles.mjs.map +1 -0
- package/es/SparkChart/SparkAreaChart.d.mts +14 -0
- package/es/SparkChart/SparkAreaChart.mjs +109 -0
- package/es/SparkChart/SparkAreaChart.mjs.map +1 -0
- package/es/SparkChart/SparkBarChart.d.mts +11 -0
- package/es/SparkChart/SparkBarChart.mjs +69 -0
- package/es/SparkChart/SparkBarChart.mjs.map +1 -0
- package/es/SparkChart/SparkLineChart.d.mts +12 -0
- package/es/SparkChart/SparkLineChart.mjs +73 -0
- package/es/SparkChart/SparkLineChart.mjs.map +1 -0
- package/es/SparkChart/index.d.mts +4 -0
- package/es/SparkChart/index.mjs +4 -0
- package/es/Tracker/TrackerBlock.d.mts +11 -0
- package/es/Tracker/TrackerBlock.mjs +52 -0
- package/es/Tracker/TrackerBlock.mjs.map +1 -0
- package/es/Tracker/index.d.mts +21 -0
- package/es/Tracker/index.mjs +69 -0
- package/es/Tracker/index.mjs.map +1 -0
- package/es/Tracker/styles.d.mts +8 -0
- package/es/Tracker/styles.mjs +24 -0
- package/es/Tracker/styles.mjs.map +1 -0
- package/es/common/BaseAnimationTimingProps.d.mts +10 -0
- package/es/common/BaseAnimationTimingProps.mjs +0 -0
- package/es/common/BaseChartProps.d.mts +61 -0
- package/es/common/BaseChartProps.mjs +0 -0
- package/es/common/BaseSparkChartProps.d.mts +17 -0
- package/es/common/BaseSparkChartProps.mjs +0 -0
- package/es/common/ChartLegend.d.mts +8 -0
- package/es/common/ChartLegend.mjs +32 -0
- package/es/common/ChartLegend.mjs.map +1 -0
- package/es/common/ChartTooltip/ChartTooltipFrame.d.mts +8 -0
- package/es/common/ChartTooltip/ChartTooltipFrame.mjs +27 -0
- package/es/common/ChartTooltip/ChartTooltipFrame.mjs.map +1 -0
- package/es/common/ChartTooltip/ChartTooltipRow.d.mts +10 -0
- package/es/common/ChartTooltip/ChartTooltipRow.mjs +51 -0
- package/es/common/ChartTooltip/ChartTooltipRow.mjs.map +1 -0
- package/es/common/ChartTooltip/index.d.mts +18 -0
- package/es/common/ChartTooltip/index.mjs +50 -0
- package/es/common/ChartTooltip/index.mjs.map +1 -0
- package/es/common/CustomTooltipProps.d.mts +15 -0
- package/es/common/CustomTooltipProps.mjs +0 -0
- package/es/common/CustomYAxisTick.d.mts +18 -0
- package/es/common/CustomYAxisTick.mjs +24 -0
- package/es/common/CustomYAxisTick.mjs.map +1 -0
- package/es/common/NoData.d.mts +13 -0
- package/es/common/NoData.mjs +25 -0
- package/es/common/NoData.mjs.map +1 -0
- package/es/common/benchmark/index.d.mts +3 -0
- package/es/common/benchmark/{index.js → index.mjs} +1 -1
- package/es/common/benchmark/types.d.mts +125 -0
- package/es/common/benchmark/types.mjs +0 -0
- package/es/common/benchmark/{utils.d.ts → utils.d.mts} +38 -36
- package/es/common/benchmark/utils.mjs +115 -0
- package/es/common/benchmark/utils.mjs.map +1 -0
- package/es/common/{utils.d.ts → utils.d.mts} +3 -0
- package/es/common/utils.mjs +36 -0
- package/es/common/utils.mjs.map +1 -0
- package/es/hooks/useOnWindowResize.d.mts +6 -0
- package/es/hooks/useOnWindowResize.mjs +18 -0
- package/es/hooks/useOnWindowResize.mjs.map +1 -0
- package/es/hooks/usePrefersReducedMotion.d.mts +4 -0
- package/es/hooks/usePrefersReducedMotion.mjs +24 -0
- package/es/hooks/usePrefersReducedMotion.mjs.map +1 -0
- package/es/hooks/useThemeColorRange.d.mts +4 -0
- package/es/hooks/useThemeColorRange.mjs +28 -0
- package/es/hooks/useThemeColorRange.mjs.map +1 -0
- package/es/index.d.mts +34 -0
- package/es/index.mjs +28 -0
- package/es/types/{charts.d.ts → charts.d.mts} +26 -26
- package/es/types/charts.mjs +12 -0
- package/es/types/charts.mjs.map +1 -0
- package/es/utils/{calendar.d.ts → calendar.d.mts} +21 -18
- package/es/utils/calendar.mjs +154 -0
- package/es/utils/calendar.mjs.map +1 -0
- package/es/utils/getMaxLabelLength.d.mts +13 -0
- package/es/utils/getMaxLabelLength.mjs +48 -0
- package/es/utils/getMaxLabelLength.mjs.map +1 -0
- package/es/utils/{index.d.ts → index.d.mts} +4 -1
- package/es/utils/index.mjs +19 -0
- package/es/utils/index.mjs.map +1 -0
- package/es/utils/{theme.d.ts → theme.d.mts} +3 -0
- package/es/utils/theme.mjs +33 -0
- package/es/utils/theme.mjs.map +1 -0
- package/package.json +144 -4
- package/es/AccuracyBarChart/index.d.ts +0 -60
- package/es/AccuracyBarChart/index.js +0 -454
- package/es/AccuracyBarChart/index.mdx +0 -52
- package/es/AccuracyBarChart/styles.d.ts +0 -11
- package/es/AccuracyBarChart/styles.js +0 -18
- package/es/AreaChart/index.d.ts +0 -11
- package/es/AreaChart/index.js +0 -430
- package/es/AreaChart/index.mdx +0 -49
- package/es/AreaChart/styles.d.ts +0 -6
- package/es/AreaChart/styles.js +0 -13
- package/es/BarChart/index.d.ts +0 -9
- package/es/BarChart/index.js +0 -392
- package/es/BarChart/index.mdx +0 -73
- package/es/BarChart/renderShape.js +0 -34
- package/es/BarChart/styles.d.ts +0 -6
- package/es/BarChart/styles.js +0 -13
- package/es/BarList/index.d.ts +0 -29
- package/es/BarList/index.js +0 -174
- package/es/BarList/index.mdx +0 -34
- package/es/BarList/styles.d.ts +0 -10
- package/es/BarList/styles.js +0 -18
- package/es/BenchmarkColumnChart/index.d.ts +0 -140
- package/es/BenchmarkColumnChart/index.js +0 -686
- package/es/BenchmarkColumnChart/index.mdx +0 -66
- package/es/BenchmarkColumnChart/styles.d.ts +0 -16
- package/es/BenchmarkColumnChart/styles.js +0 -23
- package/es/BenchmarkRankingChart/index.d.ts +0 -87
- package/es/BenchmarkRankingChart/index.js +0 -455
- package/es/BenchmarkRankingChart/index.mdx +0 -59
- package/es/BenchmarkRankingChart/styles.d.ts +0 -33
- package/es/BenchmarkRankingChart/styles.js +0 -41
- package/es/BenchmarkScatterChart/index.d.ts +0 -145
- package/es/BenchmarkScatterChart/index.js +0 -857
- package/es/BenchmarkScatterChart/index.mdx +0 -61
- package/es/BenchmarkScatterChart/styles.d.ts +0 -25
- package/es/BenchmarkScatterChart/styles.js +0 -33
- package/es/BenchmarkScatterChart/utils.js +0 -353
- package/es/ComposedChart/index.d.ts +0 -5
- package/es/ComposedChart/index.js +0 -335
- package/es/ComposedChart/index.mdx +0 -43
- package/es/ComposedChart/styles.d.ts +0 -6
- package/es/ComposedChart/styles.js +0 -13
- package/es/ComposedChart/types.d.ts +0 -68
- package/es/ComposedChart/types.js +0 -1
- package/es/DataBars/CategoryBar.d.ts +0 -15
- package/es/DataBars/CategoryBar.js +0 -201
- package/es/DataBars/DeltaBar.d.ts +0 -13
- package/es/DataBars/DeltaBar.js +0 -117
- package/es/DataBars/MarkerBar.d.ts +0 -16
- package/es/DataBars/MarkerBar.js +0 -94
- package/es/DataBars/ProgressBar.d.ts +0 -12
- package/es/DataBars/ProgressBar.js +0 -71
- package/es/DataBars/index.d.ts +0 -4
- package/es/DataBars/index.js +0 -4
- package/es/DataBars/index.mdx +0 -36
- package/es/DataBars/styles.d.ts +0 -7
- package/es/DataBars/styles.js +0 -14
- package/es/DonutChart/DonutChartTooltip.d.ts +0 -11
- package/es/DonutChart/DonutChartTooltip.js +0 -26
- package/es/DonutChart/index.d.ts +0 -31
- package/es/DonutChart/index.js +0 -232
- package/es/DonutChart/index.mdx +0 -48
- package/es/DonutChart/inputParser.d.ts +0 -2
- package/es/DonutChart/inputParser.js +0 -9
- package/es/DonutChart/renderInactiveShape.d.ts +0 -2
- package/es/DonutChart/renderInactiveShape.js +0 -27
- package/es/DonutChart/styles.d.ts +0 -6
- package/es/DonutChart/styles.js +0 -13
- package/es/FunnelChart/ArrowRightIcon.d.ts +0 -5
- package/es/FunnelChart/ArrowRightIcon.js +0 -22
- package/es/FunnelChart/index.d.ts +0 -19
- package/es/FunnelChart/index.js +0 -499
- package/es/FunnelChart/index.mdx +0 -21
- package/es/FunnelChart/styles.d.ts +0 -6
- package/es/FunnelChart/styles.js +0 -13
- package/es/FunnelChart/types.d.ts +0 -28
- package/es/FunnelChart/types.js +0 -1
- package/es/Heatmaps/Calendar.d.ts +0 -18
- package/es/Heatmaps/Calendar.js +0 -155
- package/es/Heatmaps/ChartLabels.d.ts +0 -15
- package/es/Heatmaps/ChartLabels.js +0 -106
- package/es/Heatmaps/Footer.d.ts +0 -22
- package/es/Heatmaps/Footer.js +0 -105
- package/es/Heatmaps/index.d.ts +0 -28
- package/es/Heatmaps/index.js +0 -227
- package/es/Heatmaps/index.mdx +0 -70
- package/es/Heatmaps/styles.d.ts +0 -7
- package/es/Heatmaps/styles.js +0 -14
- package/es/Legend/LegendItem.d.ts +0 -10
- package/es/Legend/LegendItem.js +0 -58
- package/es/Legend/ScrollButton.d.ts +0 -9
- package/es/Legend/ScrollButton.js +0 -63
- package/es/Legend/index.d.ts +0 -14
- package/es/Legend/index.js +0 -184
- package/es/Legend/index.mdx +0 -13
- package/es/LineChart/index.d.ts +0 -9
- package/es/LineChart/index.js +0 -388
- package/es/LineChart/index.mdx +0 -49
- package/es/LineChart/styles.d.ts +0 -6
- package/es/LineChart/styles.js +0 -13
- package/es/RadarChart/index.d.ts +0 -24
- package/es/RadarChart/index.js +0 -254
- package/es/RadarChart/index.mdx +0 -52
- package/es/RadarChart/styles.d.ts +0 -5
- package/es/RadarChart/styles.js +0 -12
- package/es/ScatterChart/ScatterChartTooltip.d.ts +0 -16
- package/es/ScatterChart/ScatterChartTooltip.js +0 -76
- package/es/ScatterChart/ScatterChartTooltipRow.d.ts +0 -7
- package/es/ScatterChart/ScatterChartTooltipRow.js +0 -40
- package/es/ScatterChart/index.d.ts +0 -56
- package/es/ScatterChart/index.js +0 -342
- package/es/ScatterChart/index.mdx +0 -49
- package/es/ScatterChart/renderShape.js +0 -18
- package/es/ScatterChart/styles.d.ts +0 -6
- package/es/ScatterChart/styles.js +0 -13
- package/es/SparkChart/SparkAreaChart.d.ts +0 -12
- package/es/SparkChart/SparkAreaChart.js +0 -148
- package/es/SparkChart/SparkBarChart.d.ts +0 -9
- package/es/SparkChart/SparkBarChart.js +0 -106
- package/es/SparkChart/SparkLineChart.d.ts +0 -10
- package/es/SparkChart/SparkLineChart.js +0 -110
- package/es/SparkChart/index.d.ts +0 -3
- package/es/SparkChart/index.js +0 -3
- package/es/SparkChart/index.mdx +0 -29
- package/es/Tracker/TrackerBlock.d.ts +0 -8
- package/es/Tracker/TrackerBlock.js +0 -64
- package/es/Tracker/index.d.ts +0 -18
- package/es/Tracker/index.js +0 -105
- package/es/Tracker/index.mdx +0 -41
- package/es/Tracker/styles.d.ts +0 -5
- package/es/Tracker/styles.js +0 -12
- package/es/common/BaseAnimationTimingProps.d.ts +0 -7
- package/es/common/BaseAnimationTimingProps.js +0 -1
- package/es/common/BaseChartProps.d.ts +0 -58
- package/es/common/BaseChartProps.js +0 -1
- package/es/common/BaseSparkChartProps.d.ts +0 -14
- package/es/common/BaseSparkChartProps.js +0 -1
- package/es/common/ChartLegend.d.ts +0 -5
- package/es/common/ChartLegend.js +0 -40
- package/es/common/ChartTooltip/ChartTooltipFrame.d.ts +0 -6
- package/es/common/ChartTooltip/ChartTooltipFrame.js +0 -32
- package/es/common/ChartTooltip/ChartTooltipRow.d.ts +0 -8
- package/es/common/ChartTooltip/ChartTooltipRow.js +0 -55
- package/es/common/ChartTooltip/index.d.ts +0 -15
- package/es/common/ChartTooltip/index.js +0 -66
- package/es/common/CustomTooltipProps.d.ts +0 -12
- package/es/common/CustomTooltipProps.js +0 -1
- package/es/common/CustomYAxisTick.d.ts +0 -15
- package/es/common/CustomYAxisTick.js +0 -27
- package/es/common/NoData.d.ts +0 -10
- package/es/common/NoData.js +0 -24
- package/es/common/benchmark/index.d.ts +0 -2
- package/es/common/benchmark/types.d.ts +0 -122
- package/es/common/benchmark/types.js +0 -1
- package/es/common/benchmark/utils.js +0 -159
- package/es/common/utils.js +0 -85
- package/es/hooks/useOnWindowResize.d.ts +0 -3
- package/es/hooks/useOnWindowResize.js +0 -15
- package/es/hooks/usePrefersReducedMotion.d.ts +0 -1
- package/es/hooks/usePrefersReducedMotion.js +0 -28
- package/es/hooks/useThemeColorRange.d.ts +0 -1
- package/es/hooks/useThemeColorRange.js +0 -8
- package/es/index.d.ts +0 -24
- package/es/index.js +0 -22
- package/es/types/charts.js +0 -8
- package/es/types/global.d.ts +0 -9
- package/es/utils/calendar.js +0 -199
- package/es/utils/getMaxLabelLength.d.ts +0 -10
- package/es/utils/getMaxLabelLength.js +0 -110
- package/es/utils/index.js +0 -32
- package/es/utils/theme.js +0 -40
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defaultValueFormatter } from "../utils/index.mjs";
|
|
2
|
+
import { ChartTooltipFrame } from "../common/ChartTooltip/ChartTooltipFrame.mjs";
|
|
3
|
+
import ChartTooltipRow from "./ScatterChartTooltipRow.mjs";
|
|
4
|
+
import { Flexbox, Icon } from "@lobehub/ui";
|
|
5
|
+
import { Text } from "@lobehub/ui/base-ui";
|
|
6
|
+
import { createStaticStyles, cssVar, cx } from "antd-style";
|
|
7
|
+
import { memo } from "react";
|
|
8
|
+
import { Circle } from "lucide-react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/ScatterChart/ScatterChartTooltip.tsx
|
|
11
|
+
const styles = createStaticStyles(({ css }) => ({ header: css`
|
|
12
|
+
border-bottom: 1px solid ${cssVar.colorBorderSecondary};
|
|
13
|
+
font-weight: 500;
|
|
14
|
+
` }));
|
|
15
|
+
const ScatterChartTooltip = memo(({ customCategories, label, active, payload, valueFormatter, axis, category, categoryColors }) => {
|
|
16
|
+
const color = category ? categoryColors.get(payload?.[0]?.payload[category]) ?? cssVar.colorPrimary : cssVar.colorPrimary;
|
|
17
|
+
if (active && payload) return /* @__PURE__ */ jsxs(ChartTooltipFrame, { children: [/* @__PURE__ */ jsxs(Flexbox, {
|
|
18
|
+
align: "center",
|
|
19
|
+
className: cx(styles.header),
|
|
20
|
+
gap: 8,
|
|
21
|
+
horizontal: true,
|
|
22
|
+
paddingBlock: 8,
|
|
23
|
+
paddingInline: 16,
|
|
24
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
25
|
+
color,
|
|
26
|
+
fill: color,
|
|
27
|
+
icon: Circle,
|
|
28
|
+
size: 10
|
|
29
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
30
|
+
ellipsis: true,
|
|
31
|
+
style: { margin: 0 },
|
|
32
|
+
children: label
|
|
33
|
+
})]
|
|
34
|
+
}), /* @__PURE__ */ jsx(Flexbox, {
|
|
35
|
+
gap: 4,
|
|
36
|
+
paddingBlock: 8,
|
|
37
|
+
paddingInline: 16,
|
|
38
|
+
style: { marginTop: 4 },
|
|
39
|
+
children: payload.map(({ value, name }, idx) => {
|
|
40
|
+
const valueFormatterFn = valueFormatter[Object.keys(axis).find((key) => axis[key] === name) ?? ""] ?? defaultValueFormatter;
|
|
41
|
+
return /* @__PURE__ */ jsx(ChartTooltipRow, {
|
|
42
|
+
name: customCategories?.[name] || name,
|
|
43
|
+
value: valueFormatter && valueFormatterFn ? valueFormatterFn(value) : `${value}`
|
|
44
|
+
}, `id-${idx}`);
|
|
45
|
+
})
|
|
46
|
+
})] });
|
|
47
|
+
return null;
|
|
48
|
+
});
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ScatterChartTooltip as default };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=ScatterChartTooltip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScatterChartTooltip.mjs","names":["ScatterChartTooltipRow"],"sources":["../../src/ScatterChart/ScatterChartTooltip.tsx"],"sourcesContent":["import { Flexbox, Icon } from '@lobehub/ui';\nimport { Text } from '@lobehub/ui/base-ui';\nimport { createStaticStyles, cssVar, cx } from 'antd-style';\nimport { Circle } from 'lucide-react';\nimport React, { memo } from 'react';\n\nimport { ChartTooltipFrame } from '@/common/ChartTooltip/ChartTooltipFrame';\nimport { ScatterChartValueFormatter } from '@/types/charts';\nimport { defaultValueFormatter } from '@/utils';\n\nimport ScatterChartTooltipRow from './ScatterChartTooltipRow';\n\nconst styles = createStaticStyles(({ css }) => ({\n header: css`\n border-bottom: 1px solid ${cssVar.colorBorderSecondary};\n font-weight: 500;\n `,\n}));\n\nexport interface ScatterChartTooltipProps {\n active: boolean | undefined;\n axis: any;\n category?: string;\n categoryColors: Map<string, string>;\n customCategories?: {\n [key: string]: string;\n };\n label: string;\n payload: any;\n valueFormatter: ScatterChartValueFormatter;\n}\n\nconst ScatterChartTooltip = memo<ScatterChartTooltipProps>(\n ({\n customCategories,\n label,\n active,\n payload,\n valueFormatter,\n axis,\n category,\n categoryColors,\n }) => {\n const color = category\n ? (categoryColors.get(payload?.[0]?.payload[category]) ?? cssVar.colorPrimary)\n : cssVar.colorPrimary;\n if (active && payload) {\n return (\n <ChartTooltipFrame>\n <Flexbox\n align={'center'}\n className={cx(styles.header)}\n gap={8}\n horizontal\n paddingBlock={8}\n paddingInline={16}\n >\n <Icon color={color} fill={color} icon={Circle} size={10} />\n <Text ellipsis style={{ margin: 0 }}>\n {label}\n </Text>\n </Flexbox>\n <Flexbox gap={4} paddingBlock={8} paddingInline={16} style={{ marginTop: 4 }}>\n {payload.map(({ value, name }: { name: string; value: number }, idx: number) => {\n const valueFormatterKey = Object.keys(axis).find((key) => axis[key] === name) ?? '';\n const valueFormatterFn =\n valueFormatter[valueFormatterKey as keyof ScatterChartValueFormatter] ??\n defaultValueFormatter;\n return (\n <ScatterChartTooltipRow\n key={`id-${idx}`}\n name={customCategories?.[name] || name}\n value={valueFormatter && valueFormatterFn ? valueFormatterFn(value) : `${value}`}\n />\n );\n })}\n </Flexbox>\n </ChartTooltipFrame>\n );\n }\n return null;\n },\n);\n\nexport default ScatterChartTooltip;\n"],"mappings":";;;;;;;;;;AAYA,MAAM,SAAS,oBAAoB,EAAE,WAAW,EAC9C,QAAQ,GAAG;+BACkB,OAAO,qBAAqB;;IAG3D,EAAE;AAeF,MAAM,sBAAsB,MACzB,EACC,kBACA,OACA,QACA,SACA,gBACA,MACA,UACA,qBACI;CACJ,MAAM,QAAQ,WACT,eAAe,IAAI,UAAU,EAAE,EAAE,QAAQ,SAAS,KAAK,OAAO,eAC/D,OAAO;CACX,IAAI,UAAU,SACZ,OACE,qBAAC,mBAAD,EAAA,UAAA,CACE,qBAAC,SAAD;EACE,OAAO;EACP,WAAW,GAAG,OAAO,MAAM;EAC3B,KAAK;EACL,YAAA;EACA,cAAc;EACd,eAAe;EANjB,UAAA,CAQE,oBAAC,MAAD;GAAa;GAAO,MAAM;GAAO,MAAM;GAAQ,MAAM;EAAK,CAAA,GAC1D,oBAAC,MAAD;GAAM,UAAA;GAAS,OAAO,EAAE,QAAQ,EAAE;GAC/B,UAAA;EACG,CAAA,CACC;CACT,CAAA,GAAA,oBAAC,SAAD;EAAS,KAAK;EAAG,cAAc;EAAG,eAAe;EAAI,OAAO,EAAE,WAAW,EAAE;EACxE,UAAA,QAAQ,KAAK,EAAE,OAAO,QAAyC,QAAgB;GAE9E,MAAM,mBACJ,eAFwB,OAAO,KAAK,IAAI,CAAC,CAAC,MAAM,QAAQ,KAAK,SAAS,IAAI,KAAK,OAG/E;GACF,OACE,oBAACA,iBAAD;IAEE,MAAM,mBAAmB,SAAS;IAClC,OAAO,kBAAkB,mBAAmB,iBAAiB,KAAK,IAAI,GAAG;GAC1E,GAHM,MAAM,KAGZ;EAEL,CAAC;CACM,CAAA,CACQ,EAAA,CAAA;CAGvB,OAAO;AACT,CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
//#region src/ScatterChart/ScatterChartTooltipRow.d.ts
|
|
3
|
+
export interface ChartTooltipRowProps {
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
declare const ChartTooltipRow: React.NamedExoticComponent<ChartTooltipRowProps>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ChartTooltipRow as default };
|
|
10
|
+
//# sourceMappingURL=ScatterChartTooltipRow.d.mts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Flexbox } from "@lobehub/ui";
|
|
2
|
+
import { Text } from "@lobehub/ui/base-ui";
|
|
3
|
+
import { createStaticStyles, cssVar } from "antd-style";
|
|
4
|
+
import { memo } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/ScatterChart/ScatterChartTooltipRow.tsx
|
|
7
|
+
const styles = createStaticStyles(({ css }) => ({
|
|
8
|
+
number: css`
|
|
9
|
+
font-weight: 500;
|
|
10
|
+
`,
|
|
11
|
+
title: css`
|
|
12
|
+
color: ${cssVar.colorTextSecondary};
|
|
13
|
+
`
|
|
14
|
+
}));
|
|
15
|
+
const ChartTooltipRow = memo(({ value, name }) => {
|
|
16
|
+
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
17
|
+
align: "center",
|
|
18
|
+
gap: 32,
|
|
19
|
+
horizontal: true,
|
|
20
|
+
justify: "space-between",
|
|
21
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
22
|
+
className: styles.title,
|
|
23
|
+
ellipsis: true,
|
|
24
|
+
style: { margin: 0 },
|
|
25
|
+
children: name
|
|
26
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
27
|
+
className: styles.number,
|
|
28
|
+
style: { margin: 0 },
|
|
29
|
+
children: value
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//#endregion
|
|
34
|
+
export { ChartTooltipRow as default };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=ScatterChartTooltipRow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScatterChartTooltipRow.mjs","names":[],"sources":["../../src/ScatterChart/ScatterChartTooltipRow.tsx"],"sourcesContent":["import { Flexbox } from '@lobehub/ui';\nimport { Text } from '@lobehub/ui/base-ui';\nimport { createStaticStyles, cssVar } from 'antd-style';\nimport React, { memo } from 'react';\n\nconst styles = createStaticStyles(({ css }) => ({\n number: css`\n font-weight: 500;\n `,\n title: css`\n color: ${cssVar.colorTextSecondary};\n `,\n}));\n\nexport interface ChartTooltipRowProps {\n name: string;\n value: string;\n}\n\nconst ChartTooltipRow = memo<ChartTooltipRowProps>(({ value, name }) => {\n return (\n <Flexbox align={'center'} gap={32} horizontal justify={'space-between'}>\n <Text className={styles.title} ellipsis style={{ margin: 0 }}>\n {name}\n </Text>\n <Text className={styles.number} style={{ margin: 0 }}>\n {value}\n </Text>\n </Flexbox>\n );\n});\n\nexport default ChartTooltipRow;\n"],"mappings":";;;;;;AAKA,MAAM,SAAS,oBAAoB,EAAE,WAAW;CAC9C,QAAQ,GAAG;;;CAGX,OAAO,GAAG;aACC,OAAO,mBAAmB;;AAEvC,EAAE;AAOF,MAAM,kBAAkB,MAA4B,EAAE,OAAO,WAAW;CACtE,OACE,qBAAC,SAAD;EAAS,OAAO;EAAU,KAAK;EAAI,YAAA;EAAW,SAAS;EAAvD,UAAA,CACE,oBAAC,MAAD;GAAM,WAAW,OAAO;GAAO,UAAA;GAAS,OAAO,EAAE,QAAQ,EAAE;GACxD,UAAA;EACG,CAAA,GACN,oBAAC,MAAD;GAAM,WAAW,OAAO;GAAQ,OAAO,EAAE,QAAQ,EAAE;GAChD,UAAA;EACG,CAAA,CACC;;AAEb,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { NoDataProps } from "../common/NoData.mjs";
|
|
2
|
+
import { EventProps, IntervalType, ValueFormatter } from "../types/charts.mjs";
|
|
3
|
+
import BaseAnimationTimingProps from "../common/BaseAnimationTimingProps.mjs";
|
|
4
|
+
import { CustomTooltipProps } from "../common/CustomTooltipProps.mjs";
|
|
5
|
+
import { ComponentType, HTMLAttributes } from "react";
|
|
6
|
+
//#region src/ScatterChart/index.d.ts
|
|
7
|
+
export type ScatterChartValueFormatter = {
|
|
8
|
+
size?: ValueFormatter;
|
|
9
|
+
x?: ValueFormatter;
|
|
10
|
+
y?: ValueFormatter;
|
|
11
|
+
};
|
|
12
|
+
export interface ScatterChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
allowDecimals?: boolean;
|
|
14
|
+
autoMinXValue?: boolean;
|
|
15
|
+
autoMinYValue?: boolean;
|
|
16
|
+
category: string;
|
|
17
|
+
colors?: string[];
|
|
18
|
+
customCategories?: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
21
|
+
customTooltip?: ComponentType<CustomTooltipProps>;
|
|
22
|
+
data: any[];
|
|
23
|
+
enableLegendSlider?: boolean;
|
|
24
|
+
intervalType?: IntervalType;
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
maxXValue?: number;
|
|
27
|
+
maxYValue?: number;
|
|
28
|
+
minXValue?: number;
|
|
29
|
+
minYValue?: number;
|
|
30
|
+
noDataText?: NoDataProps['noDataText'];
|
|
31
|
+
onValueChange?: (value: EventProps) => void;
|
|
32
|
+
rotateLabelX?: {
|
|
33
|
+
angle: number;
|
|
34
|
+
verticalShift: number;
|
|
35
|
+
xAxisHeight: number;
|
|
36
|
+
};
|
|
37
|
+
showGridLines?: boolean;
|
|
38
|
+
showLegend?: boolean;
|
|
39
|
+
showOpacity?: boolean;
|
|
40
|
+
showTooltip?: boolean;
|
|
41
|
+
showXAxis?: boolean;
|
|
42
|
+
showYAxis?: boolean;
|
|
43
|
+
size?: string;
|
|
44
|
+
sizeRange?: number[];
|
|
45
|
+
startEndOnly?: boolean;
|
|
46
|
+
tickGap?: number;
|
|
47
|
+
valueFormatter?: ScatterChartValueFormatter;
|
|
48
|
+
x: string;
|
|
49
|
+
xAxisLabel?: string;
|
|
50
|
+
y: string;
|
|
51
|
+
yAxisAlign?: 'left' | 'right';
|
|
52
|
+
yAxisLabel?: string;
|
|
53
|
+
yAxisWidth?: number;
|
|
54
|
+
}
|
|
55
|
+
declare const ScatterChart: import("react").ForwardRefExoticComponent<ScatterChartProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { ScatterChart as default };
|
|
58
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange.mjs";
|
|
3
|
+
import { defaultValueFormatter } from "../utils/index.mjs";
|
|
4
|
+
import ChartLegend from "../common/ChartLegend.mjs";
|
|
5
|
+
import CustomYAxisTick from "../common/CustomYAxisTick.mjs";
|
|
6
|
+
import NoData from "../common/NoData.mjs";
|
|
7
|
+
import { constructCategories, constructCategoryColors, deepEqual, getYAxisDomain } from "../common/utils.mjs";
|
|
8
|
+
import { getMaxLabelLength } from "../utils/getMaxLabelLength.mjs";
|
|
9
|
+
import { renderShape } from "./renderShape.mjs";
|
|
10
|
+
import ScatterChartTooltip from "./ScatterChartTooltip.mjs";
|
|
11
|
+
import { styles } from "./styles.mjs";
|
|
12
|
+
import { Flexbox } from "@lobehub/ui";
|
|
13
|
+
import { Skeleton } from "@lobehub/ui/base-ui";
|
|
14
|
+
import { css, cssVar, cx } from "antd-style";
|
|
15
|
+
import { forwardRef, useMemo, useState } from "react";
|
|
16
|
+
import { CartesianGrid, Label, Legend, ResponsiveContainer, Scatter, ScatterChart as ScatterChart$1, Tooltip as Tooltip$1, XAxis, YAxis, ZAxis } from "recharts";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
//#region src/ScatterChart/index.tsx
|
|
19
|
+
const ScatterChart = forwardRef((props, ref) => {
|
|
20
|
+
const themeColorRange = useThemeColorRange();
|
|
21
|
+
const { data = [], x, y, size, category, colors = themeColorRange, showOpacity = false, yAxisAlign = "left", sizeRange = [1, 1e3], valueFormatter = {
|
|
22
|
+
size: defaultValueFormatter,
|
|
23
|
+
x: defaultValueFormatter,
|
|
24
|
+
y: defaultValueFormatter
|
|
25
|
+
}, startEndOnly = false, showXAxis = true, showYAxis = true, yAxisWidth, intervalType = "equidistantPreserveStart", animationDuration = 900, showAnimation = false, showTooltip = true, showLegend = true, loading, showGridLines = true, autoMinXValue = false, minXValue, maxXValue, autoMinYValue = false, minYValue, maxYValue, allowDecimals = true, noDataText, onValueChange, customTooltip, rotateLabelX, className, enableLegendSlider = false, tickGap = 5, xAxisLabel, yAxisLabel, width = "100%", height = 280, style, customCategories, ...rest } = props;
|
|
26
|
+
const [legendHeight, setLegendHeight] = useState(60);
|
|
27
|
+
const [activeNode, setActiveNode] = useState();
|
|
28
|
+
const [activeLegend, setActiveLegend] = useState();
|
|
29
|
+
const calculatedYAxisWidth = useMemo(() => {
|
|
30
|
+
if (yAxisWidth) return yAxisWidth;
|
|
31
|
+
return getMaxLabelLength({
|
|
32
|
+
data,
|
|
33
|
+
index: y,
|
|
34
|
+
isScatterChart: true,
|
|
35
|
+
margin: 0,
|
|
36
|
+
valueFormatter: valueFormatter?.y
|
|
37
|
+
});
|
|
38
|
+
}, [
|
|
39
|
+
yAxisWidth,
|
|
40
|
+
data,
|
|
41
|
+
valueFormatter,
|
|
42
|
+
y
|
|
43
|
+
]);
|
|
44
|
+
if (loading || !data) return /* @__PURE__ */ jsx(Skeleton, {
|
|
45
|
+
height,
|
|
46
|
+
width
|
|
47
|
+
});
|
|
48
|
+
const CustomTooltip = customTooltip;
|
|
49
|
+
const hasOnValueChange = !!onValueChange;
|
|
50
|
+
const onNodeClick = (data, index, event) => {
|
|
51
|
+
event.stopPropagation();
|
|
52
|
+
if (!hasOnValueChange) return;
|
|
53
|
+
if (deepEqual(activeNode, data.node)) {
|
|
54
|
+
setActiveLegend(void 0);
|
|
55
|
+
setActiveNode(void 0);
|
|
56
|
+
onValueChange?.(null);
|
|
57
|
+
} else {
|
|
58
|
+
setActiveNode(data.node);
|
|
59
|
+
setActiveLegend(data.payload[category]);
|
|
60
|
+
onValueChange?.({
|
|
61
|
+
categoryClicked: data.payload[category],
|
|
62
|
+
eventType: "bubble",
|
|
63
|
+
...data.payload
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const onCategoryClick = (dataKey) => {
|
|
68
|
+
if (!hasOnValueChange) return;
|
|
69
|
+
if (dataKey === activeLegend && !activeNode) {
|
|
70
|
+
setActiveLegend(void 0);
|
|
71
|
+
onValueChange?.(null);
|
|
72
|
+
} else {
|
|
73
|
+
setActiveLegend(dataKey);
|
|
74
|
+
onValueChange?.({
|
|
75
|
+
categoryClicked: dataKey,
|
|
76
|
+
eventType: "category"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
setActiveNode(void 0);
|
|
80
|
+
};
|
|
81
|
+
const categories = constructCategories(data, category);
|
|
82
|
+
const categoryColors = constructCategoryColors(categories, colors);
|
|
83
|
+
const xAxisDomain = getYAxisDomain(autoMinXValue, minXValue, maxXValue);
|
|
84
|
+
const yAxisDomain = getYAxisDomain(autoMinYValue, minYValue, maxYValue);
|
|
85
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
86
|
+
className,
|
|
87
|
+
height,
|
|
88
|
+
ref,
|
|
89
|
+
style: {
|
|
90
|
+
position: "relative",
|
|
91
|
+
...style
|
|
92
|
+
},
|
|
93
|
+
width,
|
|
94
|
+
...rest,
|
|
95
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: data?.length ? /* @__PURE__ */ jsxs(ScatterChart$1, {
|
|
96
|
+
margin: {
|
|
97
|
+
bottom: xAxisLabel ? 20 : void 0,
|
|
98
|
+
left: 20,
|
|
99
|
+
right: 20,
|
|
100
|
+
top: 5
|
|
101
|
+
},
|
|
102
|
+
onClick: hasOnValueChange && (activeLegend || activeNode) ? () => {
|
|
103
|
+
setActiveNode(void 0);
|
|
104
|
+
setActiveLegend(void 0);
|
|
105
|
+
onValueChange?.(null);
|
|
106
|
+
} : void 0,
|
|
107
|
+
children: [
|
|
108
|
+
showGridLines ? /* @__PURE__ */ jsx(CartesianGrid, {
|
|
109
|
+
className: styles.gridLines,
|
|
110
|
+
horizontal: true,
|
|
111
|
+
vertical: true
|
|
112
|
+
}) : null,
|
|
113
|
+
x ? /* @__PURE__ */ jsx(XAxis, {
|
|
114
|
+
allowDataOverflow: true,
|
|
115
|
+
angle: rotateLabelX?.angle,
|
|
116
|
+
axisLine: false,
|
|
117
|
+
className: styles.label,
|
|
118
|
+
dataKey: x,
|
|
119
|
+
domain: xAxisDomain,
|
|
120
|
+
dy: rotateLabelX?.verticalShift,
|
|
121
|
+
fill: "",
|
|
122
|
+
hide: !showXAxis,
|
|
123
|
+
interval: startEndOnly ? "preserveStartEnd" : intervalType,
|
|
124
|
+
minTickGap: tickGap,
|
|
125
|
+
name: x,
|
|
126
|
+
stroke: "",
|
|
127
|
+
tick: { transform: "translate(0, 6)" },
|
|
128
|
+
tickFormatter: valueFormatter.x,
|
|
129
|
+
tickLine: false,
|
|
130
|
+
ticks: startEndOnly ? [data[0][x], data.at(-1)[x]] : void 0,
|
|
131
|
+
type: "number",
|
|
132
|
+
children: xAxisLabel && /* @__PURE__ */ jsx(Label, {
|
|
133
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
134
|
+
offset: -20,
|
|
135
|
+
position: "insideBottom",
|
|
136
|
+
children: xAxisLabel
|
|
137
|
+
})
|
|
138
|
+
}) : null,
|
|
139
|
+
y ? /* @__PURE__ */ jsx(YAxis, {
|
|
140
|
+
allowDataOverflow: true,
|
|
141
|
+
allowDecimals,
|
|
142
|
+
axisLine: false,
|
|
143
|
+
className: styles.label,
|
|
144
|
+
dataKey: y,
|
|
145
|
+
domain: yAxisDomain,
|
|
146
|
+
fill: "",
|
|
147
|
+
hide: !showYAxis,
|
|
148
|
+
name: y,
|
|
149
|
+
stroke: "",
|
|
150
|
+
tick: (props) => /* @__PURE__ */ jsx(CustomYAxisTick, {
|
|
151
|
+
...props,
|
|
152
|
+
align: yAxisAlign,
|
|
153
|
+
formatter: valueFormatter.y,
|
|
154
|
+
textAnchor: yAxisAlign === "left" ? "start" : "end",
|
|
155
|
+
yAxisLabel: Boolean(yAxisLabel)
|
|
156
|
+
}),
|
|
157
|
+
tickFormatter: valueFormatter.y,
|
|
158
|
+
tickLine: false,
|
|
159
|
+
type: "number",
|
|
160
|
+
width: calculatedYAxisWidth,
|
|
161
|
+
children: yAxisLabel && /* @__PURE__ */ jsx(Label, {
|
|
162
|
+
angle: -90,
|
|
163
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
164
|
+
offset: -15,
|
|
165
|
+
position: "insideLeft",
|
|
166
|
+
style: { textAnchor: "middle" },
|
|
167
|
+
children: yAxisLabel
|
|
168
|
+
})
|
|
169
|
+
}) : null,
|
|
170
|
+
/* @__PURE__ */ jsx(Tooltip$1, {
|
|
171
|
+
content: showTooltip ? ({ active, payload, label }) => {
|
|
172
|
+
const color = category ? payload?.[0]?.payload?.[category] : label;
|
|
173
|
+
return CustomTooltip ? /* @__PURE__ */ jsx(CustomTooltip, {
|
|
174
|
+
active,
|
|
175
|
+
customCategories,
|
|
176
|
+
label: color,
|
|
177
|
+
payload: payload?.map((payloadItem) => ({
|
|
178
|
+
...payloadItem,
|
|
179
|
+
color: categoryColors.get(color) ?? cssVar.colorPrimary
|
|
180
|
+
})),
|
|
181
|
+
valueFormatter
|
|
182
|
+
}) : /* @__PURE__ */ jsx(ScatterChartTooltip, {
|
|
183
|
+
active,
|
|
184
|
+
axis: {
|
|
185
|
+
size,
|
|
186
|
+
x,
|
|
187
|
+
y
|
|
188
|
+
},
|
|
189
|
+
category,
|
|
190
|
+
categoryColors,
|
|
191
|
+
customCategories,
|
|
192
|
+
label: color,
|
|
193
|
+
payload,
|
|
194
|
+
valueFormatter
|
|
195
|
+
});
|
|
196
|
+
} : void 0,
|
|
197
|
+
cursor: {
|
|
198
|
+
stroke: cssVar.colorTextSecondary,
|
|
199
|
+
strokeWidth: 1
|
|
200
|
+
},
|
|
201
|
+
isAnimationActive: false,
|
|
202
|
+
wrapperStyle: { outline: "none" }
|
|
203
|
+
}),
|
|
204
|
+
size ? /* @__PURE__ */ jsx(ZAxis, {
|
|
205
|
+
dataKey: size,
|
|
206
|
+
name: size,
|
|
207
|
+
range: sizeRange,
|
|
208
|
+
type: "number"
|
|
209
|
+
}) : null,
|
|
210
|
+
categories.map((cat) => {
|
|
211
|
+
return /* @__PURE__ */ jsx(Scatter, {
|
|
212
|
+
animationDuration,
|
|
213
|
+
className: cx(css`
|
|
214
|
+
fill: ${categoryColors.get(cat) ?? cssVar.colorPrimary};
|
|
215
|
+
`, showOpacity && css`
|
|
216
|
+
stroke: ${categoryColors.get(cat) ?? cssVar.colorPrimary};
|
|
217
|
+
`),
|
|
218
|
+
data: category ? data.filter((d) => d[category] === cat) : data,
|
|
219
|
+
fill: `url(#${categoryColors.get(cat)})`,
|
|
220
|
+
fillOpacity: showOpacity ? .7 : 1,
|
|
221
|
+
isAnimationActive: showAnimation,
|
|
222
|
+
name: cat,
|
|
223
|
+
onClick: onNodeClick,
|
|
224
|
+
shape: (props) => renderShape(props, activeNode, activeLegend),
|
|
225
|
+
style: { cursor: onValueChange ? "pointer" : void 0 }
|
|
226
|
+
}, cat);
|
|
227
|
+
}),
|
|
228
|
+
showLegend ? /* @__PURE__ */ jsx(Legend, {
|
|
229
|
+
content: ({ payload }) => ChartLegend({ payload }, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? (clickedLegendItem) => onCategoryClick(clickedLegendItem) : void 0, enableLegendSlider, customCategories),
|
|
230
|
+
height: legendHeight,
|
|
231
|
+
verticalAlign: "top"
|
|
232
|
+
}) : void 0
|
|
233
|
+
]
|
|
234
|
+
}) : /* @__PURE__ */ jsx(NoData, { noDataText }) })
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
ScatterChart.displayName = "ScatterChart";
|
|
238
|
+
//#endregion
|
|
239
|
+
export { ScatterChart as default };
|
|
240
|
+
|
|
241
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["ReChartsScatterChart","Tooltip"],"sources":["../../src/ScatterChart/index.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox } from '@lobehub/ui';\nimport { Skeleton } from '@lobehub/ui/base-ui';\nimport { css, cssVar, cx } from 'antd-style';\nimport { ComponentType, HTMLAttributes, MouseEvent, forwardRef, useMemo, useState } from 'react';\nimport {\n CartesianGrid,\n Label,\n Legend,\n ScatterChart as ReChartsScatterChart,\n ResponsiveContainer,\n Scatter,\n Tooltip,\n XAxis,\n YAxis,\n ZAxis,\n} from 'recharts';\nimport { AxisDomain } from 'recharts/types/util/types';\n\nimport { renderShape } from '@/ScatterChart/renderShape';\nimport ChartLegend from '@/common/ChartLegend';\nimport { CustomTooltipProps } from '@/common/CustomTooltipProps';\nimport CustomYAxisTick from '@/common/CustomYAxisTick';\nimport {\n constructCategories,\n constructCategoryColors,\n deepEqual,\n getYAxisDomain,\n} from '@/common/utils';\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport type { EventProps } from '@/types/charts';\nimport { IntervalType, ValueFormatter } from '@/types/charts';\nimport { defaultValueFormatter } from '@/utils';\nimport { getMaxLabelLength } from '@/utils/getMaxLabelLength';\n\nimport BaseAnimationTimingProps from '../common/BaseAnimationTimingProps';\nimport NoData, { type NoDataProps } from '../common/NoData';\nimport ScatterChartTooltip from './ScatterChartTooltip';\nimport { styles } from './styles';\n\nexport type ScatterChartValueFormatter = {\n size?: ValueFormatter;\n x?: ValueFormatter;\n y?: ValueFormatter;\n};\n\nexport interface ScatterChartProps\n extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {\n allowDecimals?: boolean;\n autoMinXValue?: boolean;\n autoMinYValue?: boolean;\n category: string;\n colors?: string[];\n customCategories?: {\n [key: string]: string;\n };\n customTooltip?: ComponentType<CustomTooltipProps>;\n data: any[];\n enableLegendSlider?: boolean;\n intervalType?: IntervalType;\n loading?: boolean;\n maxXValue?: number;\n maxYValue?: number;\n minXValue?: number;\n minYValue?: number;\n noDataText?: NoDataProps['noDataText'];\n onValueChange?: (value: EventProps) => void;\n rotateLabelX?: {\n angle: number;\n verticalShift: number;\n xAxisHeight: number;\n };\n showGridLines?: boolean;\n showLegend?: boolean;\n showOpacity?: boolean;\n showTooltip?: boolean;\n showXAxis?: boolean;\n showYAxis?: boolean;\n size?: string;\n sizeRange?: number[];\n startEndOnly?: boolean;\n tickGap?: number;\n valueFormatter?: ScatterChartValueFormatter;\n x: string;\n xAxisLabel?: string;\n y: string;\n yAxisAlign?: 'left' | 'right';\n yAxisLabel?: string;\n yAxisWidth?: number;\n}\n\nconst ScatterChart = forwardRef<HTMLDivElement, ScatterChartProps>((props, ref) => {\n const themeColorRange = useThemeColorRange();\n const {\n data = [],\n x,\n y,\n size,\n category,\n colors = themeColorRange,\n showOpacity = false,\n yAxisAlign = 'left',\n sizeRange = [1, 1000],\n valueFormatter = {\n size: defaultValueFormatter,\n x: defaultValueFormatter,\n y: defaultValueFormatter,\n },\n startEndOnly = false,\n showXAxis = true,\n showYAxis = true,\n yAxisWidth,\n intervalType = 'equidistantPreserveStart',\n animationDuration = 900,\n showAnimation = false,\n showTooltip = true,\n showLegend = true,\n loading,\n showGridLines = true,\n autoMinXValue = false,\n minXValue,\n maxXValue,\n autoMinYValue = false,\n minYValue,\n maxYValue,\n allowDecimals = true,\n noDataText,\n onValueChange,\n customTooltip,\n rotateLabelX,\n className,\n enableLegendSlider = false,\n tickGap = 5,\n xAxisLabel,\n yAxisLabel,\n width = '100%',\n height = 280,\n style,\n customCategories,\n ...rest\n } = props;\n\n const [legendHeight, setLegendHeight] = useState(60);\n const [activeNode, setActiveNode] = useState<any | undefined>();\n const [activeLegend, setActiveLegend] = useState<string | undefined>();\n const calculatedYAxisWidth: number | string = useMemo(() => {\n if (yAxisWidth) return yAxisWidth;\n return getMaxLabelLength({\n data,\n index: y,\n isScatterChart: true,\n margin: 0,\n valueFormatter: valueFormatter?.y,\n });\n }, [yAxisWidth, data, valueFormatter, y]);\n\n if (loading || !data) return <Skeleton height={height} width={width} />;\n\n const CustomTooltip = customTooltip;\n const hasOnValueChange = !!onValueChange;\n\n const onNodeClick = (data: any, index: number, event: MouseEvent) => {\n event.stopPropagation();\n if (!hasOnValueChange) return;\n if (deepEqual(activeNode, data.node)) {\n setActiveLegend(undefined);\n setActiveNode(undefined);\n onValueChange?.(null);\n } else {\n setActiveNode(data.node);\n setActiveLegend(data.payload[category]);\n onValueChange?.({\n categoryClicked: data.payload[category],\n eventType: 'bubble',\n ...data.payload,\n });\n }\n };\n\n const onCategoryClick = (dataKey: string) => {\n if (!hasOnValueChange) return;\n if (dataKey === activeLegend && !activeNode) {\n setActiveLegend(undefined);\n onValueChange?.(null);\n } else {\n setActiveLegend(dataKey);\n onValueChange?.({\n categoryClicked: dataKey,\n eventType: 'category',\n });\n }\n setActiveNode(undefined);\n };\n\n const categories = constructCategories(data, category);\n const categoryColors = constructCategoryColors(categories, colors);\n\n //maybe rename getYAxisDomain to getAxisDomain\n const xAxisDomain = getYAxisDomain(autoMinXValue, minXValue, maxXValue);\n const yAxisDomain = getYAxisDomain(autoMinYValue, minYValue, maxYValue);\n\n return (\n <Flexbox\n className={className}\n height={height}\n ref={ref}\n style={{ position: 'relative', ...style }}\n width={width}\n {...rest}\n >\n <ResponsiveContainer>\n {data?.length ? (\n <ReChartsScatterChart\n margin={{\n bottom: xAxisLabel ? 20 : undefined,\n left: 20,\n right: 20,\n top: 5,\n }}\n onClick={\n hasOnValueChange && (activeLegend || activeNode)\n ? () => {\n setActiveNode(undefined);\n setActiveLegend(undefined);\n onValueChange?.(null);\n }\n : undefined\n }\n >\n {showGridLines ? (\n <CartesianGrid className={styles.gridLines} horizontal={true} vertical={true} />\n ) : null}\n {x ? (\n <XAxis\n allowDataOverflow={true}\n angle={rotateLabelX?.angle}\n axisLine={false}\n className={styles.label}\n dataKey={x}\n domain={xAxisDomain as AxisDomain}\n dy={rotateLabelX?.verticalShift}\n fill=\"\"\n hide={!showXAxis}\n interval={startEndOnly ? 'preserveStartEnd' : intervalType}\n minTickGap={tickGap}\n name={x}\n stroke=\"\"\n tick={{ transform: 'translate(0, 6)' }}\n tickFormatter={valueFormatter.x}\n tickLine={false}\n ticks={startEndOnly ? [data[0][x], data.at(-1)[x]] : undefined}\n type=\"number\"\n >\n {xAxisLabel && (\n <Label\n className={cx(styles.strongLabel, styles.emphasis)}\n offset={-20}\n position=\"insideBottom\"\n >\n {xAxisLabel}\n </Label>\n )}\n </XAxis>\n ) : null}\n {y ? (\n <YAxis\n allowDataOverflow={true}\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.label}\n dataKey={y}\n domain={yAxisDomain as AxisDomain}\n fill=\"\"\n hide={!showYAxis}\n name={y}\n stroke=\"\"\n tick={(props) => (\n <CustomYAxisTick\n {...props}\n align={yAxisAlign}\n formatter={valueFormatter.y}\n textAnchor={yAxisAlign === 'left' ? 'start' : 'end'}\n yAxisLabel={Boolean(yAxisLabel)}\n />\n )}\n tickFormatter={valueFormatter.y}\n tickLine={false}\n type=\"number\"\n width={calculatedYAxisWidth}\n >\n {yAxisLabel && (\n <Label\n angle={-90}\n className={cx(styles.strongLabel, styles.emphasis)}\n offset={-15}\n position=\"insideLeft\"\n style={{ textAnchor: 'middle' }}\n >\n {yAxisLabel}\n </Label>\n )}\n </YAxis>\n ) : null}\n <Tooltip\n content={\n showTooltip\n ? ({ active, payload, label }) => {\n const color = category ? payload?.[0]?.payload?.[category] : label;\n return CustomTooltip ? (\n <CustomTooltip\n active={active}\n customCategories={customCategories}\n label={color}\n payload={payload?.map((payloadItem) => ({\n ...payloadItem,\n color: categoryColors.get(color) ?? cssVar.colorPrimary,\n }))}\n valueFormatter={valueFormatter}\n />\n ) : (\n <ScatterChartTooltip\n active={active}\n axis={{ size: size, x: x, y: y }}\n category={category}\n categoryColors={categoryColors}\n customCategories={customCategories}\n label={color}\n payload={payload}\n valueFormatter={valueFormatter}\n />\n );\n }\n : undefined\n }\n cursor={{ stroke: cssVar.colorTextSecondary, strokeWidth: 1 }}\n isAnimationActive={false}\n wrapperStyle={{ outline: 'none' }}\n />\n {size ? <ZAxis dataKey={size} name={size} range={sizeRange} type=\"number\" /> : null}\n {categories.map((cat) => {\n return (\n <Scatter\n animationDuration={animationDuration}\n className={cx(\n css`\n fill: ${categoryColors.get(cat) ?? cssVar.colorPrimary};\n `,\n showOpacity &&\n css`\n stroke: ${categoryColors.get(cat) ?? cssVar.colorPrimary};\n `,\n )}\n data={category ? data.filter((d) => d[category] === cat) : data}\n fill={`url(#${categoryColors.get(cat)})`}\n fillOpacity={showOpacity ? 0.7 : 1}\n isAnimationActive={showAnimation}\n key={cat}\n name={cat}\n onClick={onNodeClick}\n shape={(props: any) => renderShape(props, activeNode, activeLegend)}\n style={{\n cursor: onValueChange ? 'pointer' : undefined,\n }}\n />\n );\n })}\n {showLegend ? (\n <Legend\n content={({ payload }) =>\n ChartLegend(\n { payload },\n categoryColors,\n setLegendHeight,\n activeLegend,\n hasOnValueChange\n ? (clickedLegendItem: string) => onCategoryClick(clickedLegendItem)\n : undefined,\n enableLegendSlider,\n customCategories,\n )\n }\n height={legendHeight}\n verticalAlign=\"top\"\n />\n ) : undefined}\n </ReChartsScatterChart>\n ) : (\n <NoData noDataText={noDataText} />\n )}\n </ResponsiveContainer>\n </Flexbox>\n );\n});\n\nScatterChart.displayName = 'ScatterChart';\n\nexport default ScatterChart;\n"],"mappings":"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"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
|
+
//#region src/ScatterChart/renderShape.d.ts
|
|
2
3
|
export declare const renderShape: (props: any, activeNode: any | undefined, activeLegend: string | undefined) => React.JSX.Element;
|
|
4
|
+
//#endregion
|
|
5
|
+
//# sourceMappingURL=renderShape.d.mts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { deepEqual } from "../common/utils.mjs";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Dot } from "recharts";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/ScatterChart/renderShape.tsx
|
|
6
|
+
const renderShape = (props, activeNode, activeLegend) => {
|
|
7
|
+
const { cx, cy, width, node, fillOpacity, name } = props;
|
|
8
|
+
return /* @__PURE__ */ jsx(Dot, {
|
|
9
|
+
cx,
|
|
10
|
+
cy,
|
|
11
|
+
opacity: activeNode || activeLegend && activeLegend !== name ? deepEqual(activeNode, node) ? fillOpacity : .3 : fillOpacity,
|
|
12
|
+
r: width / 2
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { renderShape };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=renderShape.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderShape.mjs","names":[],"sources":["../../src/ScatterChart/renderShape.tsx"],"sourcesContent":["import React from 'react';\nimport { Dot } from 'recharts';\n\nimport { deepEqual } from '@/common/utils';\n\nexport const renderShape = (\n props: any,\n activeNode: any | undefined,\n activeLegend: string | undefined,\n) => {\n const { cx, cy, width, node, fillOpacity, name } = props;\n\n return (\n <Dot\n cx={cx}\n cy={cy}\n opacity={\n activeNode || (activeLegend && activeLegend !== name)\n ? deepEqual(activeNode, node)\n ? fillOpacity\n : 0.3\n : fillOpacity\n }\n r={width / 2}\n />\n );\n};\n"],"mappings":";;;;;AAKA,MAAa,eACX,OACA,YACA,iBACG;CACH,MAAM,EAAE,IAAI,IAAI,OAAO,MAAM,aAAa,SAAS;CAEnD,OACE,oBAAC,KAAD;EACM;EACA;EACJ,SACE,cAAe,gBAAgB,iBAAiB,OAC5C,UAAU,YAAY,IAAI,IACxB,cACA,KACF;EAEN,GAAG,QAAQ;CACZ,CAAA;AAEL"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createStaticStyles } from "antd-style";
|
|
2
|
+
//#region src/ScatterChart/styles.ts
|
|
3
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
4
|
+
emphasis: css`
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
text-overflow: ellipsis;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
`,
|
|
9
|
+
gridLines: css`
|
|
10
|
+
stroke: ${cssVar.colorBorderSecondary};
|
|
11
|
+
stroke-width: 1;
|
|
12
|
+
`,
|
|
13
|
+
label: css`
|
|
14
|
+
font-size: 12px;
|
|
15
|
+
line-height: 16px;
|
|
16
|
+
fill: ${cssVar.colorTextDescription};
|
|
17
|
+
`,
|
|
18
|
+
strongLabel: css`
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
font-weight: 500;
|
|
21
|
+
line-height: 16px;
|
|
22
|
+
fill: ${cssVar.colorTextSecondary};
|
|
23
|
+
`
|
|
24
|
+
}));
|
|
25
|
+
//#endregion
|
|
26
|
+
export { styles };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=styles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.mjs","names":[],"sources":["../../src/ScatterChart/styles.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n emphasis: css`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n `,\n gridLines: css`\n stroke: ${cssVar.colorBorderSecondary};\n stroke-width: 1;\n `,\n label: css`\n font-size: 12px;\n line-height: 16px;\n fill: ${cssVar.colorTextDescription};\n `,\n strongLabel: css`\n font-size: 12px;\n font-weight: 500;\n line-height: 16px;\n fill: ${cssVar.colorTextSecondary};\n `,\n}));\n"],"mappings":";;AAEA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,UAAU,GAAG;;;;;CAKb,WAAW,GAAG;cACF,OAAO,qBAAqB;;;CAGxC,OAAO,GAAG;;;YAGA,OAAO,qBAAqB;;CAEtC,aAAa,GAAG;;;;YAIN,OAAO,mBAAmB;;AAEtC,EAAE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CurveType } from "../types/charts.mjs";
|
|
2
|
+
import BaseSparkChartProps from "../common/BaseSparkChartProps.mjs";
|
|
3
|
+
//#region src/SparkChart/SparkAreaChart.d.ts
|
|
4
|
+
export interface SparkAreaChartProps extends BaseSparkChartProps {
|
|
5
|
+
connectNulls?: boolean;
|
|
6
|
+
curveType?: CurveType;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
showGradient?: boolean;
|
|
9
|
+
stack?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const SparkAreaChart: import("react").ForwardRefExoticComponent<SparkAreaChartProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { SparkAreaChart as default };
|
|
14
|
+
//# sourceMappingURL=SparkAreaChart.d.mts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange.mjs";
|
|
3
|
+
import NoData from "../common/NoData.mjs";
|
|
4
|
+
import { constructCategoryColors, getYAxisDomain } from "../common/utils.mjs";
|
|
5
|
+
import { Flexbox } from "@lobehub/ui";
|
|
6
|
+
import { Skeleton } from "@lobehub/ui/base-ui";
|
|
7
|
+
import { css, cssVar, cx } from "antd-style";
|
|
8
|
+
import { forwardRef } from "react";
|
|
9
|
+
import { Area, AreaChart, ResponsiveContainer, XAxis, YAxis } from "recharts";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/SparkChart/SparkAreaChart.tsx
|
|
12
|
+
const SparkAreaChart = forwardRef((props, ref) => {
|
|
13
|
+
const themeColorRange = useThemeColorRange();
|
|
14
|
+
const { data = [], categories = [], index, stack = false, colors = themeColorRange, showAnimation = false, animationDuration = 900, showGradient = true, curveType = "linear", connectNulls = false, noDataText = /* @__PURE__ */ jsx("div", {}), autoMinValue = false, loading, minValue, maxValue, className, width = 112, height = 48, style, ...rest } = props;
|
|
15
|
+
if (loading || !data) return /* @__PURE__ */ jsx(Skeleton, {
|
|
16
|
+
height,
|
|
17
|
+
width
|
|
18
|
+
});
|
|
19
|
+
const categoryColors = constructCategoryColors(categories, colors);
|
|
20
|
+
const yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
|
|
21
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
22
|
+
className,
|
|
23
|
+
height,
|
|
24
|
+
ref,
|
|
25
|
+
style: {
|
|
26
|
+
position: "relative",
|
|
27
|
+
...style
|
|
28
|
+
},
|
|
29
|
+
width,
|
|
30
|
+
...rest,
|
|
31
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: data?.length ? /* @__PURE__ */ jsxs(AreaChart, {
|
|
32
|
+
data,
|
|
33
|
+
margin: {
|
|
34
|
+
bottom: 1,
|
|
35
|
+
left: 1,
|
|
36
|
+
right: 1,
|
|
37
|
+
top: 1
|
|
38
|
+
},
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
41
|
+
domain: yAxisDomain,
|
|
42
|
+
hide: true
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
45
|
+
dataKey: index,
|
|
46
|
+
hide: true
|
|
47
|
+
}),
|
|
48
|
+
categories.map((category) => {
|
|
49
|
+
return /* @__PURE__ */ jsx("defs", { children: showGradient ? /* @__PURE__ */ jsxs("linearGradient", {
|
|
50
|
+
className: cx(css`
|
|
51
|
+
color: ${categoryColors.get(category) ?? cssVar.colorPrimary};
|
|
52
|
+
`),
|
|
53
|
+
id: categoryColors.get(category),
|
|
54
|
+
x1: "0",
|
|
55
|
+
x2: "0",
|
|
56
|
+
y1: "0",
|
|
57
|
+
y2: "1",
|
|
58
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
59
|
+
offset: "5%",
|
|
60
|
+
stopColor: "currentColor",
|
|
61
|
+
stopOpacity: .4
|
|
62
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
63
|
+
offset: "95%",
|
|
64
|
+
stopColor: "currentColor",
|
|
65
|
+
stopOpacity: 0
|
|
66
|
+
})]
|
|
67
|
+
}) : /* @__PURE__ */ jsx("linearGradient", {
|
|
68
|
+
className: cx(css`
|
|
69
|
+
color: ${categoryColors.get(category) ?? cssVar.colorPrimary};
|
|
70
|
+
`),
|
|
71
|
+
id: categoryColors.get(category),
|
|
72
|
+
x1: "0",
|
|
73
|
+
x2: "0",
|
|
74
|
+
y1: "0",
|
|
75
|
+
y2: "1",
|
|
76
|
+
children: /* @__PURE__ */ jsx("stop", {
|
|
77
|
+
stopColor: "currentColor",
|
|
78
|
+
stopOpacity: .3
|
|
79
|
+
})
|
|
80
|
+
}) }, category);
|
|
81
|
+
}),
|
|
82
|
+
categories.map((category) => /* @__PURE__ */ jsx(Area, {
|
|
83
|
+
animationDuration,
|
|
84
|
+
className: cx(css`
|
|
85
|
+
stroke: ${categoryColors.get(category) ?? cssVar.colorPrimary};
|
|
86
|
+
`),
|
|
87
|
+
connectNulls,
|
|
88
|
+
dataKey: category,
|
|
89
|
+
dot: false,
|
|
90
|
+
fill: `url(#${categoryColors.get(category)})`,
|
|
91
|
+
isAnimationActive: showAnimation,
|
|
92
|
+
name: category,
|
|
93
|
+
stackId: stack ? "a" : void 0,
|
|
94
|
+
stroke: "",
|
|
95
|
+
strokeLinecap: "round",
|
|
96
|
+
strokeLinejoin: "round",
|
|
97
|
+
strokeOpacity: 1,
|
|
98
|
+
strokeWidth: 2,
|
|
99
|
+
type: curveType
|
|
100
|
+
}, category))
|
|
101
|
+
]
|
|
102
|
+
}) : /* @__PURE__ */ jsx(NoData, { noDataText }) })
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
SparkAreaChart.displayName = "AreaChart";
|
|
106
|
+
//#endregion
|
|
107
|
+
export { SparkAreaChart as default };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=SparkAreaChart.mjs.map
|