@lobehub/charts 5.6.0 → 5.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +23 -5
- 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 -448
- 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 -850
- 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 -200
- package/es/DataBars/DeltaBar.d.ts +0 -13
- package/es/DataBars/DeltaBar.js +0 -116
- package/es/DataBars/MarkerBar.d.ts +0 -16
- package/es/DataBars/MarkerBar.js +0 -93
- package/es/DataBars/ProgressBar.d.ts +0 -12
- package/es/DataBars/ProgressBar.js +0 -70
- 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 -226
- 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 -63
- package/es/Tracker/index.d.ts +0 -18
- package/es/Tracker/index.js +0 -104
- 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 -41
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/BenchmarkScatterChart/utils.ts"],"sourcesContent":["export type ScaleType = 'linear' | 'log';\n\nexport interface Scale {\n domain: [number, number];\n map: (value: number) => number;\n ticks: number[];\n}\n\nconst niceStep = (range: number, count: number) => {\n if (range <= 0 || !Number.isFinite(range)) return 1;\n const raw = range / count;\n const magnitude = 10 ** Math.floor(Math.log10(raw));\n const normalized = raw / magnitude;\n const base = normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10;\n return base * magnitude;\n};\n\nexport const getLinearTicks = (min: number, max: number, count = 5) => {\n const step = niceStep(max - min, count);\n const ticks: number[] = [];\n const start = Math.ceil(min / step) * step;\n for (let value = start; value <= max + step / 1e6; value += step) {\n ticks.push(Number(value.toPrecision(12)));\n }\n return ticks;\n};\n\nexport const getLogTicks = (min: number, max: number) => {\n const ticks: number[] = [];\n const from = Math.floor(Math.log10(min));\n const to = Math.ceil(Math.log10(max));\n for (let exp = from; exp <= to; exp++) {\n for (const base of [1, 2, 5]) {\n const value = Number((base * 10 ** exp).toPrecision(12));\n if (value >= min && value <= max) ticks.push(value);\n }\n }\n return ticks;\n};\n\nexport const createScale = ({\n values,\n type = 'linear',\n range,\n min,\n max,\n padding = 0.08,\n tickCount = 5,\n}: {\n max?: number;\n min?: number;\n padding?: number;\n range: [number, number];\n tickCount?: number;\n type?: ScaleType;\n values: number[];\n}): Scale => {\n const isLog = type === 'log';\n const valid = values.filter((v) => Number.isFinite(v) && (!isLog || v > 0));\n const toSpace = (v: number) => (isLog ? Math.log10(v) : v);\n const fromSpace = (v: number) => (isLog ? 10 ** v : v);\n\n let lo = valid.length ? Math.min(...valid.map(toSpace)) : 0;\n let hi = valid.length ? Math.max(...valid.map(toSpace)) : 1;\n if (lo === hi) {\n const delta = lo === 0 ? 1 : Math.abs(lo) * 0.1;\n lo -= delta;\n hi += delta;\n }\n const pad = (hi - lo) * padding;\n lo = typeof min === 'number' && (!isLog || min > 0) ? toSpace(min) : lo - pad;\n hi = typeof max === 'number' && (!isLog || max > 0) ? toSpace(max) : hi + pad;\n\n const domain: [number, number] = [fromSpace(lo), fromSpace(hi)];\n const span = hi - lo || 1;\n const map = (value: number) =>\n range[0] +\n ((toSpace(Math.max(value, isLog ? domain[0] : -Infinity)) - lo) / span) * (range[1] - range[0]);\n\n let ticks = isLog ? getLogTicks(domain[0], domain[1]) : getLinearTicks(...domain, tickCount);\n if (isLog && ticks.length < 2) {\n ticks = getLinearTicks(lo, hi, tickCount).map((v) => Number(fromSpace(v).toPrecision(3)));\n }\n\n return { domain, map, ticks };\n};\n\n/**\n * Pareto frontier: points not dominated by any other point.\n * `xDirection = 'lower'` treats smaller X as better (e.g. cost / latency).\n * Returns keys ordered by ascending X.\n */\nexport const getParetoFrontier = <T extends { key: string | number; x: number; y: number }>(\n points: T[],\n xDirection: 'lower' | 'higher' = 'lower',\n): T[] => {\n const sign = xDirection === 'lower' ? 1 : -1;\n const sorted = [...points]\n .filter((p) => Number.isFinite(p.x) && Number.isFinite(p.y))\n .sort((a, b) => sign * (a.x - b.x) || b.y - a.y);\n\n const frontier: T[] = [];\n let bestY = -Infinity;\n for (const point of sorted) {\n if (point.y > bestY) {\n frontier.push(point);\n bestY = point.y;\n }\n }\n return frontier.sort((a, b) => a.x - b.x);\n};\n\nexport type LabelPlacement =\n 'right' | 'left' | 'top' | 'bottom' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';\n\nexport interface Box {\n height: number;\n width: number;\n x: number;\n y: number;\n}\n\nexport interface LabelCandidate {\n height: number;\n key: string | number;\n px: number;\n py: number;\n radius: number;\n width: number;\n}\n\nexport interface PlacedLabel extends Box {\n key: string | number;\n placement: LabelPlacement;\n}\n\n// Ordered by preference; `shift` nudges side labels vertically (in label heights)\nconst PLACEMENTS: Array<{ placement: LabelPlacement; shift?: number }> = [\n { placement: 'right' },\n { placement: 'left' },\n { placement: 'right', shift: -0.5 },\n { placement: 'right', shift: 0.5 },\n { placement: 'left', shift: -0.5 },\n { placement: 'left', shift: 0.5 },\n { placement: 'top-right' },\n { placement: 'bottom-right' },\n { placement: 'top-left' },\n { placement: 'bottom-left' },\n { placement: 'top' },\n { placement: 'bottom' },\n];\n\nconst getLabelBox = (\n { px, py, radius, width, height }: LabelCandidate,\n placement: LabelPlacement,\n gap: number,\n): Box => {\n const offset = radius + gap;\n const diagonal = radius * 0.7 + gap;\n switch (placement) {\n case 'right': {\n return { height, width, x: px + offset, y: py - height / 2 };\n }\n case 'left': {\n return { height, width, x: px - offset - width, y: py - height / 2 };\n }\n case 'top': {\n return { height, width, x: px - width / 2, y: py - offset - height };\n }\n case 'bottom': {\n return { height, width, x: px - width / 2, y: py + offset };\n }\n case 'top-right': {\n return { height, width, x: px + diagonal, y: py - diagonal - height };\n }\n case 'top-left': {\n return { height, width, x: px - diagonal - width, y: py - diagonal - height };\n }\n case 'bottom-right': {\n return { height, width, x: px + diagonal, y: py + diagonal };\n }\n case 'bottom-left': {\n return { height, width, x: px - diagonal - width, y: py + diagonal };\n }\n }\n};\n\nconst overlapArea = (a: Box, b: Box) => {\n const w = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x);\n const h = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y);\n return w > 0 && h > 0 ? w * h : 0;\n};\n\nconst inflate = (box: Box, by: number): Box => ({\n height: box.height + by * 2,\n width: box.width + by * 2,\n x: box.x - by,\n y: box.y - by,\n});\n\nconst outOfBoundsArea = (box: Box, bounds: Box) => {\n const inside = overlapArea(box, bounds);\n return box.width * box.height - inside;\n};\n\n/**\n * Greedy label placement: candidates are processed in the given order,\n * each picks the position with the least overlap against markers,\n * already-placed labels and the outer bounds.\n */\nexport const placeLabels = (\n candidates: LabelCandidate[],\n bounds: Box,\n { gap = 8, lines = [] }: { gap?: number; lines?: Box[] } = {},\n): Map<string | number, PlacedLabel> => {\n const markers: Array<Box & { key: string | number }> = candidates.map((c) => ({\n height: c.radius * 2,\n key: c.key,\n width: c.radius * 2,\n x: c.px - c.radius,\n y: c.py - c.radius,\n }));\n\n const placed = new Map<string | number, PlacedLabel>();\n\n for (const candidate of candidates) {\n let best: PlacedLabel | undefined;\n let bestCost = Infinity;\n\n PLACEMENTS.forEach(({ placement, shift = 0 }, order) => {\n const base = getLabelBox(candidate, placement, gap);\n const box = { ...base, y: base.y + shift * candidate.height };\n let cost = order * 2;\n cost += outOfBoundsArea(box, bounds) * 20;\n for (const marker of markers) {\n if (marker.key === candidate.key) continue;\n cost += overlapArea(inflate(box, 3), marker) * 10;\n }\n for (const label of placed.values()) cost += overlapArea(inflate(box, 2), label) * 8;\n for (const line of lines) cost += overlapArea(box, line) * 1.5;\n\n if (cost < bestCost) {\n bestCost = cost;\n best = { ...box, key: candidate.key, placement };\n }\n });\n\n if (best) placed.set(candidate.key, best);\n }\n\n return placed;\n};\n"],"mappings":";AAQA,MAAM,YAAY,OAAe,UAAkB;CACjD,IAAI,SAAS,KAAK,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CAClD,MAAM,MAAM,QAAQ;CACpB,MAAM,YAAY,MAAM,KAAK,MAAM,KAAK,MAAM,GAAG,CAAC;CAClD,MAAM,aAAa,MAAM;CAEzB,QADa,cAAc,IAAI,IAAI,cAAc,IAAI,IAAI,cAAc,IAAI,IAAI,MACjE;AAChB;AAEA,MAAa,kBAAkB,KAAa,KAAa,QAAQ,MAAM;CACrE,MAAM,OAAO,SAAS,MAAM,KAAK,KAAK;CACtC,MAAM,QAAkB,CAAC;CACzB,MAAM,QAAQ,KAAK,KAAK,MAAM,IAAI,IAAI;CACtC,KAAK,IAAI,QAAQ,OAAO,SAAS,MAAM,OAAO,KAAK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IAAI,OAAO,UAAU;IACnB,WAAW;IACX,OAAO;KAAE,GAAG;KAAK,KAAK,UAAU;KAAK;IAAU;GACjD;EACF,CAAC;EAED,IAAI,MAAM,OAAO,IAAI,UAAU,KAAK,IAAI;CAC1C;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComposedChartProps, SeriesItem, YAxisConfig } from "./types.mjs";
|
|
2
|
+
//#region src/ComposedChart/index.d.ts
|
|
3
|
+
declare const ComposedChart: import("react").ForwardRefExoticComponent<ComposedChartProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { type ComposedChartProps, type SeriesItem, type YAxisConfig, ComposedChart as default };
|
|
6
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,254 @@
|
|
|
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 ChartTooltip from "../common/ChartTooltip/index.mjs";
|
|
6
|
+
import CustomYAxisTick from "../common/CustomYAxisTick.mjs";
|
|
7
|
+
import NoData from "../common/NoData.mjs";
|
|
8
|
+
import { getMaxLabelLength } from "../utils/getMaxLabelLength.mjs";
|
|
9
|
+
import { styles } from "./styles.mjs";
|
|
10
|
+
import { Flexbox } from "@lobehub/ui";
|
|
11
|
+
import { Skeleton } from "@lobehub/ui/base-ui";
|
|
12
|
+
import { css, cssVar, cx } from "antd-style";
|
|
13
|
+
import { forwardRef, useMemo, useState } from "react";
|
|
14
|
+
import { Bar, CartesianGrid, ComposedChart as ComposedChart$1, Label, Legend, Line, ResponsiveContainer, Tooltip as Tooltip$1, XAxis, YAxis } from "recharts";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
//#region src/ComposedChart/index.tsx
|
|
17
|
+
const ComposedChart = forwardRef((props, ref) => {
|
|
18
|
+
const themeColorRange = useThemeColorRange();
|
|
19
|
+
const { data = [], index, series = [], yAxisLeft, yAxisRight, colors = themeColorRange, xAxisLabelFormatter = defaultValueFormatter, startEndOnly = false, animationDuration = 900, showAnimation = false, showXAxis = true, showYAxis = true, intervalType = "equidistantPreserveStart", showTooltip = true, showLegend = true, showGridLines = true, allowDecimals = true, noDataText, enableLegendSlider = false, rotateLabelX, tickGap = 5, loading, xAxisLabel, className, width = "100%", height = 280, style, ...rest } = props;
|
|
20
|
+
const [legendHeight, setLegendHeight] = useState(60);
|
|
21
|
+
const seriesColorMap = useMemo(() => {
|
|
22
|
+
const map = /* @__PURE__ */ new Map();
|
|
23
|
+
series.forEach((s, i) => {
|
|
24
|
+
map.set(s.key, s.color ?? colors[i % colors.length]);
|
|
25
|
+
});
|
|
26
|
+
return map;
|
|
27
|
+
}, [series, colors]);
|
|
28
|
+
const categoryColors = seriesColorMap;
|
|
29
|
+
const customCategories = useMemo(() => {
|
|
30
|
+
return series.reduce((acc, item) => {
|
|
31
|
+
if (item.name) acc[item.key] = item.name;
|
|
32
|
+
return acc;
|
|
33
|
+
}, {});
|
|
34
|
+
}, [series]);
|
|
35
|
+
const hasRightAxis = series.some((s) => s.axis === "right");
|
|
36
|
+
const leftYAxisWidth = useMemo(() => {
|
|
37
|
+
if (yAxisLeft?.width) return yAxisLeft.width;
|
|
38
|
+
const leftFormatter = yAxisLeft?.valueFormatter ?? defaultValueFormatter;
|
|
39
|
+
return getMaxLabelLength({
|
|
40
|
+
data,
|
|
41
|
+
index,
|
|
42
|
+
layout: "horizontal",
|
|
43
|
+
valueFormatter: leftFormatter
|
|
44
|
+
});
|
|
45
|
+
}, [
|
|
46
|
+
yAxisLeft,
|
|
47
|
+
data,
|
|
48
|
+
index
|
|
49
|
+
]);
|
|
50
|
+
const rightYAxisWidth = useMemo(() => {
|
|
51
|
+
if (yAxisRight?.width) return yAxisRight.width;
|
|
52
|
+
const rightFormatter = yAxisRight?.valueFormatter ?? defaultValueFormatter;
|
|
53
|
+
return getMaxLabelLength({
|
|
54
|
+
data,
|
|
55
|
+
index,
|
|
56
|
+
layout: "horizontal",
|
|
57
|
+
valueFormatter: rightFormatter
|
|
58
|
+
});
|
|
59
|
+
}, [
|
|
60
|
+
yAxisRight,
|
|
61
|
+
data,
|
|
62
|
+
index
|
|
63
|
+
]);
|
|
64
|
+
if (loading || !data) return /* @__PURE__ */ jsx(Skeleton, {
|
|
65
|
+
height,
|
|
66
|
+
width
|
|
67
|
+
});
|
|
68
|
+
const paddingValue = !showXAxis && !showYAxis ? 0 : 20;
|
|
69
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
70
|
+
className,
|
|
71
|
+
height,
|
|
72
|
+
ref,
|
|
73
|
+
style: {
|
|
74
|
+
position: "relative",
|
|
75
|
+
...style
|
|
76
|
+
},
|
|
77
|
+
width,
|
|
78
|
+
...rest,
|
|
79
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: data?.length ? /* @__PURE__ */ jsxs(ComposedChart$1, {
|
|
80
|
+
data,
|
|
81
|
+
margin: {
|
|
82
|
+
bottom: xAxisLabel ? 30 : void 0,
|
|
83
|
+
left: yAxisLeft?.label ? 20 : void 0,
|
|
84
|
+
right: hasRightAxis ? yAxisRight?.label ? 20 : 5 : void 0,
|
|
85
|
+
top: 5
|
|
86
|
+
},
|
|
87
|
+
children: [
|
|
88
|
+
showGridLines && /* @__PURE__ */ jsx(CartesianGrid, {
|
|
89
|
+
className: styles.gridLines,
|
|
90
|
+
horizontal: true,
|
|
91
|
+
vertical: false
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
94
|
+
angle: rotateLabelX?.angle,
|
|
95
|
+
axisLine: false,
|
|
96
|
+
className: styles.label,
|
|
97
|
+
dataKey: index,
|
|
98
|
+
dy: rotateLabelX?.verticalShift,
|
|
99
|
+
fill: "",
|
|
100
|
+
hide: !showXAxis,
|
|
101
|
+
interval: startEndOnly ? "preserveStartEnd" : intervalType,
|
|
102
|
+
minTickGap: tickGap,
|
|
103
|
+
padding: {
|
|
104
|
+
left: paddingValue,
|
|
105
|
+
right: paddingValue
|
|
106
|
+
},
|
|
107
|
+
stroke: "",
|
|
108
|
+
tick: { transform: "translate(0, 6)" },
|
|
109
|
+
tickFormatter: xAxisLabelFormatter,
|
|
110
|
+
tickLine: false,
|
|
111
|
+
ticks: startEndOnly ? [data[0][index], data.at(-1)?.[index]] : void 0,
|
|
112
|
+
children: xAxisLabel && /* @__PURE__ */ jsx(Label, {
|
|
113
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
114
|
+
offset: -20,
|
|
115
|
+
position: "insideBottom",
|
|
116
|
+
style: {
|
|
117
|
+
fill: cssVar.colorTextSecondary,
|
|
118
|
+
fontWeight: 500,
|
|
119
|
+
textAnchor: "middle"
|
|
120
|
+
},
|
|
121
|
+
children: xAxisLabel
|
|
122
|
+
})
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
125
|
+
allowDecimals,
|
|
126
|
+
axisLine: false,
|
|
127
|
+
className: styles.label,
|
|
128
|
+
domain: yAxisLeft?.domain,
|
|
129
|
+
fill: "",
|
|
130
|
+
hide: !showYAxis,
|
|
131
|
+
orientation: "left",
|
|
132
|
+
stroke: "",
|
|
133
|
+
tick: (tickProps) => /* @__PURE__ */ jsx(CustomYAxisTick, {
|
|
134
|
+
...tickProps,
|
|
135
|
+
align: "left",
|
|
136
|
+
formatter: yAxisLeft?.valueFormatter ?? defaultValueFormatter,
|
|
137
|
+
yAxisLabel: Boolean(yAxisLeft?.label)
|
|
138
|
+
}),
|
|
139
|
+
tickFormatter: yAxisLeft?.valueFormatter ?? defaultValueFormatter,
|
|
140
|
+
tickLine: false,
|
|
141
|
+
type: "number",
|
|
142
|
+
width: leftYAxisWidth,
|
|
143
|
+
yAxisId: "left",
|
|
144
|
+
children: yAxisLeft?.label && /* @__PURE__ */ jsx(Label, {
|
|
145
|
+
angle: -90,
|
|
146
|
+
className: styles.emphasis,
|
|
147
|
+
offset: -15,
|
|
148
|
+
position: "insideLeft",
|
|
149
|
+
style: {
|
|
150
|
+
fill: cssVar.colorTextSecondary,
|
|
151
|
+
fontWeight: 500,
|
|
152
|
+
textAnchor: "middle"
|
|
153
|
+
},
|
|
154
|
+
children: yAxisLeft.label
|
|
155
|
+
})
|
|
156
|
+
}),
|
|
157
|
+
hasRightAxis && /* @__PURE__ */ jsx(YAxis, {
|
|
158
|
+
allowDecimals,
|
|
159
|
+
axisLine: false,
|
|
160
|
+
className: styles.label,
|
|
161
|
+
domain: yAxisRight?.domain,
|
|
162
|
+
fill: "",
|
|
163
|
+
hide: !showYAxis,
|
|
164
|
+
orientation: "right",
|
|
165
|
+
stroke: "",
|
|
166
|
+
tick: (tickProps) => /* @__PURE__ */ jsx(CustomYAxisTick, {
|
|
167
|
+
...tickProps,
|
|
168
|
+
align: "right",
|
|
169
|
+
anchor: "start",
|
|
170
|
+
formatter: yAxisRight?.valueFormatter ?? defaultValueFormatter,
|
|
171
|
+
yAxisLabel: Boolean(yAxisRight?.label)
|
|
172
|
+
}),
|
|
173
|
+
tickFormatter: yAxisRight?.valueFormatter ?? defaultValueFormatter,
|
|
174
|
+
tickLine: false,
|
|
175
|
+
type: "number",
|
|
176
|
+
width: rightYAxisWidth,
|
|
177
|
+
yAxisId: "right",
|
|
178
|
+
children: yAxisRight?.label && /* @__PURE__ */ jsx(Label, {
|
|
179
|
+
angle: 90,
|
|
180
|
+
className: styles.emphasis,
|
|
181
|
+
offset: -15,
|
|
182
|
+
position: "insideRight",
|
|
183
|
+
style: {
|
|
184
|
+
fill: cssVar.colorTextSecondary,
|
|
185
|
+
fontWeight: 500,
|
|
186
|
+
textAnchor: "middle"
|
|
187
|
+
},
|
|
188
|
+
children: yAxisRight.label
|
|
189
|
+
})
|
|
190
|
+
}),
|
|
191
|
+
showLegend && /* @__PURE__ */ jsx(Legend, {
|
|
192
|
+
content: ({ payload }) => ChartLegend({ payload }, categoryColors, setLegendHeight, void 0, void 0, enableLegendSlider, customCategories),
|
|
193
|
+
height: legendHeight,
|
|
194
|
+
verticalAlign: "top"
|
|
195
|
+
}),
|
|
196
|
+
series.map((s) => {
|
|
197
|
+
const color = seriesColorMap.get(s.key) ?? cssVar.colorPrimary;
|
|
198
|
+
const axisId = s.axis ?? "left";
|
|
199
|
+
if (s.type === "bar") return /* @__PURE__ */ jsx(Bar, {
|
|
200
|
+
animationDuration,
|
|
201
|
+
className: cx(css`
|
|
202
|
+
fill: ${color};
|
|
203
|
+
`),
|
|
204
|
+
dataKey: s.key,
|
|
205
|
+
fill: "",
|
|
206
|
+
isAnimationActive: showAnimation,
|
|
207
|
+
name: s.key,
|
|
208
|
+
yAxisId: axisId
|
|
209
|
+
}, s.key);
|
|
210
|
+
if (s.type === "line") return /* @__PURE__ */ jsx(Line, {
|
|
211
|
+
animationDuration,
|
|
212
|
+
className: cx(css`
|
|
213
|
+
stroke: ${color};
|
|
214
|
+
`),
|
|
215
|
+
dataKey: s.key,
|
|
216
|
+
dot: false,
|
|
217
|
+
isAnimationActive: showAnimation,
|
|
218
|
+
name: s.key,
|
|
219
|
+
stroke: "",
|
|
220
|
+
strokeWidth: 2,
|
|
221
|
+
type: "monotone",
|
|
222
|
+
yAxisId: axisId
|
|
223
|
+
}, s.key);
|
|
224
|
+
return null;
|
|
225
|
+
}),
|
|
226
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip$1, {
|
|
227
|
+
content: ({ active, payload, label }) => /* @__PURE__ */ jsx(ChartTooltip, {
|
|
228
|
+
active,
|
|
229
|
+
categoryColors,
|
|
230
|
+
customCategories,
|
|
231
|
+
label,
|
|
232
|
+
payload,
|
|
233
|
+
valueFormatter: (value, name) => {
|
|
234
|
+
const currentSeries = series.find((item) => item.key === name);
|
|
235
|
+
return (currentSeries?.valueFormatter ?? (currentSeries?.axis === "right" ? yAxisRight?.valueFormatter : yAxisLeft?.valueFormatter) ?? defaultValueFormatter)(value);
|
|
236
|
+
}
|
|
237
|
+
}),
|
|
238
|
+
cursor: {
|
|
239
|
+
stroke: cssVar.colorTextSecondary,
|
|
240
|
+
strokeWidth: 1
|
|
241
|
+
},
|
|
242
|
+
isAnimationActive: false,
|
|
243
|
+
position: { y: 0 },
|
|
244
|
+
wrapperStyle: { outline: "none" }
|
|
245
|
+
})
|
|
246
|
+
]
|
|
247
|
+
}) : /* @__PURE__ */ jsx(NoData, { noDataText }) })
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
ComposedChart.displayName = "ComposedChart";
|
|
251
|
+
//#endregion
|
|
252
|
+
export { ComposedChart as default };
|
|
253
|
+
|
|
254
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["ReChartsComposedChart","Tooltip"],"sources":["../../src/ComposedChart/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 { forwardRef, useMemo, useState } from 'react';\nimport {\n Bar,\n CartesianGrid,\n Label,\n Legend,\n Line,\n ComposedChart as ReChartsComposedChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\n\nimport ChartLegend from '@/common/ChartLegend';\nimport ChartTooltip from '@/common/ChartTooltip';\nimport CustomYAxisTick from '@/common/CustomYAxisTick';\nimport NoData from '@/common/NoData';\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport { defaultValueFormatter } from '@/utils';\nimport { getMaxLabelLength } from '@/utils/getMaxLabelLength';\n\nimport { styles } from './styles';\nimport type { ComposedChartProps } from './types';\n\nexport type { ComposedChartProps, SeriesItem, YAxisConfig } from './types';\n\nconst ComposedChart = forwardRef<HTMLDivElement, ComposedChartProps>((props, ref) => {\n const themeColorRange = useThemeColorRange();\n const {\n data = [],\n index,\n series = [],\n yAxisLeft,\n yAxisRight,\n colors = themeColorRange,\n xAxisLabelFormatter = defaultValueFormatter,\n startEndOnly = false,\n animationDuration = 900,\n showAnimation = false,\n showXAxis = true,\n showYAxis = true,\n intervalType = 'equidistantPreserveStart',\n showTooltip = true,\n showLegend = true,\n showGridLines = true,\n allowDecimals = true,\n noDataText,\n enableLegendSlider = false,\n rotateLabelX,\n tickGap = 5,\n loading,\n xAxisLabel,\n className,\n width = '100%',\n height = 280,\n style,\n ...rest\n } = props;\n\n const [legendHeight, setLegendHeight] = useState(60);\n\n const seriesColorMap = useMemo(() => {\n const map = new Map<string, string>();\n series.forEach((s, i) => {\n map.set(s.key, s.color ?? colors[i % colors.length]);\n });\n return map;\n }, [series, colors]);\n\n const categoryColors = seriesColorMap;\n const customCategories = useMemo(() => {\n return series.reduce<Record<string, string>>((acc, item) => {\n if (item.name) acc[item.key] = item.name;\n return acc;\n }, {});\n }, [series]);\n\n const hasRightAxis = series.some((s) => s.axis === 'right');\n\n const leftYAxisWidth = useMemo(() => {\n if (yAxisLeft?.width) return yAxisLeft.width;\n const leftFormatter = yAxisLeft?.valueFormatter ?? defaultValueFormatter;\n return getMaxLabelLength({ data, index, layout: 'horizontal', valueFormatter: leftFormatter });\n }, [yAxisLeft, data, index]);\n\n const rightYAxisWidth = useMemo(() => {\n if (yAxisRight?.width) return yAxisRight.width;\n const rightFormatter = yAxisRight?.valueFormatter ?? defaultValueFormatter;\n return getMaxLabelLength({ data, index, layout: 'horizontal', valueFormatter: rightFormatter });\n }, [yAxisRight, data, index]);\n\n if (loading || !data) return <Skeleton height={height} width={width} />;\n\n const paddingValue = !showXAxis && !showYAxis ? 0 : 20;\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 <ReChartsComposedChart\n data={data}\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLeft?.label ? 20 : undefined,\n right: hasRightAxis ? (yAxisRight?.label ? 20 : 5) : undefined,\n top: 5,\n }}\n >\n {showGridLines && (\n <CartesianGrid className={styles.gridLines} horizontal vertical={false} />\n )}\n\n <XAxis\n angle={rotateLabelX?.angle}\n axisLine={false}\n className={styles.label}\n dataKey={index}\n dy={rotateLabelX?.verticalShift}\n fill=\"\"\n hide={!showXAxis}\n interval={startEndOnly ? 'preserveStartEnd' : intervalType}\n minTickGap={tickGap}\n padding={{ left: paddingValue, right: paddingValue }}\n stroke=\"\"\n tick={{ transform: 'translate(0, 6)' }}\n tickFormatter={xAxisLabelFormatter}\n tickLine={false}\n ticks={startEndOnly ? [data[0][index], data.at(-1)?.[index]] : undefined}\n >\n {xAxisLabel && (\n <Label\n className={cx(styles.strongLabel, styles.emphasis)}\n offset={-20}\n position=\"insideBottom\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {xAxisLabel}\n </Label>\n )}\n </XAxis>\n\n {/* Left Y Axis */}\n <YAxis\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.label}\n domain={yAxisLeft?.domain}\n fill=\"\"\n hide={!showYAxis}\n orientation=\"left\"\n stroke=\"\"\n tick={(tickProps) => (\n <CustomYAxisTick\n {...tickProps}\n align=\"left\"\n formatter={yAxisLeft?.valueFormatter ?? defaultValueFormatter}\n yAxisLabel={Boolean(yAxisLeft?.label)}\n />\n )}\n tickFormatter={yAxisLeft?.valueFormatter ?? defaultValueFormatter}\n tickLine={false}\n type=\"number\"\n width={leftYAxisWidth}\n yAxisId=\"left\"\n >\n {yAxisLeft?.label && (\n <Label\n angle={-90}\n className={styles.emphasis}\n offset={-15}\n position=\"insideLeft\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {yAxisLeft.label}\n </Label>\n )}\n </YAxis>\n\n {/* Right Y Axis */}\n {hasRightAxis && (\n <YAxis\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.label}\n domain={yAxisRight?.domain}\n fill=\"\"\n hide={!showYAxis}\n orientation=\"right\"\n stroke=\"\"\n tick={(tickProps) => (\n <CustomYAxisTick\n {...tickProps}\n align=\"right\"\n anchor=\"start\"\n formatter={yAxisRight?.valueFormatter ?? defaultValueFormatter}\n yAxisLabel={Boolean(yAxisRight?.label)}\n />\n )}\n tickFormatter={yAxisRight?.valueFormatter ?? defaultValueFormatter}\n tickLine={false}\n type=\"number\"\n width={rightYAxisWidth}\n yAxisId=\"right\"\n >\n {yAxisRight?.label && (\n <Label\n angle={90}\n className={styles.emphasis}\n offset={-15}\n position=\"insideRight\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {yAxisRight.label}\n </Label>\n )}\n </YAxis>\n )}\n\n {showLegend && (\n <Legend\n content={({ payload }) =>\n ChartLegend(\n { payload },\n categoryColors,\n setLegendHeight,\n undefined,\n undefined,\n enableLegendSlider,\n customCategories,\n )\n }\n height={legendHeight}\n verticalAlign=\"top\"\n />\n )}\n\n {series.map((s) => {\n const color = seriesColorMap.get(s.key) ?? cssVar.colorPrimary;\n const axisId = s.axis ?? 'left';\n\n if (s.type === 'bar') {\n return (\n <Bar\n animationDuration={animationDuration}\n className={cx(css`\n fill: ${color};\n `)}\n dataKey={s.key}\n fill=\"\"\n isAnimationActive={showAnimation}\n key={s.key}\n name={s.key}\n yAxisId={axisId}\n />\n );\n }\n\n if (s.type === 'line') {\n return (\n <Line\n animationDuration={animationDuration}\n className={cx(css`\n stroke: ${color};\n `)}\n dataKey={s.key}\n dot={false}\n isAnimationActive={showAnimation}\n key={s.key}\n name={s.key}\n stroke=\"\"\n strokeWidth={2}\n type=\"monotone\"\n yAxisId={axisId}\n />\n );\n }\n\n return null;\n })}\n\n {showTooltip && (\n <Tooltip\n content={({ active, payload, label }) => (\n <ChartTooltip\n active={active}\n categoryColors={categoryColors}\n customCategories={customCategories}\n label={label}\n payload={payload}\n valueFormatter={(value, name) => {\n const currentSeries = series.find((item) => item.key === name);\n const formatter =\n currentSeries?.valueFormatter ??\n (currentSeries?.axis === 'right'\n ? yAxisRight?.valueFormatter\n : yAxisLeft?.valueFormatter) ??\n defaultValueFormatter;\n\n return formatter(value);\n }}\n />\n )}\n cursor={{ stroke: cssVar.colorTextSecondary, strokeWidth: 1 }}\n isAnimationActive={false}\n position={{ y: 0 }}\n wrapperStyle={{ outline: 'none' }}\n />\n )}\n </ReChartsComposedChart>\n ) : (\n <NoData noDataText={noDataText} />\n )}\n </ResponsiveContainer>\n </Flexbox>\n );\n});\n\nComposedChart.displayName = 'ComposedChart';\n\nexport default ComposedChart;\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,gBAAgB,YAAgD,OAAO,QAAQ;CACnF,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,EACJ,OAAO,CAAC,GACR,OACA,SAAS,CAAC,GACV,WACA,YACA,SAAS,iBACT,sBAAsB,uBACtB,eAAe,OACf,oBAAoB,KACpB,gBAAgB,OAChB,YAAY,MACZ,YAAY,MACZ,eAAe,4BACf,cAAc,MACd,aAAa,MACb,gBAAgB,MAChB,gBAAgB,MAChB,YACA,qBAAqB,OACrB,cACA,UAAU,GACV,SACA,YACA,WACA,QAAQ,QACR,SAAS,KACT,OACA,GAAG,SACD;CAEJ,MAAM,CAAC,cAAc,mBAAmB,SAAS,EAAE;CAEnD,MAAM,iBAAiB,cAAc;EACnC,MAAM,sBAAM,IAAI,IAAoB;EACpC,OAAO,SAAS,GAAG,MAAM;GACvB,IAAI,IAAI,EAAE,KAAK,EAAE,SAAS,OAAO,IAAI,OAAO,OAAO;EACrD,CAAC;EACD,OAAO;CACT,GAAG,CAAC,QAAQ,MAAM,CAAC;CAEnB,MAAM,iBAAiB;CACvB,MAAM,mBAAmB,cAAc;EACrC,OAAO,OAAO,QAAgC,KAAK,SAAS;GAC1D,IAAI,KAAK,MAAM,IAAI,KAAK,OAAO,KAAK;GACpC,OAAO;EACT,GAAG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AAU,EAAE,GAAG,EAAE;KACjB,cAAc,EAAE,SAAS,OAAO;IACjC,CAAA;GAEkB;EAEvB,CAAA,IAAA,oBAAC,QAAD,EAAoB,WAAa,CAAA,EAEhB,CAAA;CACd,CAAA;AAEb,CAAC;AAED,cAAc,cAAc"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createStaticStyles } from "antd-style";
|
|
2
|
+
//#region src/ComposedChart/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/ComposedChart/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,71 @@
|
|
|
1
|
+
import { NoDataProps } from "../common/NoData.mjs";
|
|
2
|
+
import { IntervalType, LabelFormatter, ValueFormatter } from "../types/charts.mjs";
|
|
3
|
+
import BaseAnimationTimingProps from "../common/BaseAnimationTimingProps.mjs";
|
|
4
|
+
import { HTMLAttributes } from "react";
|
|
5
|
+
import { AxisDomain } from "recharts/types/util/types";
|
|
6
|
+
//#region src/ComposedChart/types.d.ts
|
|
7
|
+
export interface SeriesItem {
|
|
8
|
+
/**
|
|
9
|
+
* Which y-axis this series is bound to.
|
|
10
|
+
* @default 'left'
|
|
11
|
+
*/
|
|
12
|
+
axis?: 'left' | 'right';
|
|
13
|
+
/** Override color for this series. Falls back to the chart-level `colors` array. */
|
|
14
|
+
color?: string;
|
|
15
|
+
/** Data key in the `data` array */
|
|
16
|
+
key: string;
|
|
17
|
+
/** Display name shown in legend / tooltip. Defaults to `key`. */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Chart type for this series */
|
|
20
|
+
type: 'bar' | 'line';
|
|
21
|
+
/** Per-series value formatter used in tooltip */
|
|
22
|
+
valueFormatter?: ValueFormatter;
|
|
23
|
+
}
|
|
24
|
+
export interface YAxisConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Forward to recharts `YAxis.domain`.
|
|
27
|
+
* Accepts numbers or `'auto'` / `'dataMin'` / `'dataMax'` / `'dataMin - N'` etc.
|
|
28
|
+
*/
|
|
29
|
+
domain?: AxisDomain;
|
|
30
|
+
/** Label string rendered alongside the axis */
|
|
31
|
+
label?: string;
|
|
32
|
+
/** Custom tick formatter */
|
|
33
|
+
valueFormatter?: ValueFormatter;
|
|
34
|
+
/** Fixed axis width in pixels */
|
|
35
|
+
width?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface ComposedChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {
|
|
38
|
+
allowDecimals?: boolean;
|
|
39
|
+
colors?: string[];
|
|
40
|
+
data: any[];
|
|
41
|
+
enableLegendSlider?: boolean;
|
|
42
|
+
height?: string | number;
|
|
43
|
+
/** The key in `data` used as the shared x-axis category */
|
|
44
|
+
index: string;
|
|
45
|
+
intervalType?: IntervalType;
|
|
46
|
+
loading?: boolean;
|
|
47
|
+
noDataText?: NoDataProps['noDataText'];
|
|
48
|
+
rotateLabelX?: {
|
|
49
|
+
angle: number;
|
|
50
|
+
verticalShift?: number;
|
|
51
|
+
xAxisHeight?: number;
|
|
52
|
+
};
|
|
53
|
+
/** Series definitions — each item maps to a Bar or Line renderer */
|
|
54
|
+
series: SeriesItem[];
|
|
55
|
+
showGridLines?: boolean;
|
|
56
|
+
showLegend?: boolean;
|
|
57
|
+
showTooltip?: boolean;
|
|
58
|
+
showXAxis?: boolean;
|
|
59
|
+
showYAxis?: boolean;
|
|
60
|
+
startEndOnly?: boolean;
|
|
61
|
+
tickGap?: number;
|
|
62
|
+
width?: string | number;
|
|
63
|
+
xAxisLabel?: string;
|
|
64
|
+
xAxisLabelFormatter?: LabelFormatter;
|
|
65
|
+
/** Left y-axis configuration */
|
|
66
|
+
yAxisLeft?: YAxisConfig;
|
|
67
|
+
/** Right y-axis configuration */
|
|
68
|
+
yAxisRight?: YAxisConfig;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//# sourceMappingURL=types.d.mts.map
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ValueFormatter } from "../types/charts.mjs";
|
|
2
|
+
import { FlexboxProps } from "@lobehub/ui";
|
|
3
|
+
//#region src/DataBars/CategoryBar.d.ts
|
|
4
|
+
export interface CategoryBarProps extends FlexboxProps {
|
|
5
|
+
colors?: string[];
|
|
6
|
+
markerValue?: number;
|
|
7
|
+
showAnimation?: boolean;
|
|
8
|
+
showLabels?: boolean;
|
|
9
|
+
size?: number;
|
|
10
|
+
tooltip?: string;
|
|
11
|
+
valueFormatter?: ValueFormatter;
|
|
12
|
+
values: number[];
|
|
13
|
+
}
|
|
14
|
+
declare const CategoryBar: import("react").ForwardRefExoticComponent<Omit<CategoryBarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { CategoryBar as default };
|
|
17
|
+
//# sourceMappingURL=CategoryBar.d.mts.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange.mjs";
|
|
3
|
+
import { defaultValueFormatter, sumNumericArray } from "../utils/index.mjs";
|
|
4
|
+
import { styles } from "./styles.mjs";
|
|
5
|
+
import { Flexbox } from "@lobehub/ui";
|
|
6
|
+
import { Tooltip } from "@lobehub/ui/base-ui";
|
|
7
|
+
import { cssVar, cx } from "antd-style";
|
|
8
|
+
import { forwardRef, memo, useMemo } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/DataBars/CategoryBar.tsx
|
|
11
|
+
const getMarkerBgColor = (markerValue, values, colors) => {
|
|
12
|
+
if (markerValue === void 0) return "";
|
|
13
|
+
let prefixSum = 0;
|
|
14
|
+
for (const [i, currentWidthPercentage] of values.entries()) {
|
|
15
|
+
const currentBgColor = colors[i];
|
|
16
|
+
prefixSum += currentWidthPercentage;
|
|
17
|
+
if (prefixSum >= markerValue) return currentBgColor;
|
|
18
|
+
}
|
|
19
|
+
return "";
|
|
20
|
+
};
|
|
21
|
+
const getPositionLeft = (value, maxValue) => value ? value / maxValue * 100 : 0;
|
|
22
|
+
const BarLabels = memo(({ values, valueFormatter }) => {
|
|
23
|
+
const sumValues = useMemo(() => sumNumericArray(values), [values]);
|
|
24
|
+
let prefixSum = 0;
|
|
25
|
+
let sumConsecutiveHiddenLabels = 0;
|
|
26
|
+
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
27
|
+
className: cx(styles.label, styles.emphasis),
|
|
28
|
+
horizontal: true,
|
|
29
|
+
style: { position: "relative" },
|
|
30
|
+
children: [
|
|
31
|
+
values.slice(0, values.length).map((widthPercentage, idx) => {
|
|
32
|
+
prefixSum += widthPercentage;
|
|
33
|
+
const showLabel = (widthPercentage >= .1 * sumValues || sumConsecutiveHiddenLabels >= .09 * sumValues) && sumValues - prefixSum >= .15 * sumValues && prefixSum >= .1 * sumValues;
|
|
34
|
+
sumConsecutiveHiddenLabels = showLabel ? 0 : sumConsecutiveHiddenLabels += widthPercentage;
|
|
35
|
+
const widthPositionLeft = getPositionLeft(widthPercentage, sumValues);
|
|
36
|
+
if (prefixSum === sumValues) return null;
|
|
37
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
38
|
+
align: "center",
|
|
39
|
+
horizontal: true,
|
|
40
|
+
justify: "flex-end",
|
|
41
|
+
style: { width: `${widthPositionLeft}%` },
|
|
42
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
43
|
+
style: {
|
|
44
|
+
display: showLabel ? "block" : "hidden",
|
|
45
|
+
left: "50%",
|
|
46
|
+
transform: "translateX(50%)"
|
|
47
|
+
},
|
|
48
|
+
children: valueFormatter ? valueFormatter(prefixSum) : prefixSum
|
|
49
|
+
})
|
|
50
|
+
}, `item-${idx}`);
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx(Flexbox, {
|
|
53
|
+
align: "center",
|
|
54
|
+
horizontal: true,
|
|
55
|
+
style: {
|
|
56
|
+
bottom: 0,
|
|
57
|
+
left: 0,
|
|
58
|
+
position: "absolute"
|
|
59
|
+
},
|
|
60
|
+
children: valueFormatter ? valueFormatter(0) : 0
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ jsx(Flexbox, {
|
|
63
|
+
align: "center",
|
|
64
|
+
horizontal: true,
|
|
65
|
+
style: {
|
|
66
|
+
bottom: 0,
|
|
67
|
+
position: "absolute",
|
|
68
|
+
right: 0
|
|
69
|
+
},
|
|
70
|
+
children: valueFormatter ? valueFormatter(sumValues) : sumValues
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
const CategoryBar = forwardRef((props, ref) => {
|
|
76
|
+
const themeColorRange = useThemeColorRange();
|
|
77
|
+
const { values = [], colors = themeColorRange, valueFormatter = defaultValueFormatter, markerValue, showLabels = true, tooltip, showAnimation = false, className, width = "100%", size = 8, style, ...rest } = props;
|
|
78
|
+
const colorGroup = colors.concat(themeColorRange);
|
|
79
|
+
const markerBgColor = useMemo(() => getMarkerBgColor(markerValue, values, colorGroup), [
|
|
80
|
+
markerValue,
|
|
81
|
+
values,
|
|
82
|
+
colorGroup
|
|
83
|
+
]);
|
|
84
|
+
const maxValue = useMemo(() => sumNumericArray(values), [values]);
|
|
85
|
+
const markerPositionLeft = useMemo(() => getPositionLeft(markerValue, maxValue), [markerValue, maxValue]);
|
|
86
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
87
|
+
title: tooltip,
|
|
88
|
+
children: /* @__PURE__ */ jsxs(Flexbox, {
|
|
89
|
+
className,
|
|
90
|
+
gap: 8,
|
|
91
|
+
ref,
|
|
92
|
+
style: {
|
|
93
|
+
position: "relative",
|
|
94
|
+
...style
|
|
95
|
+
},
|
|
96
|
+
width,
|
|
97
|
+
...rest,
|
|
98
|
+
children: [showLabels && /* @__PURE__ */ jsx(BarLabels, {
|
|
99
|
+
valueFormatter,
|
|
100
|
+
values
|
|
101
|
+
}), /* @__PURE__ */ jsxs(Flexbox, {
|
|
102
|
+
align: "center",
|
|
103
|
+
className: cx("relative w-full flex items-center h-2"),
|
|
104
|
+
height: size,
|
|
105
|
+
horizontal: true,
|
|
106
|
+
style: { position: "relative" },
|
|
107
|
+
children: [/* @__PURE__ */ jsx(Flexbox, {
|
|
108
|
+
align: "center",
|
|
109
|
+
height: "100%",
|
|
110
|
+
horizontal: true,
|
|
111
|
+
style: {
|
|
112
|
+
borderRadius: size / 2,
|
|
113
|
+
overflow: "hidden"
|
|
114
|
+
},
|
|
115
|
+
width: "100%",
|
|
116
|
+
children: values.map((value, idx) => {
|
|
117
|
+
const baseColor = colorGroup[idx] ?? cssVar.colorPrimary;
|
|
118
|
+
const percentage = value / maxValue * 100;
|
|
119
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
120
|
+
height: "100%",
|
|
121
|
+
style: {
|
|
122
|
+
background: baseColor,
|
|
123
|
+
width: `${percentage}%`
|
|
124
|
+
}
|
|
125
|
+
}, `item-${idx}`);
|
|
126
|
+
})
|
|
127
|
+
}), markerValue === void 0 ? void 0 : /* @__PURE__ */ jsx("div", {
|
|
128
|
+
className: cx(styles.markerWrapper, showAnimation && styles.showAnimation),
|
|
129
|
+
style: { left: `${markerPositionLeft}%` },
|
|
130
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
131
|
+
className: styles.marker,
|
|
132
|
+
style: {
|
|
133
|
+
background: markerBgColor || cssVar.colorPrimary,
|
|
134
|
+
height: size + 8
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
})]
|
|
138
|
+
})]
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
CategoryBar.displayName = "CategoryBar";
|
|
143
|
+
//#endregion
|
|
144
|
+
export { CategoryBar as default };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=CategoryBar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CategoryBar.mjs","names":[],"sources":["../../src/DataBars/CategoryBar.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox, FlexboxProps } from '@lobehub/ui';\nimport { Tooltip } from '@lobehub/ui/base-ui';\nimport { cssVar, cx } from 'antd-style';\nimport { forwardRef, memo, useMemo } from 'react';\n\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport { ValueFormatter } from '@/types/charts';\nimport { defaultValueFormatter, sumNumericArray } from '@/utils';\n\nimport { styles } from './styles';\n\nconst getMarkerBgColor = (\n markerValue: number | undefined,\n values: number[],\n colors: string[],\n): string => {\n if (markerValue === undefined) return '';\n\n let prefixSum = 0;\n for (const [i, currentWidthPercentage] of values.entries()) {\n const currentBgColor = colors[i];\n\n prefixSum += currentWidthPercentage;\n if (prefixSum >= markerValue) return currentBgColor;\n }\n\n return '';\n};\n\nconst getPositionLeft = (value: number | undefined, maxValue: number): number =>\n value ? (value / maxValue) * 100 : 0;\n\nconst BarLabels = memo<{ valueFormatter?: ValueFormatter; values: number[] }>(\n ({ values, valueFormatter }) => {\n const sumValues = useMemo(() => sumNumericArray(values), [values]);\n let prefixSum = 0;\n let sumConsecutiveHiddenLabels = 0;\n return (\n <Flexbox\n className={cx(styles.label, styles.emphasis)}\n horizontal\n style={{\n position: 'relative',\n }}\n >\n {values.slice(0, values.length).map((widthPercentage, idx) => {\n prefixSum += widthPercentage;\n const showLabel =\n (widthPercentage >= 0.1 * sumValues ||\n sumConsecutiveHiddenLabels >= 0.09 * sumValues) &&\n sumValues - prefixSum >= 0.15 * sumValues &&\n prefixSum >= 0.1 * sumValues;\n sumConsecutiveHiddenLabels = showLabel\n ? 0\n : (sumConsecutiveHiddenLabels += widthPercentage);\n\n const widthPositionLeft = getPositionLeft(widthPercentage, sumValues);\n\n if (prefixSum === sumValues) return null;\n\n return (\n <Flexbox\n align={'center'}\n horizontal\n justify={'flex-end'}\n key={`item-${idx}`}\n style={{ width: `${widthPositionLeft}%` }}\n >\n <span\n style={{\n display: showLabel ? 'block' : 'hidden',\n left: '50%',\n transform: 'translateX(50%)',\n }}\n >\n {valueFormatter ? valueFormatter(prefixSum) : prefixSum}\n </span>\n </Flexbox>\n );\n })}\n <Flexbox align={'center'} horizontal style={{ bottom: 0, left: 0, position: 'absolute' }}>\n {valueFormatter ? valueFormatter(0) : 0}\n </Flexbox>\n <Flexbox align={'center'} horizontal style={{ bottom: 0, position: 'absolute', right: 0 }}>\n {valueFormatter ? valueFormatter(sumValues) : sumValues}\n </Flexbox>\n </Flexbox>\n );\n },\n);\n\nexport interface CategoryBarProps extends FlexboxProps {\n colors?: string[];\n markerValue?: number;\n showAnimation?: boolean;\n showLabels?: boolean;\n size?: number;\n tooltip?: string;\n valueFormatter?: ValueFormatter;\n values: number[];\n}\n\nconst CategoryBar = forwardRef<HTMLDivElement, CategoryBarProps>((props, ref) => {\n const themeColorRange = useThemeColorRange();\n const {\n values = [],\n colors = themeColorRange,\n valueFormatter = defaultValueFormatter,\n markerValue,\n showLabels = true,\n tooltip,\n showAnimation = false,\n className,\n width = '100%',\n size = 8,\n style,\n ...rest\n } = props;\n\n const colorGroup = colors.concat(themeColorRange);\n\n const markerBgColor = useMemo(\n () => getMarkerBgColor(markerValue, values, colorGroup),\n [markerValue, values, colorGroup],\n );\n\n const maxValue = useMemo(() => sumNumericArray(values), [values]);\n\n const markerPositionLeft: number = useMemo(\n () => getPositionLeft(markerValue, maxValue),\n [markerValue, maxValue],\n );\n\n return (\n <Tooltip title={tooltip}>\n <Flexbox\n className={className}\n gap={8}\n ref={ref}\n style={{\n position: 'relative',\n ...style,\n }}\n width={width}\n {...rest}\n >\n {showLabels && <BarLabels valueFormatter={valueFormatter} values={values} />}\n <Flexbox\n align={'center'}\n className={cx('relative w-full flex items-center h-2')}\n height={size}\n horizontal\n style={{\n position: 'relative',\n }}\n >\n <Flexbox\n align={'center'}\n height={'100%'}\n horizontal\n style={{\n borderRadius: size / 2,\n overflow: 'hidden',\n }}\n width={'100%'}\n >\n {values.map((value, idx) => {\n const baseColor = colorGroup[idx] ?? cssVar.colorPrimary;\n const percentage = (value / maxValue) * 100;\n return (\n <Flexbox\n height={'100%'}\n key={`item-${idx}`}\n style={{ background: baseColor, width: `${percentage}%` }}\n />\n );\n })}\n </Flexbox>\n {markerValue === undefined ? undefined : (\n <div\n className={cx(styles.markerWrapper, showAnimation && styles.showAnimation)}\n style={{\n left: `${markerPositionLeft}%`,\n }}\n >\n <div\n className={styles.marker}\n style={{\n background: markerBgColor || cssVar.colorPrimary,\n height: size + 8,\n }}\n />\n </div>\n )}\n </Flexbox>\n </Flexbox>\n </Tooltip>\n );\n});\n\nCategoryBar.displayName = 'CategoryBar';\n\nexport default CategoryBar;\n"],"mappings":";;;;;;;;;;AAaA,MAAM,oBACJ,aACA,QACA,WACW;CACX,IAAI,gBAAgB,KAAA,GAAW,OAAO;CAEtC,IAAI,YAAY;CAChB,KAAK,MAAM,CAAC,GAAG,2BAA2B,OAAO,QAAQ,GAAG;EAC1D,MAAM,iBAAiB,OAAO;EAE9B,aAAa;EACb,IAAI,aAAa,aAAa,OAAO;CACvC;CAEA,OAAO;AACT;AAEA,MAAM,mBAAmB,OAA2B,aAClD,QAAS,QAAQ,WAAY,MAAM;AAErC,MAAM,YAAY,MACf,EAAE,QAAQ,qBAAqB;CAC9B,MAAM,YAAY,cAAc,gBAAgB,MAAM,GAAG,CAAC,MAAM,CAAC;CACjE,IAAI,YAAY;CAChB,IAAI,6BAA6B;CACjC,OACE,qBAAC,SAAD;EACE,WAAW,GAAG,OAAO,OAAO,OAAO,QAAQ;EAC3C,YAAA;EACA,OAAO,EACL,UAAU,WACZ;EALF,UAAA;GAOG,OAAO,MAAM,GAAG,OAAO,MAAM,CAAC,CAAC,KAAK,iBAAiB,QAAQ;IAC5D,aAAa;IACb,MAAM,aACH,mBAAmB,KAAM,aACxB,8BAA8B,MAAO,cACvC,YAAY,aAAa,MAAO,aAChC,aAAa,KAAM;IACrB,6BAA6B,YACzB,IACC,8BAA8B;IAEnC,MAAM,oBAAoB,gBAAgB,iBAAiB,SAAS;IAEpE,IAAI,cAAc,WAAW,OAAO;IAEpC,OACE,oBAAC,SAAD;KACE,OAAO;KACP,YAAA;KACA,SAAS;KAET,OAA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AAO;IACP,WAAW,GAAG,uCAAuC;IACrD,QAAQ;IACR,YAAA;IACA,OAAO,EACL,UAAU,WACZ;IAPF,UAAA,CASE,oBAAC,SAAD;KACE,OAAO;KACP,QAAQ;KACR,YAAA;KACA,OAAO;MACL,cAAc,OAAO;MACrB,UAAU;KACZ;KACA,OAAO;KAEN,UAAA,OAAO,KAAK,OAAO,QAAQ;MAC1B,MAAM,YAAY,WAAW,QAAQ,OAAO;MAC5C,MAAM,aAAc,QAAQ,WAAY;MACxC,OACE,oBAAC,SAAD;OACE,QAAQ;OAER,OAAO;QAAE,YAAY;QAAW,OAAO,GAAG,WAAW;OAAG;MACzD,GAFM,QAAQ,KAEd;KAEL,CAAC;IACM,CAAA,GACR,gBAAgB,KAAA,IAAY,KAAA,IAC3B,oBAAC,OAAD;KACE,WAAW,GAAG,OAAO,eAAe,iBAAiB,OAAO,aAAa;KACzE,OAAO,EACL,MAAM,GAAG,mBAAmB,GAC9B;KAEA,UAAA,oBAAC,OAAD;MACE,WAAW,OAAO;MAClB,OAAO;OACL,YAAY,iBAAiB,OAAO;OACpC,QAAQ,OAAO;MACjB;KACD,CAAA;IACE,CAAA,CAEA;GACF,CAAA,CAAA;;CACF,CAAA;AAEb,CAAC;AAED,YAAY,cAAc"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FlexboxProps } from "@lobehub/ui";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/DataBars/DeltaBar.d.ts
|
|
4
|
+
export interface DeltaBarProps extends FlexboxProps {
|
|
5
|
+
bgColors?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
isIncreasePositive?: boolean;
|
|
8
|
+
showAnimation?: boolean;
|
|
9
|
+
size?: number;
|
|
10
|
+
tooltip?: ReactNode;
|
|
11
|
+
value: number;
|
|
12
|
+
}
|
|
13
|
+
declare const DeltaBar: import("react").ForwardRefExoticComponent<Omit<DeltaBarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DeltaBar as default };
|
|
16
|
+
//# sourceMappingURL=DeltaBar.d.mts.map
|