@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,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DeltaTypes } from "../types/charts.mjs";
|
|
3
|
+
import { mapInputsToDeltaType } 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 } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/DataBars/DeltaBar.tsx
|
|
11
|
+
const getDeltaType = (value) => value >= 0 ? DeltaTypes.Increase : DeltaTypes.Decrease;
|
|
12
|
+
const DeltaBar = forwardRef((props, ref) => {
|
|
13
|
+
const { value, bgColors, color, isIncreasePositive = true, showAnimation = false, className, tooltip, width = "100%", size = 8, style, ...rest } = props;
|
|
14
|
+
const deltaType = mapInputsToDeltaType(getDeltaType(value), isIncreasePositive);
|
|
15
|
+
const colors = {
|
|
16
|
+
[DeltaTypes.Increase]: cssVar.colorSuccess,
|
|
17
|
+
[DeltaTypes.ModerateIncrease]: cssVar.colorSuccess,
|
|
18
|
+
[DeltaTypes.Decrease]: cssVar.colorError,
|
|
19
|
+
[DeltaTypes.ModerateDecrease]: cssVar.colorError,
|
|
20
|
+
[DeltaTypes.Unchanged]: cssVar.colorWarning
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
23
|
+
title: tooltip,
|
|
24
|
+
children: /* @__PURE__ */ jsxs(Flexbox, {
|
|
25
|
+
align: "center",
|
|
26
|
+
className,
|
|
27
|
+
height: size,
|
|
28
|
+
horizontal: true,
|
|
29
|
+
ref,
|
|
30
|
+
style: {
|
|
31
|
+
position: "relative",
|
|
32
|
+
...style
|
|
33
|
+
},
|
|
34
|
+
width,
|
|
35
|
+
...rest,
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsx(Flexbox, {
|
|
38
|
+
height: "100%",
|
|
39
|
+
style: {
|
|
40
|
+
background: bgColors || cssVar.colorFillTertiary,
|
|
41
|
+
borderRadius: size / 2,
|
|
42
|
+
inset: 0,
|
|
43
|
+
opacity: bgColors ? .2 : 1,
|
|
44
|
+
position: "absolute",
|
|
45
|
+
zIndex: 0
|
|
46
|
+
},
|
|
47
|
+
width: "100%"
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ jsx(Flexbox, {
|
|
50
|
+
align: "center",
|
|
51
|
+
flex: 1,
|
|
52
|
+
height: "100%",
|
|
53
|
+
horizontal: true,
|
|
54
|
+
justify: "flex-end",
|
|
55
|
+
style: { position: "relative" },
|
|
56
|
+
children: value < 0 ? /* @__PURE__ */ jsx("div", {
|
|
57
|
+
className: cx(showAnimation && styles.showAnimation),
|
|
58
|
+
style: {
|
|
59
|
+
background: colors[deltaType],
|
|
60
|
+
borderBottomLeftRadius: size / 2,
|
|
61
|
+
borderTopLeftRadius: size / 2,
|
|
62
|
+
height: "100%",
|
|
63
|
+
width: `${Math.abs(value)}%`
|
|
64
|
+
}
|
|
65
|
+
}) : void 0
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ jsx(Flexbox, {
|
|
68
|
+
className: styles.marker,
|
|
69
|
+
flex: "none",
|
|
70
|
+
style: {
|
|
71
|
+
background: color || cssVar.colorPrimary,
|
|
72
|
+
height: size + 8,
|
|
73
|
+
zIndex: 2
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx(Flexbox, {
|
|
77
|
+
align: "center",
|
|
78
|
+
flex: 1,
|
|
79
|
+
height: "100%",
|
|
80
|
+
horizontal: true,
|
|
81
|
+
justify: "flex-start",
|
|
82
|
+
style: { position: "relative" },
|
|
83
|
+
children: value >= 0 ? /* @__PURE__ */ jsx("div", {
|
|
84
|
+
className: cx(showAnimation && styles.showAnimation),
|
|
85
|
+
style: {
|
|
86
|
+
background: colors[deltaType],
|
|
87
|
+
borderBottomRightRadius: size / 2,
|
|
88
|
+
borderTopRightRadius: size / 2,
|
|
89
|
+
height: "100%",
|
|
90
|
+
width: `${Math.abs(value)}%`
|
|
91
|
+
}
|
|
92
|
+
}) : void 0
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
DeltaBar.displayName = "DeltaBar";
|
|
99
|
+
//#endregion
|
|
100
|
+
export { DeltaBar as default };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=DeltaBar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeltaBar.mjs","names":[],"sources":["../../src/DataBars/DeltaBar.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 { ReactNode, forwardRef } from 'react';\n\nimport { DeltaTypes } from '@/types/charts';\nimport { mapInputsToDeltaType } from '@/utils';\n\nimport { styles } from './styles';\n\nconst getDeltaType = (value: number) => (value >= 0 ? DeltaTypes.Increase : DeltaTypes.Decrease);\n\nexport interface DeltaBarProps extends FlexboxProps {\n bgColors?: string;\n color?: string;\n isIncreasePositive?: boolean;\n showAnimation?: boolean;\n size?: number;\n tooltip?: ReactNode;\n value: number;\n}\n\nconst DeltaBar = forwardRef<HTMLDivElement, DeltaBarProps>((props, ref) => {\n const {\n value,\n bgColors,\n color,\n isIncreasePositive = true,\n showAnimation = false,\n className,\n tooltip,\n width = '100%',\n size = 8,\n style,\n ...rest\n } = props;\n const deltaType = mapInputsToDeltaType(getDeltaType(value), isIncreasePositive);\n\n const colors = {\n [DeltaTypes.Increase]: cssVar.colorSuccess,\n [DeltaTypes.ModerateIncrease]: cssVar.colorSuccess,\n [DeltaTypes.Decrease]: cssVar.colorError,\n [DeltaTypes.ModerateDecrease]: cssVar.colorError,\n [DeltaTypes.Unchanged]: cssVar.colorWarning,\n };\n\n return (\n <Tooltip title={tooltip}>\n <Flexbox\n align={'center'}\n className={className}\n height={size}\n horizontal\n ref={ref}\n style={{\n position: 'relative',\n ...style,\n }}\n width={width}\n {...rest}\n >\n <Flexbox\n height={'100%'}\n style={{\n background: bgColors || cssVar.colorFillTertiary,\n borderRadius: size / 2,\n inset: 0,\n opacity: bgColors ? 0.2 : 1,\n position: 'absolute',\n zIndex: 0,\n }}\n width={'100%'}\n />\n <Flexbox\n align={'center'}\n flex={1}\n height={'100%'}\n horizontal\n justify={'flex-end'}\n style={{ position: 'relative' }}\n >\n {value < 0 ? (\n <div\n className={cx(showAnimation && styles.showAnimation)}\n style={{\n background: colors[deltaType],\n borderBottomLeftRadius: size / 2,\n borderTopLeftRadius: size / 2,\n height: '100%',\n width: `${Math.abs(value)}%`,\n }}\n />\n ) : undefined}\n </Flexbox>\n <Flexbox\n className={styles.marker}\n flex={'none'}\n style={{\n background: color || cssVar.colorPrimary,\n height: size + 8,\n zIndex: 2,\n }}\n />\n <Flexbox\n align={'center'}\n flex={1}\n height={'100%'}\n horizontal\n justify={'flex-start'}\n style={{ position: 'relative' }}\n >\n {value >= 0 ? (\n <div\n className={cx(showAnimation && styles.showAnimation)}\n style={{\n background: colors[deltaType],\n borderBottomRightRadius: size / 2,\n borderTopRightRadius: size / 2,\n height: '100%',\n width: `${Math.abs(value)}%`,\n }}\n />\n ) : undefined}\n </Flexbox>\n </Flexbox>\n </Tooltip>\n );\n});\n\nDeltaBar.displayName = 'DeltaBar';\n\nexport default DeltaBar;\n"],"mappings":";;;;;;;;;;AAYA,MAAM,gBAAgB,UAAmB,SAAS,IAAI,WAAW,WAAW,WAAW;AAYvF,MAAM,WAAW,YAA2C,OAAO,QAAQ;CACzE,MAAM,EACJ,OACA,UACA,OACA,qBAAqB,MACrB,gBAAgB,OAChB,WACA,SACA,QAAQ,QACR,OAAO,GACP,OACA,GAAG,SACD;CACJ,MAAM,YAAY,qBAAqB,aAAa,KAAK,GAAG,kBAAkB;CAE9E,MAAM,SAAS;GACZ,WAAW,WAAW,OAAO;GAC7B,WAAW,mBAAmB,OAAO;GACrC,WAAW,WAAW,OAAO;GAC7B,WAAW,mBAAmB,OAAO;GACrC,WAAW,YAAY,OAAO;CACjC;CAEA,OACE,oBAAC,SAAD;EAAS,OAAO;EACd,UAAA,qBAAC,SAAD;GACE,OAAO;GACI;GACX,QAAQ;GACR,YAAA;GACK;GACL,OAAO;IACL,UAAU;IACV,GAAG;GACL;GACO;GACP,GAAI;GAXN,UAAA;IAaE,oBAAC,SAAD;KACE,QAAQ;KACR,OAAO;MACL,YAAY,YAAY,OAAO;MAC/B,cAAc,OAAO;MACrB,OAAO;MACP,SAAS,WAAW,KAAM;MAC1B,UAAU;MACV,QAAQ;KACV;KACA,OAAO;IACR,CAAA;IACD,oBAAC,SAAD;KACE,OAAO;KACP,MAAM;KACN,QAAQ;KACR,YAAA;KACA,SAAS;KACT,OAAO,EAAE,UAAU,WAAW;KAE7B,UAAA,QAAQ,IACP,oBAAC,OAAD;MACE,WAAW,GAAG,iBAAiB,OAAO,aAAa;MACnD,OAAO;OACL,YAAY,OAAO;OACnB,wBAAwB,OAAO;OAC/B,qBAAqB,OAAO;OAC5B,QAAQ;OACR,OAAO,GAAG,KAAK,IAAI,KAAK,EAAE;MAC5B;KACD,CAAA,IACC,KAAA;IACG,CAAA;IACT,oBAAC,SAAD;KACE,WAAW,OAAO;KAClB,MAAM;KACN,OAAO;MACL,YAAY,SAAS,OAAO;MAC5B,QAAQ,OAAO;MACf,QAAQ;KACV;IACD,CAAA;IACD,oBAAC,SAAD;KACE,OAAO;KACP,MAAM;KACN,QAAQ;KACR,YAAA;KACA,SAAS;KACT,OAAO,EAAE,UAAU,WAAW;KAE7B,UAAA,SAAS,IACR,oBAAC,OAAD;MACE,WAAW,GAAG,iBAAiB,OAAO,aAAa;MACnD,OAAO;OACL,YAAY,OAAO;OACnB,yBAAyB,OAAO;OAChC,sBAAsB,OAAO;OAC7B,QAAQ;OACR,OAAO,GAAG,KAAK,IAAI,KAAK,EAAE;MAC5B;KACD,CAAA,IACC,KAAA;IACG,CAAA;GACF;;CACF,CAAA;AAEb,CAAC;AAED,SAAS,cAAc"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FlexboxProps } from "@lobehub/ui";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/DataBars/MarkerBar.d.ts
|
|
4
|
+
export interface MarkerBarProps extends FlexboxProps {
|
|
5
|
+
bgColors?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
markerTooltip?: ReactNode;
|
|
8
|
+
maxValue?: number;
|
|
9
|
+
minValue?: number;
|
|
10
|
+
rangeColors?: string;
|
|
11
|
+
rangeTooltip?: ReactNode;
|
|
12
|
+
showAnimation?: boolean;
|
|
13
|
+
size?: number;
|
|
14
|
+
value: number;
|
|
15
|
+
}
|
|
16
|
+
declare const MarkerBar: import("react").ForwardRefExoticComponent<Omit<MarkerBarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { MarkerBar as default };
|
|
19
|
+
//# sourceMappingURL=MarkerBar.d.mts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styles } from "./styles.mjs";
|
|
3
|
+
import { Flexbox } from "@lobehub/ui";
|
|
4
|
+
import { Tooltip } from "@lobehub/ui/base-ui";
|
|
5
|
+
import { cssVar, cx } from "antd-style";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/DataBars/MarkerBar.tsx
|
|
9
|
+
const MarkerBar = forwardRef((props, ref) => {
|
|
10
|
+
const { value, minValue, maxValue, markerTooltip, rangeTooltip, showAnimation = false, color, bgColors, rangeColors, className, width = "100%", style, size = 8, ...rest } = props;
|
|
11
|
+
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
12
|
+
align: "center",
|
|
13
|
+
className,
|
|
14
|
+
height: size,
|
|
15
|
+
horizontal: true,
|
|
16
|
+
ref,
|
|
17
|
+
style: {
|
|
18
|
+
position: "relative",
|
|
19
|
+
...style
|
|
20
|
+
},
|
|
21
|
+
width,
|
|
22
|
+
...rest,
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Flexbox, {
|
|
25
|
+
height: "100%",
|
|
26
|
+
style: {
|
|
27
|
+
background: bgColors || cssVar.colorFillTertiary,
|
|
28
|
+
borderRadius: size / 2,
|
|
29
|
+
inset: 0,
|
|
30
|
+
opacity: bgColors ? .2 : 1,
|
|
31
|
+
position: "absolute",
|
|
32
|
+
zIndex: 0
|
|
33
|
+
},
|
|
34
|
+
width: "100%"
|
|
35
|
+
}),
|
|
36
|
+
minValue !== void 0 && maxValue !== void 0 ? /* @__PURE__ */ jsx(Tooltip, {
|
|
37
|
+
title: rangeTooltip,
|
|
38
|
+
children: /* @__PURE__ */ jsx(Flexbox, {
|
|
39
|
+
className: cx(showAnimation && styles.showAnimation),
|
|
40
|
+
height: "100%",
|
|
41
|
+
style: {
|
|
42
|
+
background: rangeColors || cssVar.colorFill,
|
|
43
|
+
borderRadius: size / 2,
|
|
44
|
+
inset: 0,
|
|
45
|
+
left: `${minValue}%`,
|
|
46
|
+
opacity: rangeColors ? .2 : 1,
|
|
47
|
+
position: "absolute",
|
|
48
|
+
zIndex: 0
|
|
49
|
+
},
|
|
50
|
+
width: `${maxValue - minValue}%`
|
|
51
|
+
})
|
|
52
|
+
}) : null,
|
|
53
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
54
|
+
title: markerTooltip,
|
|
55
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
56
|
+
className: cx(styles.markerWrapper, showAnimation && styles.showAnimation),
|
|
57
|
+
style: { left: `${value}%` },
|
|
58
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
59
|
+
className: styles.marker,
|
|
60
|
+
style: {
|
|
61
|
+
background: color || cssVar.colorPrimary,
|
|
62
|
+
height: size + 8
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
MarkerBar.displayName = "MarkerBar";
|
|
71
|
+
//#endregion
|
|
72
|
+
export { MarkerBar as default };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=MarkerBar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkerBar.mjs","names":[],"sources":["../../src/DataBars/MarkerBar.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 { ReactNode, forwardRef } from 'react';\n\nimport { styles } from './styles';\n\nexport interface MarkerBarProps extends FlexboxProps {\n bgColors?: string;\n color?: string;\n markerTooltip?: ReactNode;\n maxValue?: number;\n minValue?: number;\n rangeColors?: string;\n rangeTooltip?: ReactNode;\n showAnimation?: boolean;\n size?: number;\n value: number;\n}\n\nconst MarkerBar = forwardRef<HTMLDivElement, MarkerBarProps>((props, ref) => {\n const {\n value,\n minValue,\n maxValue,\n markerTooltip,\n rangeTooltip,\n showAnimation = false,\n color,\n bgColors,\n rangeColors,\n className,\n width = '100%',\n style,\n size = 8,\n ...rest\n } = props;\n return (\n <Flexbox\n align={'center'}\n className={className}\n height={size}\n horizontal\n ref={ref}\n style={{\n position: 'relative',\n ...style,\n }}\n width={width}\n {...rest}\n >\n <Flexbox\n height={'100%'}\n style={{\n background: bgColors || cssVar.colorFillTertiary,\n borderRadius: size / 2,\n inset: 0,\n opacity: bgColors ? 0.2 : 1,\n position: 'absolute',\n zIndex: 0,\n }}\n width={'100%'}\n />\n {minValue !== undefined && maxValue !== undefined ? (\n <Tooltip title={rangeTooltip}>\n <Flexbox\n className={cx(showAnimation && styles.showAnimation)}\n height={'100%'}\n style={{\n background: rangeColors || cssVar.colorFill,\n borderRadius: size / 2,\n inset: 0,\n left: `${minValue}%`,\n opacity: rangeColors ? 0.2 : 1,\n position: 'absolute',\n zIndex: 0,\n }}\n width={`${maxValue - minValue}%`}\n />\n </Tooltip>\n ) : null}\n <Tooltip title={markerTooltip}>\n <div\n className={cx(styles.markerWrapper, showAnimation && styles.showAnimation)}\n style={{\n left: `${value}%`,\n }}\n >\n <div\n className={styles.marker}\n style={{\n background: color || cssVar.colorPrimary,\n height: size + 8,\n }}\n />\n </div>\n </Tooltip>\n </Flexbox>\n );\n});\n\nMarkerBar.displayName = 'MarkerBar';\n\nexport default MarkerBar;\n"],"mappings":";;;;;;;;AAsBA,MAAM,YAAY,YAA4C,OAAO,QAAQ;CAC3E,MAAM,EACJ,OACA,UACA,UACA,eACA,cACA,gBAAgB,OAChB,OACA,UACA,aACA,WACA,QAAQ,QACR,OACA,OAAO,GACP,GAAG,SACD;CACJ,OACE,qBAAC,SAAD;EACE,OAAO;EACI;EACX,QAAQ;EACR,YAAA;EACK;EACL,OAAO;GACL,UAAU;GACV,GAAG;EACL;EACO;EACP,GAAI;EAXN,UAAA;GAaE,oBAAC,SAAD;IACE,QAAQ;IACR,OAAO;KACL,YAAY,YAAY,OAAO;KAC/B,cAAc,OAAO;KACrB,OAAO;KACP,SAAS,WAAW,KAAM;KAC1B,UAAU;KACV,QAAQ;IACV;IACA,OAAO;GACR,CAAA;GACA,aAAa,KAAA,KAAa,aAAa,KAAA,IACtC,oBAAC,SAAD;IAAS,OAAO;IACd,UAAA,oBAAC,SAAD;KACE,WAAW,GAAG,iBAAiB,OAAO,aAAa;KACnD,QAAQ;KACR,OAAO;MACL,YAAY,eAAe,OAAO;MAClC,cAAc,OAAO;MACrB,OAAO;MACP,MAAM,GAAG,SAAS;MAClB,SAAS,cAAc,KAAM;MAC7B,UAAU;MACV,QAAQ;KACV;KACA,OAAO,GAAG,WAAW,SAAS;IAC/B,CAAA;GACM,CAAA,IACP;GACJ,oBAAC,SAAD;IAAS,OAAO;IACd,UAAA,oBAAC,OAAD;KACE,WAAW,GAAG,OAAO,eAAe,iBAAiB,OAAO,aAAa;KACzE,OAAO,EACL,MAAM,GAAG,MAAM,GACjB;KAEA,UAAA,oBAAC,OAAD;MACE,WAAW,OAAO;MAClB,OAAO;OACL,YAAY,SAAS,OAAO;OAC5B,QAAQ,OAAO;MACjB;KACD,CAAA;IACE,CAAA;GACE,CAAA;EACF;;AAEb,CAAC;AAED,UAAU,cAAc"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FlexboxProps } from "@lobehub/ui";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/DataBars/ProgressBar.d.ts
|
|
4
|
+
export interface ProgressBarProps extends FlexboxProps {
|
|
5
|
+
bgColors?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
showAnimation?: boolean;
|
|
8
|
+
size?: number;
|
|
9
|
+
tooltip?: ReactNode;
|
|
10
|
+
value: number;
|
|
11
|
+
}
|
|
12
|
+
declare const ProgressBar: import("react").ForwardRefExoticComponent<Omit<ProgressBarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ProgressBar as default };
|
|
15
|
+
//# sourceMappingURL=ProgressBar.d.mts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styles } from "./styles.mjs";
|
|
3
|
+
import { Flexbox } from "@lobehub/ui";
|
|
4
|
+
import { Tooltip } from "@lobehub/ui/base-ui";
|
|
5
|
+
import { cssVar, cx } from "antd-style";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/DataBars/ProgressBar.tsx
|
|
9
|
+
const ProgressBar = forwardRef((props, ref) => {
|
|
10
|
+
const { value, color, bgColors, tooltip, showAnimation = false, className, width = "100%", size = 8, style, ...rest } = props;
|
|
11
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
12
|
+
title: tooltip,
|
|
13
|
+
children: /* @__PURE__ */ jsxs(Flexbox, {
|
|
14
|
+
align: "center",
|
|
15
|
+
className,
|
|
16
|
+
height: size,
|
|
17
|
+
horizontal: true,
|
|
18
|
+
ref,
|
|
19
|
+
style: {
|
|
20
|
+
position: "relative",
|
|
21
|
+
...style
|
|
22
|
+
},
|
|
23
|
+
width,
|
|
24
|
+
...rest,
|
|
25
|
+
children: [/* @__PURE__ */ jsx(Flexbox, {
|
|
26
|
+
height: "100%",
|
|
27
|
+
style: {
|
|
28
|
+
background: bgColors || cssVar.colorFillTertiary,
|
|
29
|
+
borderRadius: size / 2,
|
|
30
|
+
inset: 0,
|
|
31
|
+
opacity: bgColors ? .2 : 1,
|
|
32
|
+
position: "absolute",
|
|
33
|
+
zIndex: 0
|
|
34
|
+
},
|
|
35
|
+
width: "100%"
|
|
36
|
+
}), /* @__PURE__ */ jsx(Flexbox, {
|
|
37
|
+
className: cx(showAnimation && styles.showAnimation),
|
|
38
|
+
height: "100%",
|
|
39
|
+
style: {
|
|
40
|
+
background: color || cssVar.colorPrimary,
|
|
41
|
+
borderRadius: size / 2,
|
|
42
|
+
zIndex: 1
|
|
43
|
+
},
|
|
44
|
+
width: `${value}%`
|
|
45
|
+
})]
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
ProgressBar.displayName = "ProgressBar";
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ProgressBar as default };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=ProgressBar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.mjs","names":[],"sources":["../../src/DataBars/ProgressBar.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 { ReactNode, forwardRef } from 'react';\n\nimport { styles } from './styles';\n\nexport interface ProgressBarProps extends FlexboxProps {\n bgColors?: string;\n color?: string;\n showAnimation?: boolean;\n size?: number;\n tooltip?: ReactNode;\n value: number;\n}\n\nconst ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>((props, ref) => {\n const {\n value,\n color,\n bgColors,\n tooltip,\n showAnimation = false,\n className,\n width = '100%',\n size = 8,\n style,\n ...rest\n } = props;\n\n return (\n <Tooltip title={tooltip}>\n <Flexbox\n align={'center'}\n className={className}\n height={size}\n horizontal\n ref={ref}\n style={{\n position: 'relative',\n ...style,\n }}\n width={width}\n {...rest}\n >\n <Flexbox\n height={'100%'}\n style={{\n background: bgColors || cssVar.colorFillTertiary,\n borderRadius: size / 2,\n inset: 0,\n opacity: bgColors ? 0.2 : 1,\n position: 'absolute',\n zIndex: 0,\n }}\n width={'100%'}\n />\n <Flexbox\n className={cx(showAnimation && styles.showAnimation)}\n height={'100%'}\n style={{\n background: color || cssVar.colorPrimary,\n borderRadius: size / 2,\n zIndex: 1,\n }}\n width={`${value}%`}\n />\n </Flexbox>\n </Tooltip>\n );\n});\n\nProgressBar.displayName = 'ProgressBar';\n\nexport default ProgressBar;\n"],"mappings":";;;;;;;;AAkBA,MAAM,cAAc,YAA8C,OAAO,QAAQ;CAC/E,MAAM,EACJ,OACA,OACA,UACA,SACA,gBAAgB,OAChB,WACA,QAAQ,QACR,OAAO,GACP,OACA,GAAG,SACD;CAEJ,OACE,oBAAC,SAAD;EAAS,OAAO;EACd,UAAA,qBAAC,SAAD;GACE,OAAO;GACI;GACX,QAAQ;GACR,YAAA;GACK;GACL,OAAO;IACL,UAAU;IACV,GAAG;GACL;GACO;GACP,GAAI;GAXN,UAAA,CAaE,oBAAC,SAAD;IACE,QAAQ;IACR,OAAO;KACL,YAAY,YAAY,OAAO;KAC/B,cAAc,OAAO;KACrB,OAAO;KACP,SAAS,WAAW,KAAM;KAC1B,UAAU;KACV,QAAQ;IACV;IACA,OAAO;GACR,CAAA,GACD,oBAAC,SAAD;IACE,WAAW,GAAG,iBAAiB,OAAO,aAAa;IACnD,QAAQ;IACR,OAAO;KACL,YAAY,SAAS,OAAO;KAC5B,cAAc,OAAO;KACrB,QAAQ;IACV;IACA,OAAO,GAAG,MAAM;GACjB,CAAA,CACM;;CACF,CAAA;AAEb,CAAC;AAED,YAAY,cAAc"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import CategoryBar, { CategoryBarProps } from "./CategoryBar.mjs";
|
|
2
|
+
import DeltaBar, { DeltaBarProps } from "./DeltaBar.mjs";
|
|
3
|
+
import MarkerBar, { MarkerBarProps } from "./MarkerBar.mjs";
|
|
4
|
+
import ProgressBar, { ProgressBarProps } from "./ProgressBar.mjs";
|
|
5
|
+
export { CategoryBar, type CategoryBarProps, DeltaBar, type DeltaBarProps, MarkerBar, type MarkerBarProps, ProgressBar, type ProgressBarProps };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createStaticStyles } from "antd-style";
|
|
2
|
+
//#region src/DataBars/styles.ts
|
|
3
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
4
|
+
emphasis: css`
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
text-overflow: ellipsis;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
`,
|
|
9
|
+
label: css`
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
line-height: 16px;
|
|
12
|
+
fill: ${cssVar.colorTextDescription};
|
|
13
|
+
`,
|
|
14
|
+
marker: css`
|
|
15
|
+
width: 4px;
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
box-shadow: 0 0 0 3px ${cssVar.colorBgContainer};
|
|
18
|
+
`,
|
|
19
|
+
markerWrapper: css`
|
|
20
|
+
position: absolute;
|
|
21
|
+
right: 50%;
|
|
22
|
+
width: 1.25rem;
|
|
23
|
+
`,
|
|
24
|
+
showAnimation: css`
|
|
25
|
+
transition: all 0.25s ${cssVar.motionEaseInOut};
|
|
26
|
+
`
|
|
27
|
+
}));
|
|
28
|
+
//#endregion
|
|
29
|
+
export { styles };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=styles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.mjs","names":[],"sources":["../../src/DataBars/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 label: css`\n font-size: 12px;\n line-height: 16px;\n fill: ${cssVar.colorTextDescription};\n `,\n marker: css`\n width: 4px;\n border-radius: 4px;\n box-shadow: 0 0 0 3px ${cssVar.colorBgContainer};\n `,\n markerWrapper: css`\n position: absolute;\n right: 50%;\n width: 1.25rem;\n `,\n showAnimation: css`\n transition: all 0.25s ${cssVar.motionEaseInOut};\n `,\n}));\n"],"mappings":";;AAEA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,UAAU,GAAG;;;;;CAKb,OAAO,GAAG;;;YAGA,OAAO,qBAAqB;;CAEtC,QAAQ,GAAG;;;4BAGe,OAAO,iBAAiB;;CAElD,eAAe,GAAG;;;;;CAKlB,eAAe,GAAG;4BACQ,OAAO,gBAAgB;;AAEnD,EAAE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ValueFormatter } from "../types/charts.mjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
//#region src/DonutChart/DonutChartTooltip.d.ts
|
|
4
|
+
export interface DonutChartTooltipProps {
|
|
5
|
+
active: boolean | undefined;
|
|
6
|
+
customCategories?: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
payload: any;
|
|
10
|
+
valueFormatter: ValueFormatter;
|
|
11
|
+
}
|
|
12
|
+
export declare const DonutChartTooltip: ({ customCategories, active, payload, valueFormatter }: DonutChartTooltipProps) => React.JSX.Element | null;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=DonutChartTooltip.d.mts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChartTooltipFrame } from "../common/ChartTooltip/ChartTooltipFrame.mjs";
|
|
2
|
+
import ChartTooltipRow from "../common/ChartTooltip/ChartTooltipRow.mjs";
|
|
3
|
+
import { Flexbox } from "@lobehub/ui";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/DonutChart/DonutChartTooltip.tsx
|
|
7
|
+
const DonutChartTooltip = ({ customCategories, active, payload, valueFormatter }) => {
|
|
8
|
+
if (active && payload?.[0]) {
|
|
9
|
+
const payloadRow = payload?.[0];
|
|
10
|
+
return /* @__PURE__ */ jsx(ChartTooltipFrame, { children: /* @__PURE__ */ jsx(Flexbox, {
|
|
11
|
+
paddingBlock: 8,
|
|
12
|
+
paddingInline: 16,
|
|
13
|
+
children: /* @__PURE__ */ jsx(ChartTooltipRow, {
|
|
14
|
+
color: payloadRow.payload.color,
|
|
15
|
+
name: customCategories?.[payloadRow.name] || payloadRow.name,
|
|
16
|
+
value: valueFormatter(payloadRow.value)
|
|
17
|
+
})
|
|
18
|
+
}) });
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { DonutChartTooltip };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=DonutChartTooltip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DonutChartTooltip.mjs","names":[],"sources":["../../src/DonutChart/DonutChartTooltip.tsx"],"sourcesContent":["import { Flexbox } from '@lobehub/ui';\nimport React from 'react';\n\nimport ChartTooltipFrame from '@/common/ChartTooltip/ChartTooltipFrame';\nimport ChartTooltipRow from '@/common/ChartTooltip/ChartTooltipRow';\nimport { ValueFormatter } from '@/types/charts';\n\nexport interface DonutChartTooltipProps {\n active: boolean | undefined;\n customCategories?: {\n [key: string]: string;\n };\n payload: any;\n valueFormatter: ValueFormatter;\n}\n\nexport const DonutChartTooltip = ({\n customCategories,\n active,\n payload,\n valueFormatter,\n}: DonutChartTooltipProps) => {\n if (active && payload?.[0]) {\n const payloadRow = payload?.[0];\n return (\n <ChartTooltipFrame>\n <Flexbox paddingBlock={8} paddingInline={16}>\n <ChartTooltipRow\n color={payloadRow.payload.color}\n name={customCategories?.[payloadRow.name] || payloadRow.name}\n value={valueFormatter(payloadRow.value)}\n />\n </Flexbox>\n </ChartTooltipFrame>\n );\n }\n return null;\n};\n"],"mappings":";;;;;;AAgBA,MAAa,qBAAqB,EAChC,kBACA,QACA,SACA,qBAC4B;CAC5B,IAAI,UAAU,UAAU,IAAI;EAC1B,MAAM,aAAa,UAAU;EAC7B,OACE,oBAAC,mBAAD,EAAA,UACE,oBAAC,SAAD;GAAS,cAAc;GAAG,eAAe;GACvC,UAAA,oBAAC,iBAAD;IACE,OAAO,WAAW,QAAQ;IAC1B,MAAM,mBAAmB,WAAW,SAAS,WAAW;IACxD,OAAO,eAAe,WAAW,KAAK;GACvC,CAAA;EACM,CAAA,EACQ,CAAA;CAEvB;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NoDataProps } from "../common/NoData.mjs";
|
|
2
|
+
import { EventProps, ValueFormatter } from "../types/charts.mjs";
|
|
3
|
+
import BaseAnimationTimingProps from "../common/BaseAnimationTimingProps.mjs";
|
|
4
|
+
import { CustomTooltipProps } from "../common/CustomTooltipProps.mjs";
|
|
5
|
+
import { CSSProperties, ComponentType } from "react";
|
|
6
|
+
//#region src/DonutChart/index.d.ts
|
|
7
|
+
type DonutChartVariant = 'donut' | 'pie';
|
|
8
|
+
export interface DonutChartProps extends BaseAnimationTimingProps {
|
|
9
|
+
category?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
colors?: string[];
|
|
12
|
+
customCategories?: {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
};
|
|
15
|
+
customTooltip?: ComponentType<CustomTooltipProps>;
|
|
16
|
+
data: any[];
|
|
17
|
+
donutLabel?: string;
|
|
18
|
+
index?: string;
|
|
19
|
+
label?: string;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
noDataText?: NoDataProps['noDataText'];
|
|
22
|
+
onValueChange?: (value: EventProps) => void;
|
|
23
|
+
showAnimation?: boolean;
|
|
24
|
+
showLabel?: boolean;
|
|
25
|
+
showTooltip?: boolean;
|
|
26
|
+
style?: CSSProperties;
|
|
27
|
+
valueFormatter?: ValueFormatter;
|
|
28
|
+
variant?: DonutChartVariant;
|
|
29
|
+
}
|
|
30
|
+
declare const DonutChart: import("react").ForwardRefExoticComponent<DonutChartProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { DonutChart as default };
|
|
33
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange.mjs";
|
|
3
|
+
import { defaultValueFormatter, isOnSeverSide } from "../utils/index.mjs";
|
|
4
|
+
import NoData from "../common/NoData.mjs";
|
|
5
|
+
import { DonutChartTooltip } from "./DonutChartTooltip.mjs";
|
|
6
|
+
import { parseLabelInput } from "./inputParser.mjs";
|
|
7
|
+
import { renderInactiveShape } from "./renderInactiveShape.mjs";
|
|
8
|
+
import { styles } from "./styles.mjs";
|
|
9
|
+
import { Flexbox } from "@lobehub/ui";
|
|
10
|
+
import { Skeleton } from "@lobehub/ui/base-ui";
|
|
11
|
+
import { css, cssVar, cx, useThemeMode } from "antd-style";
|
|
12
|
+
import { forwardRef, useEffect, useState } from "react";
|
|
13
|
+
import { Pie, PieChart, ResponsiveContainer, Tooltip as Tooltip$1 } from "recharts";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
//#region src/DonutChart/index.tsx
|
|
16
|
+
const DonutChart = forwardRef((props, ref) => {
|
|
17
|
+
const themeColorRange = useThemeColorRange();
|
|
18
|
+
const { data = [], category = "value", index = "name", colors = themeColorRange, variant = "donut", valueFormatter = defaultValueFormatter, label, showLabel = true, animationDuration = 900, showAnimation = false, showTooltip = true, noDataText, onValueChange, customTooltip, className, width = "100%", loading, height = "10rem", style, customCategories, donutLabel, ...rest } = props;
|
|
19
|
+
const { isDarkMode } = useThemeMode();
|
|
20
|
+
const CustomTooltip = customTooltip;
|
|
21
|
+
const isDonut = variant === "donut";
|
|
22
|
+
const parsedLabelInput = parseLabelInput(label, valueFormatter, data, category);
|
|
23
|
+
const [activeIndex, setActiveIndex] = useState();
|
|
24
|
+
const hasOnValueChange = !!onValueChange;
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (isOnSeverSide) return;
|
|
27
|
+
const pieSectors = document.querySelectorAll(".recharts-pie-sector");
|
|
28
|
+
if (pieSectors) for (const sector of pieSectors) sector.setAttribute("style", "outline: none");
|
|
29
|
+
}, [activeIndex]);
|
|
30
|
+
if (loading || !data) return /* @__PURE__ */ jsx(Skeleton, {
|
|
31
|
+
height,
|
|
32
|
+
width
|
|
33
|
+
});
|
|
34
|
+
const onShapeClick = (data, index, event) => {
|
|
35
|
+
event.stopPropagation();
|
|
36
|
+
if (!hasOnValueChange) return;
|
|
37
|
+
if (activeIndex === index) {
|
|
38
|
+
setActiveIndex(void 0);
|
|
39
|
+
onValueChange?.(null);
|
|
40
|
+
} else {
|
|
41
|
+
setActiveIndex(index);
|
|
42
|
+
onValueChange?.({
|
|
43
|
+
eventType: "slice",
|
|
44
|
+
...data.payload.payload
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const parseData = (data, colors) => data.map((dataPoint, idx) => {
|
|
49
|
+
const baseColor = idx < colors.length ? colors[idx] : cssVar.colorPrimary;
|
|
50
|
+
return {
|
|
51
|
+
...dataPoint,
|
|
52
|
+
className: cx(css`
|
|
53
|
+
fill: ${baseColor ?? cssVar.colorPrimary};
|
|
54
|
+
`),
|
|
55
|
+
color: baseColor,
|
|
56
|
+
fill: ""
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
60
|
+
className,
|
|
61
|
+
height,
|
|
62
|
+
ref,
|
|
63
|
+
style: {
|
|
64
|
+
position: "relative",
|
|
65
|
+
...style
|
|
66
|
+
},
|
|
67
|
+
width,
|
|
68
|
+
...rest,
|
|
69
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: data?.length ? /* @__PURE__ */ jsxs(PieChart, {
|
|
70
|
+
margin: {
|
|
71
|
+
bottom: 0,
|
|
72
|
+
left: 0,
|
|
73
|
+
right: 0,
|
|
74
|
+
top: 0
|
|
75
|
+
},
|
|
76
|
+
onClick: hasOnValueChange && activeIndex ? () => {
|
|
77
|
+
setActiveIndex(void 0);
|
|
78
|
+
onValueChange?.(null);
|
|
79
|
+
} : void 0,
|
|
80
|
+
children: [
|
|
81
|
+
showLabel && isDonut ? /* @__PURE__ */ jsx("text", {
|
|
82
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
83
|
+
dominantBaseline: "middle",
|
|
84
|
+
textAnchor: "middle",
|
|
85
|
+
x: "50%",
|
|
86
|
+
y: "50%",
|
|
87
|
+
children: donutLabel || (typeof activeIndex === "number" ? valueFormatter(data?.[activeIndex]?.[category]) : parsedLabelInput)
|
|
88
|
+
}) : null,
|
|
89
|
+
/* @__PURE__ */ jsx(Pie, {
|
|
90
|
+
activeIndex,
|
|
91
|
+
animationDuration,
|
|
92
|
+
cx: "50%",
|
|
93
|
+
cy: "50%",
|
|
94
|
+
data: parseData(data, colors),
|
|
95
|
+
dataKey: category,
|
|
96
|
+
endAngle: -270,
|
|
97
|
+
inactiveShape: renderInactiveShape,
|
|
98
|
+
innerRadius: isDonut ? "75%" : "0%",
|
|
99
|
+
isAnimationActive: showAnimation,
|
|
100
|
+
nameKey: index,
|
|
101
|
+
onClick: onShapeClick,
|
|
102
|
+
outerRadius: "100%",
|
|
103
|
+
startAngle: 90,
|
|
104
|
+
stroke: "",
|
|
105
|
+
strokeLinejoin: "round",
|
|
106
|
+
style: {
|
|
107
|
+
cursor: onValueChange ? "pointer" : void 0,
|
|
108
|
+
outline: "none",
|
|
109
|
+
stroke: cssVar.colorBgContainer
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
isDonut && /* @__PURE__ */ jsx(Pie, {
|
|
113
|
+
activeIndex,
|
|
114
|
+
animationDuration,
|
|
115
|
+
cx: "50%",
|
|
116
|
+
cy: "50%",
|
|
117
|
+
data: parseData([{ [category]: 1 }], [isDarkMode ? "color-mix(in srgb, #000000 33%, transparent)" : "color-mix(in srgb, #000000 10%, transparent)"]),
|
|
118
|
+
dataKey: category,
|
|
119
|
+
endAngle: -270,
|
|
120
|
+
inactiveShape: renderInactiveShape,
|
|
121
|
+
innerRadius: isDonut ? "75%" : "0%",
|
|
122
|
+
isAnimationActive: false,
|
|
123
|
+
nameKey: index,
|
|
124
|
+
outerRadius: "80%",
|
|
125
|
+
startAngle: 90,
|
|
126
|
+
stroke: "",
|
|
127
|
+
strokeLinejoin: "round",
|
|
128
|
+
style: {
|
|
129
|
+
outline: "none",
|
|
130
|
+
pointerEvents: "none"
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
/* @__PURE__ */ jsx(Tooltip$1, {
|
|
134
|
+
content: showTooltip ? ({ active, payload }) => CustomTooltip ? /* @__PURE__ */ jsx(CustomTooltip, {
|
|
135
|
+
active,
|
|
136
|
+
customCategories,
|
|
137
|
+
label: payload?.[0]?.name,
|
|
138
|
+
payload: payload?.map((payloadItem) => ({
|
|
139
|
+
...payloadItem,
|
|
140
|
+
color: payload?.[0]?.payload?.color ?? cssVar.colorPrimary
|
|
141
|
+
})),
|
|
142
|
+
valueFormatter
|
|
143
|
+
}) : /* @__PURE__ */ jsx(DonutChartTooltip, {
|
|
144
|
+
active,
|
|
145
|
+
customCategories,
|
|
146
|
+
payload,
|
|
147
|
+
valueFormatter
|
|
148
|
+
}) : void 0,
|
|
149
|
+
isAnimationActive: false,
|
|
150
|
+
wrapperStyle: { outline: "none" }
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
}) : /* @__PURE__ */ jsx(NoData, { noDataText }) })
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
DonutChart.displayName = "DonutChart";
|
|
157
|
+
//#endregion
|
|
158
|
+
export { DonutChart as default };
|
|
159
|
+
|
|
160
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["ReChartsDonutChart","Tooltip"],"sources":["../../src/DonutChart/index.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox } from '@lobehub/ui';\nimport { Skeleton } from '@lobehub/ui/base-ui';\nimport { css, cssVar, cx, useThemeMode } from 'antd-style';\nimport { CSSProperties, ComponentType, MouseEvent, forwardRef, useEffect, useState } from 'react';\nimport { Pie, PieChart as ReChartsDonutChart, ResponsiveContainer, Tooltip } from 'recharts';\n\nimport type BaseAnimationTimingProps from '@/common/BaseAnimationTimingProps';\nimport { CustomTooltipProps } from '@/common/CustomTooltipProps';\nimport NoData, { type NoDataProps } from '@/common/NoData';\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport type { EventProps } from '@/types/charts';\nimport { ValueFormatter } from '@/types/charts';\nimport { defaultValueFormatter, isOnSeverSide } from '@/utils';\n\nimport { DonutChartTooltip } from './DonutChartTooltip';\nimport { parseLabelInput } from './inputParser';\nimport { renderInactiveShape } from './renderInactiveShape';\nimport { styles } from './styles';\n\ntype DonutChartVariant = 'donut' | 'pie';\n\nexport interface DonutChartProps extends BaseAnimationTimingProps {\n category?: string;\n className?: string;\n colors?: string[];\n customCategories?: {\n [key: string]: string;\n };\n customTooltip?: ComponentType<CustomTooltipProps>;\n data: any[];\n donutLabel?: string;\n index?: string;\n label?: string;\n loading?: boolean;\n noDataText?: NoDataProps['noDataText'];\n onValueChange?: (value: EventProps) => void;\n showAnimation?: boolean;\n showLabel?: boolean;\n showTooltip?: boolean;\n style?: CSSProperties;\n valueFormatter?: ValueFormatter;\n variant?: DonutChartVariant;\n}\n\nconst DonutChart = forwardRef<HTMLDivElement, DonutChartProps>((props, ref) => {\n const themeColorRange = useThemeColorRange();\n const {\n data = [],\n category = 'value',\n index = 'name',\n colors = themeColorRange,\n variant = 'donut',\n valueFormatter = defaultValueFormatter,\n label,\n showLabel = true,\n animationDuration = 900,\n showAnimation = false,\n showTooltip = true,\n noDataText,\n onValueChange,\n customTooltip,\n className,\n width = '100%',\n loading,\n height = '10rem',\n style,\n customCategories,\n donutLabel,\n ...rest\n } = props;\n const { isDarkMode } = useThemeMode();\n const CustomTooltip = customTooltip;\n const isDonut = variant === 'donut';\n const parsedLabelInput = parseLabelInput(label, valueFormatter, data, category);\n\n const [activeIndex, setActiveIndex] = useState<number | undefined>();\n const hasOnValueChange = !!onValueChange;\n\n useEffect(() => {\n if (isOnSeverSide) return;\n const pieSectors = document.querySelectorAll('.recharts-pie-sector');\n if (pieSectors) {\n for (const sector of pieSectors) {\n sector.setAttribute('style', 'outline: none');\n }\n }\n }, [activeIndex]);\n\n if (loading || !data) return <Skeleton height={height} width={width} />;\n\n const onShapeClick = (data: any, index: number, event: MouseEvent) => {\n event.stopPropagation();\n\n if (!hasOnValueChange) return;\n if (activeIndex === index) {\n setActiveIndex(undefined);\n onValueChange?.(null);\n } else {\n setActiveIndex(index);\n onValueChange?.({\n eventType: 'slice',\n ...data.payload.payload,\n });\n }\n };\n\n const parseData = (data: any[], colors: string[]) =>\n data.map((dataPoint: any, idx: number) => {\n const baseColor = idx < colors.length ? colors[idx] : cssVar.colorPrimary;\n return {\n ...dataPoint,\n className: cx(css`\n fill: ${baseColor ?? cssVar.colorPrimary};\n `),\n color: baseColor,\n fill: '',\n };\n });\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 <ReChartsDonutChart\n margin={{ bottom: 0, left: 0, right: 0, top: 0 }}\n onClick={\n hasOnValueChange && activeIndex\n ? () => {\n setActiveIndex(undefined);\n onValueChange?.(null);\n }\n : undefined\n }\n >\n {showLabel && isDonut ? (\n <text\n className={cx(styles.strongLabel, styles.emphasis)}\n dominantBaseline=\"middle\"\n textAnchor=\"middle\"\n x=\"50%\"\n y=\"50%\"\n >\n {donutLabel ||\n (typeof activeIndex === 'number'\n ? valueFormatter(data?.[activeIndex as any]?.[category])\n : parsedLabelInput)}\n </text>\n ) : null}\n <Pie\n activeIndex={activeIndex}\n animationDuration={animationDuration}\n cx=\"50%\"\n cy=\"50%\"\n data={parseData(data, colors)}\n dataKey={category}\n endAngle={-270}\n inactiveShape={renderInactiveShape}\n innerRadius={isDonut ? '75%' : '0%'}\n isAnimationActive={showAnimation}\n nameKey={index}\n onClick={onShapeClick}\n outerRadius=\"100%\"\n startAngle={90}\n stroke=\"\"\n strokeLinejoin=\"round\"\n style={{\n cursor: onValueChange ? 'pointer' : undefined,\n outline: 'none',\n stroke: cssVar.colorBgContainer,\n }}\n />\n {isDonut && (\n <Pie\n activeIndex={activeIndex}\n animationDuration={animationDuration}\n cx=\"50%\"\n cy=\"50%\"\n data={parseData(\n [{ [category]: 1 }],\n [\n isDarkMode\n ? 'color-mix(in srgb, #000000 33%, transparent)'\n : 'color-mix(in srgb, #000000 10%, transparent)',\n ],\n )}\n dataKey={category}\n endAngle={-270}\n inactiveShape={renderInactiveShape}\n innerRadius={isDonut ? '75%' : '0%'}\n isAnimationActive={false}\n nameKey={index}\n outerRadius=\"80%\"\n startAngle={90}\n stroke=\"\"\n strokeLinejoin=\"round\"\n style={{\n outline: 'none',\n pointerEvents: 'none',\n }}\n />\n )}\n <Tooltip\n content={\n showTooltip\n ? ({ active, payload }) =>\n CustomTooltip ? (\n <CustomTooltip\n active={active}\n customCategories={customCategories}\n label={payload?.[0]?.name}\n payload={payload?.map((payloadItem) => ({\n ...payloadItem,\n color: payload?.[0]?.payload?.color ?? cssVar.colorPrimary,\n }))}\n valueFormatter={valueFormatter}\n />\n ) : (\n <DonutChartTooltip\n active={active}\n customCategories={customCategories}\n payload={payload}\n valueFormatter={valueFormatter}\n />\n )\n : undefined\n }\n isAnimationActive={false}\n wrapperStyle={{ outline: 'none' }}\n />\n </ReChartsDonutChart>\n ) : (\n <NoData noDataText={noDataText} />\n )}\n </ResponsiveContainer>\n </Flexbox>\n );\n});\n\nDonutChart.displayName = 'DonutChart';\n\nexport default DonutChart;\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,MAAM,aAAa,YAA6C,OAAO,QAAQ;CAC7E,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,EACJ,OAAO,CAAC,GACR,WAAW,SACX,QAAQ,QACR,SAAS,iBACT,UAAU,SACV,iBAAiB,uBACjB,OACA,YAAY,MACZ,oBAAoB,KACpB,gBAAgB,OAChB,cAAc,MACd,YACA,eACA,eACA,WACA,QAAQ,QACR,SACA,SAAS,SACT,OACA,kBACA,YACA,GAAG,SACD;CACJ,MAAM,EAAE,eAAe,aAAa;CACpC,MAAM,gBAAgB;CACtB,MAAM,UAAU,YAAY;CAC5B,MAAM,mBAAmB,gBAAgB,OAAO,gBAAgB,MAAM,QAAQ;CAE9E,MAAM,CAAC,aAAa,kBAAkB,SAA6B;CACnE,MAAM,mBAAmB,CAAC,CAAC;CAE3B,gBAAgB;EACd,IAAI,eAAe;EACnB,MAAM,aAAa,SAAS,iBAAiB,sBAAsB;EACnE,IAAI,YACF,KAAK,MAAM,UAAU,YACnB,OAAO,aAAa,SAAS,eAAe;CAGlD,GAAG,CAAC,WAAW,CAAC;CAEhB,IAAI,WAAW,CAAC,MAAM,OAAO,oBAAC,UAAD;EAAkB;EAAe;CAAQ,CAAA;CAEtE,MAAM,gBAAgB,MAAW,OAAe,UAAsB;EACpE,MAAM,gBAAgB;EAEtB,IAAI,CAAC,kBAAkB;EACvB,IAAI,gBAAgB,OAAO;GACzB,eAAe,KAAA,CAAS;GACxB,gBAAgB,IAAI;EACtB,OAAO;GACL,eAAe,KAAK;GACpB,gBAAgB;IACd,WAAW;IACX,GAAG,KAAK,QAAQ;GAClB,CAAC;EACH;CACF;CAEA,MAAM,aAAa,MAAa,WAC9B,KAAK,KAAK,WAAgB,QAAgB;EACxC,MAAM,YAAY,MAAM,OAAO,SAAS,OAAO,OAAO,OAAO;EAC7D,OAAO;GACL,GAAG;GACH,WAAW,GAAG,GAAG;kBACP,aAAa,OAAO,aAAa;SAC1C;GACD,OAAO;GACP,MAAM;EACR;CACF,CAAC;CAEH,OACE,oBAAC,SAAD;EACa;EACH;EACH;EACL,OAAO;GAAE,UAAU;GAAY,GAAG;EAAM;EACjC;EACP,GAAI;EAEJ,UAAA,oBAAC,qBAAD,EAAA,UACG,MAAM,SACL,qBAACA,UAAD;GACE,QAAQ;IAAE,QAAQ;IAAG,MAAM;IAAG,OAAO;IAAG,KAAK;GAAE;GAC/C,SACE,oBAAoB,oBACV;IACJ,eAAe,KAAA,CAAS;IACxB,gBAAgB,IAAI;GACtB,IACA,KAAA;GARR,UAAA;IAWG,aAAa,UACZ,oBAAC,QAAD;KACE,WAAW,GAAG,OAAO,aAAa,OAAO,QAAQ;KACjD,kBAAiB;KACjB,YAAW;KACX,GAAE;KACF,GAAE;KAED,UAAA,eACE,OAAO,gBAAgB,WACpB,eAAe,OAAO,YAAmB,GAAG,SAAS,IACrD;IACF,CAAA,IACJ;IACJ,oBAAC,KAAD;KACe;KACM;KACnB,IAAG;KACH,IAAG;KACH,MAAM,UAAU,MAAM,MAAM;KAC5B,SAAS;KACT,UAAU;KACV,eAAe;KACf,aAAa,UAAU,QAAQ;KAC/B,mBAAmB;KACnB,SAAS;KACT,SAAS;KACT,aAAY;KACZ,YAAY;KACZ,QAAO;KACP,gBAAe;KACf,OAAO;MACL,QAAQ,gBAAgB,YAAY,KAAA;MACpC,SAAS;MACT,QAAQ,OAAO;KACjB;IACD,CAAA;IACA,WACC,oBAAC,KAAD;KACe;KACM;KACnB,IAAG;KACH,IAAG;KACH,MAAM,UACJ,CAAC,GAAG,WAAW,EAAE,CAAC,GAClB,CACE,aACI,iDACA,8CACN,CACF;KACA,SAAS;KACT,UAAU;KACV,eAAe;KACf,aAAa,UAAU,QAAQ;KAC/B,mBAAmB;KACnB,SAAS;KACT,aAAY;KACZ,YAAY;KACZ,QAAO;KACP,gBAAe;KACf,OAAO;MACL,SAAS;MACT,eAAe;KACjB;IACD,CAAA;IAEH,oBAACC,WAAD;KACE,SACE,eACK,EAAE,QAAQ,cACT,gBACE,oBAAC,eAAD;MACU;MACU;MAClB,OAAO,UAAU,EAAE,EAAE;MACrB,SAAS,SAAS,KAAK,iBAAiB;OACtC,GAAG;OACH,OAAO,UAAU,EAAE,EAAE,SAAS,SAAS,OAAO;MAChD,EAAE;MACc;KACjB,CAAA,IAED,oBAAC,mBAAD;MACU;MACU;MACT;MACO;KACjB,CAAA,IAEL,KAAA;KAEN,mBAAmB;KACnB,cAAc,EAAE,SAAS,OAAO;IACjC,CAAA;GACiB;EAEpB,CAAA,IAAA,oBAAC,QAAD,EAAoB,WAAa,CAAA,EAEhB,CAAA;CACd,CAAA;AAEb,CAAC;AAED,WAAW,cAAc"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ValueFormatter } from "../types/charts.mjs";
|
|
2
|
+
//#region src/DonutChart/inputParser.d.ts
|
|
3
|
+
export declare const parseLabelInput: (labelInput: string | undefined, valueFormatter: ValueFormatter, data: any[], category: string) => string;
|
|
4
|
+
//#endregion
|
|
5
|
+
//# sourceMappingURL=inputParser.d.mts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { sumNumericArray } from "../utils/index.mjs";
|
|
2
|
+
//#region src/DonutChart/inputParser.ts
|
|
3
|
+
const calculateDefaultLabel = (data, category) => sumNumericArray(data.map((dataPoint) => dataPoint[category]));
|
|
4
|
+
const parseLabelInput = (labelInput, valueFormatter, data, category) => labelInput ? labelInput : valueFormatter(calculateDefaultLabel(data, category));
|
|
5
|
+
//#endregion
|
|
6
|
+
export { parseLabelInput };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=inputParser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputParser.mjs","names":[],"sources":["../../src/DonutChart/inputParser.ts"],"sourcesContent":["import { ValueFormatter } from '@/types/charts';\nimport { sumNumericArray } from '@/utils';\n\nconst calculateDefaultLabel = (data: any[], category: string) =>\n sumNumericArray(data.map((dataPoint) => dataPoint[category]));\n\nexport const parseLabelInput = (\n labelInput: string | undefined,\n valueFormatter: ValueFormatter,\n data: any[],\n category: string,\n) => (labelInput ? labelInput : valueFormatter(calculateDefaultLabel(data, category)));\n"],"mappings":";;AAGA,MAAM,yBAAyB,MAAa,aAC1C,gBAAgB,KAAK,KAAK,cAAc,UAAU,SAAS,CAAC;AAE9D,MAAa,mBACX,YACA,gBACA,MACA,aACI,aAAa,aAAa,eAAe,sBAAsB,MAAM,QAAQ,CAAC"}
|