@lobehub/charts 6.0.0-beta.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/es/AccuracyBarChart/index.d.mts +62 -0
- package/es/AccuracyBarChart/index.mjs +324 -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 +306 -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 +288 -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 +126 -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 +512 -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 +345 -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 +666 -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 +252 -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 +144 -0
- package/es/DataBars/CategoryBar.mjs.map +1 -0
- package/es/DataBars/DeltaBar.d.mts +16 -0
- package/es/DataBars/DeltaBar.mjs +100 -0
- package/es/DataBars/DeltaBar.mjs.map +1 -0
- package/es/DataBars/MarkerBar.d.mts +19 -0
- package/es/DataBars/MarkerBar.mjs +72 -0
- package/es/DataBars/MarkerBar.mjs.map +1 -0
- package/es/DataBars/ProgressBar.d.mts +15 -0
- package/es/DataBars/ProgressBar.mjs +51 -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 +158 -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 +419 -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 +107 -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 +186 -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 +63 -0
- package/es/Legend/LegendItem.mjs.map +1 -0
- package/es/Legend/ScrollButton.d.mts +11 -0
- package/es/Legend/ScrollButton.mjs +49 -0
- package/es/Legend/ScrollButton.mjs.map +1 -0
- package/es/Legend/index.d.mts +16 -0
- package/es/Legend/index.mjs +151 -0
- package/es/Legend/index.mjs.map +1 -0
- package/es/LineChart/index.d.mts +11 -0
- package/es/LineChart/index.mjs +269 -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 +155 -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 +50 -0
- package/es/ScatterChart/ScatterChartTooltip.mjs.map +1 -0
- package/es/ScatterChart/ScatterChartTooltipRow.d.mts +10 -0
- package/es/ScatterChart/ScatterChartTooltipRow.mjs +34 -0
- package/es/ScatterChart/ScatterChartTooltipRow.mjs.map +1 -0
- package/es/ScatterChart/index.d.mts +58 -0
- package/es/ScatterChart/index.mjs +239 -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 +107 -0
- package/es/SparkChart/SparkAreaChart.mjs.map +1 -0
- package/es/SparkChart/SparkBarChart.d.mts +11 -0
- package/es/SparkChart/SparkBarChart.mjs +67 -0
- package/es/SparkChart/SparkBarChart.mjs.map +1 -0
- package/es/SparkChart/SparkLineChart.d.mts +12 -0
- package/es/SparkChart/SparkLineChart.mjs +71 -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 +50 -0
- package/es/Tracker/TrackerBlock.mjs.map +1 -0
- package/es/Tracker/index.d.mts +21 -0
- package/es/Tracker/index.mjs +67 -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 +26 -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 +49 -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 +48 -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 -5
- package/es/AccuracyBarChart/index.d.ts +0 -60
- package/es/AccuracyBarChart/index.js +0 -452
- 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 -428
- 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 -390
- 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 -172
- 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 -684
- 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 -453
- 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 -855
- 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 -333
- 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 -199
- package/es/DataBars/DeltaBar.d.ts +0 -13
- package/es/DataBars/DeltaBar.js +0 -115
- package/es/DataBars/MarkerBar.d.ts +0 -16
- package/es/DataBars/MarkerBar.js +0 -92
- package/es/DataBars/ProgressBar.d.ts +0 -12
- package/es/DataBars/ProgressBar.js +0 -69
- 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 -230
- 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 -497
- 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 -154
- 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 -225
- 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 -56
- package/es/Legend/ScrollButton.d.ts +0 -9
- package/es/Legend/ScrollButton.js +0 -62
- package/es/Legend/index.d.ts +0 -14
- package/es/Legend/index.js +0 -183
- package/es/Legend/index.mdx +0 -13
- package/es/LineChart/index.d.ts +0 -9
- package/es/LineChart/index.js +0 -386
- 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 -252
- 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 -74
- package/es/ScatterChart/ScatterChartTooltipRow.d.ts +0 -7
- package/es/ScatterChart/ScatterChartTooltipRow.js +0 -38
- package/es/ScatterChart/index.d.ts +0 -56
- package/es/ScatterChart/index.js +0 -340
- 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 -146
- package/es/SparkChart/SparkBarChart.d.ts +0 -9
- package/es/SparkChart/SparkBarChart.js +0 -104
- package/es/SparkChart/SparkLineChart.d.ts +0 -10
- package/es/SparkChart/SparkLineChart.js +0 -108
- 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 -62
- package/es/Tracker/index.d.ts +0 -18
- package/es/Tracker/index.js +0 -103
- 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 -31
- package/es/common/ChartTooltip/ChartTooltipRow.d.ts +0 -8
- package/es/common/ChartTooltip/ChartTooltipRow.js +0 -53
- package/es/common/ChartTooltip/index.d.ts +0 -15
- package/es/common/ChartTooltip/index.js +0 -64
- 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/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,269 @@
|
|
|
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 { constructCategoryColors, getYAxisDomain, hasOnlyOneValueForThisKey } from "../common/utils.mjs";
|
|
9
|
+
import { getMaxLabelLength } from "../utils/getMaxLabelLength.mjs";
|
|
10
|
+
import { styles } from "./styles.mjs";
|
|
11
|
+
import { Flexbox, Skeleton, css, cssVar, cx } from "@lobehub/ui";
|
|
12
|
+
import { Fragment, forwardRef, useMemo, useState } from "react";
|
|
13
|
+
import { CartesianGrid, Dot, Label, Legend, Line, LineChart as LineChart$1, ResponsiveContainer, Tooltip as Tooltip$1, XAxis, YAxis } from "recharts";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
//#region src/LineChart/index.tsx
|
|
16
|
+
const LineChart = forwardRef((props, ref) => {
|
|
17
|
+
const themeColorRange = useThemeColorRange();
|
|
18
|
+
const { data = [], categories = [], index, colors = themeColorRange, valueFormatter = defaultValueFormatter, xAxisLabelFormatter = defaultValueFormatter, startEndOnly = false, showXAxis = true, showYAxis = true, yAxisWidth, intervalType = "equidistantPreserveStart", animationDuration = 900, showAnimation = false, yAxisAlign = "left", showTooltip = true, showLegend = true, showGridLines = true, autoMinValue = false, curveType = "linear", minValue, maxValue, connectNulls = false, allowDecimals = true, noDataText, className, onValueChange, enableLegendSlider = false, customTooltip, rotateLabelX, tickGap = 5, xAxisLabel, yAxisLabel, yAxisDomain: yAxisDomainOverride, width = "100%", height = 280, style, customCategories, loading, ...rest } = props;
|
|
19
|
+
const [legendHeight, setLegendHeight] = useState(60);
|
|
20
|
+
const [activeDot, setActiveDot] = useState();
|
|
21
|
+
const [activeLegend, setActiveLegend] = useState();
|
|
22
|
+
const calculatedYAxisWidth = useMemo(() => {
|
|
23
|
+
if (yAxisWidth) return yAxisWidth;
|
|
24
|
+
return getMaxLabelLength({
|
|
25
|
+
data,
|
|
26
|
+
index,
|
|
27
|
+
margin: 16,
|
|
28
|
+
valueFormatter
|
|
29
|
+
});
|
|
30
|
+
}, [
|
|
31
|
+
yAxisWidth,
|
|
32
|
+
data,
|
|
33
|
+
valueFormatter,
|
|
34
|
+
index
|
|
35
|
+
]);
|
|
36
|
+
if (loading || !data) return /* @__PURE__ */ jsx(Skeleton, {
|
|
37
|
+
height,
|
|
38
|
+
width
|
|
39
|
+
});
|
|
40
|
+
const CustomTooltip = customTooltip;
|
|
41
|
+
const paddingValue = !showXAxis && !showYAxis ? 0 : 20;
|
|
42
|
+
const categoryColors = constructCategoryColors(categories, colors);
|
|
43
|
+
const yAxisDomain = yAxisDomainOverride ?? getYAxisDomain(autoMinValue, minValue, maxValue);
|
|
44
|
+
const hasOnValueChange = !!onValueChange;
|
|
45
|
+
const onDotClick = (itemData, event) => {
|
|
46
|
+
event.stopPropagation();
|
|
47
|
+
if (!hasOnValueChange) return;
|
|
48
|
+
if (itemData.index === activeDot?.index && itemData.dataKey === activeDot?.dataKey || hasOnlyOneValueForThisKey(data, itemData.dataKey) && activeLegend && activeLegend === itemData.dataKey) {
|
|
49
|
+
setActiveLegend(void 0);
|
|
50
|
+
setActiveDot(void 0);
|
|
51
|
+
onValueChange?.(null);
|
|
52
|
+
} else {
|
|
53
|
+
setActiveLegend(itemData.dataKey);
|
|
54
|
+
setActiveDot({
|
|
55
|
+
dataKey: itemData.dataKey,
|
|
56
|
+
index: itemData.index
|
|
57
|
+
});
|
|
58
|
+
onValueChange?.({
|
|
59
|
+
categoryClicked: itemData.dataKey,
|
|
60
|
+
eventType: "dot",
|
|
61
|
+
...itemData.payload
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const onCategoryClick = (dataKey) => {
|
|
66
|
+
if (!hasOnValueChange) return;
|
|
67
|
+
if (dataKey === activeLegend && !activeDot || hasOnlyOneValueForThisKey(data, dataKey) && activeDot && activeDot.dataKey === dataKey) {
|
|
68
|
+
setActiveLegend(void 0);
|
|
69
|
+
onValueChange?.(null);
|
|
70
|
+
} else {
|
|
71
|
+
setActiveLegend(dataKey);
|
|
72
|
+
onValueChange?.({
|
|
73
|
+
categoryClicked: dataKey,
|
|
74
|
+
eventType: "category"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
setActiveDot(void 0);
|
|
78
|
+
};
|
|
79
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
80
|
+
className,
|
|
81
|
+
height,
|
|
82
|
+
ref,
|
|
83
|
+
style: {
|
|
84
|
+
position: "relative",
|
|
85
|
+
...style
|
|
86
|
+
},
|
|
87
|
+
width,
|
|
88
|
+
...rest,
|
|
89
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: data?.length ? /* @__PURE__ */ jsxs(LineChart$1, {
|
|
90
|
+
data,
|
|
91
|
+
margin: {
|
|
92
|
+
bottom: xAxisLabel ? 30 : void 0,
|
|
93
|
+
left: yAxisLabel ? 20 : void 0,
|
|
94
|
+
right: yAxisLabel ? 5 : void 0,
|
|
95
|
+
top: 5
|
|
96
|
+
},
|
|
97
|
+
onClick: hasOnValueChange && (activeLegend || activeDot) ? () => {
|
|
98
|
+
setActiveDot(void 0);
|
|
99
|
+
setActiveLegend(void 0);
|
|
100
|
+
onValueChange?.(null);
|
|
101
|
+
} : void 0,
|
|
102
|
+
children: [
|
|
103
|
+
showGridLines ? /* @__PURE__ */ jsx(CartesianGrid, {
|
|
104
|
+
className: styles.gridLines,
|
|
105
|
+
horizontal: true,
|
|
106
|
+
vertical: false
|
|
107
|
+
}) : void 0,
|
|
108
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
109
|
+
angle: rotateLabelX?.angle,
|
|
110
|
+
axisLine: false,
|
|
111
|
+
className: styles.label,
|
|
112
|
+
dataKey: index,
|
|
113
|
+
dy: rotateLabelX?.verticalShift,
|
|
114
|
+
fill: "",
|
|
115
|
+
hide: !showXAxis,
|
|
116
|
+
interval: startEndOnly ? "preserveStartEnd" : intervalType,
|
|
117
|
+
minTickGap: tickGap,
|
|
118
|
+
padding: {
|
|
119
|
+
left: paddingValue,
|
|
120
|
+
right: paddingValue
|
|
121
|
+
},
|
|
122
|
+
stroke: "",
|
|
123
|
+
tick: { transform: "translate(0, 6)" },
|
|
124
|
+
tickFormatter: xAxisLabelFormatter,
|
|
125
|
+
tickLine: false,
|
|
126
|
+
ticks: startEndOnly ? [data[0][index], data.at(-1)[index]] : void 0,
|
|
127
|
+
children: xAxisLabel && /* @__PURE__ */ jsx(Label, {
|
|
128
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
129
|
+
offset: -20,
|
|
130
|
+
position: "insideBottom",
|
|
131
|
+
children: xAxisLabel
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
135
|
+
allowDecimals,
|
|
136
|
+
axisLine: false,
|
|
137
|
+
className: styles.label,
|
|
138
|
+
domain: yAxisDomain,
|
|
139
|
+
fill: "",
|
|
140
|
+
hide: !showYAxis,
|
|
141
|
+
stroke: "",
|
|
142
|
+
tick: (props) => /* @__PURE__ */ jsx(CustomYAxisTick, {
|
|
143
|
+
...props,
|
|
144
|
+
align: yAxisAlign,
|
|
145
|
+
formatter: valueFormatter,
|
|
146
|
+
textAnchor: yAxisAlign === "left" ? "start" : "end",
|
|
147
|
+
yAxisLabel: Boolean(yAxisLabel)
|
|
148
|
+
}),
|
|
149
|
+
tickFormatter: valueFormatter,
|
|
150
|
+
tickLine: false,
|
|
151
|
+
type: "number",
|
|
152
|
+
width: calculatedYAxisWidth,
|
|
153
|
+
children: yAxisLabel && /* @__PURE__ */ jsx(Label, {
|
|
154
|
+
angle: -90,
|
|
155
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
156
|
+
offset: -15,
|
|
157
|
+
position: "insideLeft",
|
|
158
|
+
style: { textAnchor: "middle" },
|
|
159
|
+
children: yAxisLabel
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ jsx(Tooltip$1, {
|
|
163
|
+
content: showTooltip ? ({ active, payload, label }) => CustomTooltip ? /* @__PURE__ */ jsx(CustomTooltip, {
|
|
164
|
+
active,
|
|
165
|
+
customCategories,
|
|
166
|
+
label,
|
|
167
|
+
payload: payload?.map((payloadItem) => ({
|
|
168
|
+
...payloadItem,
|
|
169
|
+
color: categoryColors.get(payloadItem.dataKey) ?? cssVar.colorPrimary
|
|
170
|
+
})),
|
|
171
|
+
valueFormatter
|
|
172
|
+
}) : /* @__PURE__ */ jsx(ChartTooltip, {
|
|
173
|
+
active,
|
|
174
|
+
categoryColors,
|
|
175
|
+
customCategories,
|
|
176
|
+
label,
|
|
177
|
+
payload,
|
|
178
|
+
valueFormatter
|
|
179
|
+
}) : void 0,
|
|
180
|
+
cursor: {
|
|
181
|
+
stroke: cssVar.colorTextSecondary,
|
|
182
|
+
strokeWidth: 1
|
|
183
|
+
},
|
|
184
|
+
isAnimationActive: false,
|
|
185
|
+
position: { y: 0 },
|
|
186
|
+
wrapperStyle: { outline: "none" }
|
|
187
|
+
}),
|
|
188
|
+
showLegend ? /* @__PURE__ */ jsx(Legend, {
|
|
189
|
+
content: ({ payload }) => ChartLegend({ payload }, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? (clickedLegendItem) => onCategoryClick(clickedLegendItem) : void 0, enableLegendSlider, customCategories),
|
|
190
|
+
height: legendHeight,
|
|
191
|
+
verticalAlign: "top"
|
|
192
|
+
}) : void 0,
|
|
193
|
+
categories.map((category) => /* @__PURE__ */ jsx(Line, {
|
|
194
|
+
activeDot: (props) => {
|
|
195
|
+
const { dotCx, dotCy, stroke, strokeLinecap, strokeLinejoin, strokeWidth, dataKey } = props;
|
|
196
|
+
return /* @__PURE__ */ jsx(Dot, {
|
|
197
|
+
className: cx(css`
|
|
198
|
+
fill: ${categoryColors.get(dataKey) ?? cssVar.colorPrimary};
|
|
199
|
+
`),
|
|
200
|
+
cx: dotCx,
|
|
201
|
+
cy: dotCy,
|
|
202
|
+
fill: "",
|
|
203
|
+
onClick: (dotProps, event) => onDotClick(props, event),
|
|
204
|
+
r: 5,
|
|
205
|
+
stroke,
|
|
206
|
+
strokeLinecap,
|
|
207
|
+
strokeLinejoin,
|
|
208
|
+
strokeWidth
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
animationDuration,
|
|
212
|
+
className: cx(css`
|
|
213
|
+
stroke: ${categoryColors.get(category) ?? cssVar.colorPrimary};
|
|
214
|
+
`),
|
|
215
|
+
connectNulls,
|
|
216
|
+
dataKey: category,
|
|
217
|
+
dot: (props) => {
|
|
218
|
+
const { stroke, strokeLinecap, strokeLinejoin, strokeWidth, cx: dotCx, cy: dotCy, dataKey, index } = props;
|
|
219
|
+
if (hasOnlyOneValueForThisKey(data, category) && !(activeDot || activeLegend && activeLegend !== category) || activeDot?.index === index && activeDot?.dataKey === category) return /* @__PURE__ */ jsx(Dot, {
|
|
220
|
+
className: cx(css`
|
|
221
|
+
fill: ${categoryColors.get(dataKey) ?? cssVar.colorPrimary};
|
|
222
|
+
`),
|
|
223
|
+
cx: dotCx,
|
|
224
|
+
cy: dotCy,
|
|
225
|
+
fill: "",
|
|
226
|
+
r: 5,
|
|
227
|
+
stroke,
|
|
228
|
+
strokeLinecap,
|
|
229
|
+
strokeLinejoin,
|
|
230
|
+
strokeWidth
|
|
231
|
+
}, index);
|
|
232
|
+
return /* @__PURE__ */ jsx(Fragment, {}, index);
|
|
233
|
+
},
|
|
234
|
+
isAnimationActive: showAnimation,
|
|
235
|
+
name: category,
|
|
236
|
+
stroke: "",
|
|
237
|
+
strokeLinecap: "round",
|
|
238
|
+
strokeLinejoin: "round",
|
|
239
|
+
strokeOpacity: activeDot || activeLegend && activeLegend !== category ? .3 : 1,
|
|
240
|
+
strokeWidth: 2,
|
|
241
|
+
type: curveType
|
|
242
|
+
}, category)),
|
|
243
|
+
onValueChange ? categories.map((category) => /* @__PURE__ */ jsx(Line, {
|
|
244
|
+
connectNulls,
|
|
245
|
+
dataKey: category,
|
|
246
|
+
fill: "transparent",
|
|
247
|
+
legendType: "none",
|
|
248
|
+
name: category,
|
|
249
|
+
onClick: (props, event) => {
|
|
250
|
+
event.stopPropagation();
|
|
251
|
+
const { name } = props;
|
|
252
|
+
onCategoryClick(name);
|
|
253
|
+
},
|
|
254
|
+
stroke: "transparent",
|
|
255
|
+
strokeOpacity: 0,
|
|
256
|
+
strokeWidth: 12,
|
|
257
|
+
style: { cursor: "pointer" },
|
|
258
|
+
tooltipType: "none",
|
|
259
|
+
type: curveType
|
|
260
|
+
}, category)) : void 0
|
|
261
|
+
]
|
|
262
|
+
}) : /* @__PURE__ */ jsx(NoData, { noDataText }) })
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
LineChart.displayName = "LineChart";
|
|
266
|
+
//#endregion
|
|
267
|
+
export { LineChart as default };
|
|
268
|
+
|
|
269
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["ReChartsLineChart","Tooltip"],"sources":["../../src/LineChart/index.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox, Skeleton, css, cssVar, cx } from '@lobehub/ui';\nimport { Fragment, MouseEvent, forwardRef, useMemo, useState } from 'react';\nimport {\n CartesianGrid,\n Dot,\n Label,\n Legend,\n Line,\n LineChart as ReChartsLineChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport { AxisDomain } from 'recharts/types/util/types';\n\nimport BaseChartProps from '@/common/BaseChartProps';\nimport ChartLegend from '@/common/ChartLegend';\nimport ChartTooltip from '@/common/ChartTooltip';\nimport CustomYAxisTick from '@/common/CustomYAxisTick';\nimport NoData from '@/common/NoData';\nimport { constructCategoryColors, getYAxisDomain, hasOnlyOneValueForThisKey } from '@/common/utils';\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport { CurveType } from '@/types/charts';\nimport { defaultValueFormatter } from '@/utils';\nimport { getMaxLabelLength } from '@/utils/getMaxLabelLength';\n\nimport { styles } from './styles';\n\nexport interface LineChartProps extends BaseChartProps {\n connectNulls?: boolean;\n curveType?: CurveType;\n}\n\ninterface ActiveDot {\n dataKey?: string;\n index?: number;\n}\n\nconst LineChart = forwardRef<HTMLDivElement, LineChartProps>((props, ref) => {\n const themeColorRange = useThemeColorRange();\n const {\n data = [],\n categories = [],\n index,\n colors = themeColorRange,\n valueFormatter = defaultValueFormatter,\n xAxisLabelFormatter = defaultValueFormatter,\n startEndOnly = false,\n showXAxis = true,\n showYAxis = true,\n yAxisWidth,\n intervalType = 'equidistantPreserveStart',\n animationDuration = 900,\n showAnimation = false,\n yAxisAlign = 'left',\n showTooltip = true,\n showLegend = true,\n showGridLines = true,\n autoMinValue = false,\n curveType = 'linear',\n minValue,\n maxValue,\n connectNulls = false,\n allowDecimals = true,\n noDataText,\n className,\n onValueChange,\n enableLegendSlider = false,\n customTooltip,\n rotateLabelX,\n tickGap = 5,\n xAxisLabel,\n yAxisLabel,\n yAxisDomain: yAxisDomainOverride,\n width = '100%',\n height = 280,\n style,\n customCategories,\n loading,\n ...rest\n } = props;\n const [legendHeight, setLegendHeight] = useState(60);\n const [activeDot, setActiveDot] = useState<ActiveDot | undefined>();\n const [activeLegend, setActiveLegend] = useState<string | undefined>();\n const calculatedYAxisWidth: number | string = useMemo(() => {\n if (yAxisWidth) return yAxisWidth;\n return getMaxLabelLength({ data, index, margin: 16, valueFormatter });\n }, [yAxisWidth, data, valueFormatter, index]);\n\n if (loading || !data) return <Skeleton height={height} width={width} />;\n\n const CustomTooltip = customTooltip;\n const paddingValue = !showXAxis && !showYAxis ? 0 : 20;\n const categoryColors = constructCategoryColors(categories, colors);\n const yAxisDomain = (yAxisDomainOverride ??\n getYAxisDomain(autoMinValue, minValue, maxValue)) as AxisDomain;\n const hasOnValueChange = !!onValueChange;\n\n const onDotClick = (itemData: any, event: MouseEvent) => {\n event.stopPropagation();\n\n if (!hasOnValueChange) return;\n if (\n (itemData.index === activeDot?.index && itemData.dataKey === activeDot?.dataKey) ||\n (hasOnlyOneValueForThisKey(data, itemData.dataKey) &&\n activeLegend &&\n activeLegend === itemData.dataKey)\n ) {\n setActiveLegend(undefined);\n setActiveDot(undefined);\n onValueChange?.(null);\n } else {\n setActiveLegend(itemData.dataKey);\n setActiveDot({\n dataKey: itemData.dataKey,\n index: itemData.index,\n });\n onValueChange?.({\n categoryClicked: itemData.dataKey,\n eventType: 'dot',\n ...itemData.payload,\n });\n }\n };\n\n const onCategoryClick = (dataKey: string) => {\n if (!hasOnValueChange) return;\n if (\n (dataKey === activeLegend && !activeDot) ||\n (hasOnlyOneValueForThisKey(data, dataKey) && activeDot && activeDot.dataKey === dataKey)\n ) {\n setActiveLegend(undefined);\n onValueChange?.(null);\n } else {\n setActiveLegend(dataKey);\n onValueChange?.({\n categoryClicked: dataKey,\n eventType: 'category',\n });\n }\n setActiveDot(undefined);\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 <ReChartsLineChart\n data={data}\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 20 : undefined,\n right: yAxisLabel ? 5 : undefined,\n top: 5,\n }}\n onClick={\n hasOnValueChange && (activeLegend || activeDot)\n ? () => {\n setActiveDot(undefined);\n setActiveLegend(undefined);\n onValueChange?.(null);\n }\n : undefined\n }\n >\n {showGridLines ? (\n <CartesianGrid className={styles.gridLines} horizontal={true} vertical={false} />\n ) : undefined}\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 >\n {xAxisLabel}\n </Label>\n )}\n </XAxis>\n <YAxis\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.label}\n domain={yAxisDomain as AxisDomain}\n fill=\"\"\n hide={!showYAxis}\n stroke=\"\"\n tick={(props) => (\n <CustomYAxisTick\n {...props}\n align={yAxisAlign}\n formatter={valueFormatter}\n textAnchor={yAxisAlign === 'left' ? 'start' : 'end'}\n yAxisLabel={Boolean(yAxisLabel)}\n />\n )}\n tickFormatter={valueFormatter}\n tickLine={false}\n type=\"number\"\n width={calculatedYAxisWidth}\n >\n {yAxisLabel && (\n <Label\n angle={-90}\n className={cx(styles.strongLabel, styles.emphasis)}\n offset={-15}\n position=\"insideLeft\"\n style={{ textAnchor: 'middle' }}\n >\n {yAxisLabel}\n </Label>\n )}\n </YAxis>\n <Tooltip\n content={\n showTooltip\n ? ({ active, payload, label }) =>\n CustomTooltip ? (\n <CustomTooltip\n active={active}\n customCategories={customCategories}\n label={label}\n payload={payload?.map((payloadItem: any) => ({\n ...payloadItem,\n color: categoryColors.get(payloadItem.dataKey) ?? cssVar.colorPrimary,\n }))}\n valueFormatter={valueFormatter}\n />\n ) : (\n <ChartTooltip\n active={active}\n categoryColors={categoryColors}\n customCategories={customCategories}\n label={label}\n payload={payload}\n valueFormatter={valueFormatter}\n />\n )\n : undefined\n }\n cursor={{ stroke: cssVar.colorTextSecondary, strokeWidth: 1 }}\n isAnimationActive={false}\n position={{ y: 0 }}\n wrapperStyle={{ outline: 'none' }}\n />\n\n {showLegend ? (\n <Legend\n content={({ payload }) =>\n ChartLegend(\n { payload },\n categoryColors,\n setLegendHeight,\n activeLegend,\n hasOnValueChange\n ? (clickedLegendItem: string) => onCategoryClick(clickedLegendItem)\n : undefined,\n enableLegendSlider,\n customCategories,\n )\n }\n height={legendHeight}\n verticalAlign=\"top\"\n />\n ) : undefined}\n {categories.map((category) => (\n <Line\n activeDot={(props: any) => {\n const {\n dotCx,\n dotCy,\n stroke,\n strokeLinecap,\n strokeLinejoin,\n strokeWidth,\n dataKey,\n } = props;\n return (\n <Dot\n className={cx(css`\n fill: ${categoryColors.get(dataKey) ?? cssVar.colorPrimary};\n `)}\n cx={dotCx}\n cy={dotCy}\n fill=\"\"\n onClick={(dotProps: any, event) => onDotClick(props, event)}\n r={5}\n stroke={stroke}\n strokeLinecap={strokeLinecap}\n strokeLinejoin={strokeLinejoin}\n strokeWidth={strokeWidth}\n />\n );\n }}\n animationDuration={animationDuration}\n className={cx(css`\n stroke: ${categoryColors.get(category) ?? cssVar.colorPrimary};\n `)}\n connectNulls={connectNulls}\n dataKey={category}\n dot={(props: any) => {\n const {\n stroke,\n strokeLinecap,\n strokeLinejoin,\n strokeWidth,\n cx: dotCx,\n cy: dotCy,\n dataKey,\n index,\n } = props;\n\n if (\n (hasOnlyOneValueForThisKey(data, category) &&\n !(activeDot || (activeLegend && activeLegend !== category))) ||\n (activeDot?.index === index && activeDot?.dataKey === category)\n ) {\n return (\n <Dot\n className={cx(css`\n fill: ${categoryColors.get(dataKey) ?? cssVar.colorPrimary};\n `)}\n cx={dotCx}\n cy={dotCy}\n fill=\"\"\n key={index}\n r={5}\n stroke={stroke}\n strokeLinecap={strokeLinecap}\n strokeLinejoin={strokeLinejoin}\n strokeWidth={strokeWidth}\n />\n );\n }\n return <Fragment key={index} />;\n }}\n isAnimationActive={showAnimation}\n key={category}\n name={category}\n stroke=\"\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeOpacity={activeDot || (activeLegend && activeLegend !== category) ? 0.3 : 1}\n strokeWidth={2}\n type={curveType}\n />\n ))}\n {onValueChange\n ? categories.map((category) => (\n <Line\n connectNulls={connectNulls}\n dataKey={category}\n fill=\"transparent\"\n key={category}\n legendType=\"none\"\n name={category}\n onClick={(props: any, event) => {\n event.stopPropagation();\n const { name } = props;\n onCategoryClick(name);\n }}\n stroke=\"transparent\"\n strokeOpacity={0}\n strokeWidth={12}\n style={{\n cursor: 'pointer',\n }}\n tooltipType=\"none\"\n type={curveType}\n />\n ))\n : undefined}\n </ReChartsLineChart>\n ) : (\n <NoData noDataText={noDataText} />\n )}\n </ResponsiveContainer>\n </Flexbox>\n );\n});\n\nLineChart.displayName = 'LineChart';\n\nexport default LineChart;\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,MAAM,YAAY,YAA4C,OAAO,QAAQ;CAC3E,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,EACJ,OAAO,CAAC,GACR,aAAa,CAAC,GACd,OACA,SAAS,iBACT,iBAAiB,uBACjB,sBAAsB,uBACtB,eAAe,OACf,YAAY,MACZ,YAAY,MACZ,YACA,eAAe,4BACf,oBAAoB,KACpB,gBAAgB,OAChB,aAAa,QACb,cAAc,MACd,aAAa,MACb,gBAAgB,MAChB,eAAe,OACf,YAAY,UACZ,UACA,UACA,eAAe,OACf,gBAAgB,MAChB,YACA,WACA,eACA,qBAAqB,OACrB,eACA,cACA,UAAU,GACV,YACA,YACA,aAAa,qBACb,QAAQ,QACR,SAAS,KACT,OACA,kBACA,SACA,GAAG,SACD;CACJ,MAAM,CAAC,cAAc,mBAAmB,SAAS,EAAE;CACnD,MAAM,CAAC,WAAW,gBAAgB,SAAgC;CAClE,MA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AAO,aAAa;iBAC/D;KACa;KACd,SAAS;KACT,MAAM,UAAe;MACnB,MAAM,EACJ,QACA,eACA,gBACA,aACA,IAAI,OACJ,IAAI,OACJ,SACA,UACE;MAEJ,IACG,0BAA0B,MAAM,QAAQ,KACvC,EAAE,aAAc,gBAAgB,iBAAiB,aAClD,WAAW,UAAU,SAAS,WAAW,YAAY,UAEtD,OACE,oBAAC,KAAD;OACE,WAAW,GAAG,GAAG;kCACP,eAAe,IAAI,OAAO,KAAK,OAAO,aAAa;yBAC5D;OACD,IAAI;OACJ,IAAI;OACJ,MAAK;OAEL,GAAG;OACK;OACO;OACC;OACH;MACd,GANM,KAMN;MAGL,OAAO,oBAAC,UAAD,CAAuB,GAAR,KAAQ;KAChC;KACA,mBAAmB;KAEnB,MAAM;KACN,QAAO;KACP,eAAc;KACd,gBAAe;KACf,eAAe,aAAc,gBAAgB,iBAAiB,WAAY,KAAM;KAChF,aAAa;KACb,MAAM;IACP,GARM,QAQN,CACF;IACA,gBACG,WAAW,KAAK,aACd,oBAAC,MAAD;KACgB;KACd,SAAS;KACT,MAAK;KAEL,YAAW;KACX,MAAM;KACN,UAAU,OAAY,UAAU;MAC9B,MAAM,gBAAgB;MACtB,MAAM,EAAE,SAAS;MACjB,gBAAgB,IAAI;KACtB;KACA,QAAO;KACP,eAAe;KACf,aAAa;KACb,OAAO,EACL,QAAQ,UACV;KACA,aAAY;KACZ,MAAM;IACP,GAhBM,QAgBN,CACF,IACD,KAAA;GACa;EAEnB,CAAA,IAAA,oBAAC,QAAD,EAAoB,WAAa,CAAA,EAEhB,CAAA;CACd,CAAA;AAEb,CAAC;AAED,UAAU,cAAc"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createStaticStyles } from "@lobehub/ui";
|
|
2
|
+
//#region src/LineChart/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/LineChart/styles.ts"],"sourcesContent":["import { createStaticStyles } from '@lobehub/ui';\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,27 @@
|
|
|
1
|
+
import BaseChartProps from "../common/BaseChartProps.mjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/RadarChart/index.d.ts
|
|
4
|
+
export interface RadarChartProps extends BaseChartProps {
|
|
5
|
+
/**
|
|
6
|
+
* Format angle-axis labels. Receives the index value and the matching data row.
|
|
7
|
+
* Can return a string or ReactNode (e.g. colored `<tspan>`).
|
|
8
|
+
*/
|
|
9
|
+
angleAxisLabelFormatter?: (value: string | number, payload?: Record<string, any>) => ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* When true, series after the first are rendered at `secondaryOpacity`.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
dimSecondarySeries?: boolean;
|
|
15
|
+
fillOpacity?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Opacity applied to series after the first when `dimSecondarySeries` is enabled.
|
|
18
|
+
* @default 0.25
|
|
19
|
+
*/
|
|
20
|
+
secondaryOpacity?: number;
|
|
21
|
+
shape?: 'polygon' | 'circle';
|
|
22
|
+
showRadiusAxis?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare const RadarChart: import("react").ForwardRefExoticComponent<RadarChartProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { RadarChart as default };
|
|
27
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,155 @@
|
|
|
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 NoData from "../common/NoData.mjs";
|
|
7
|
+
import { constructCategoryColors, getYAxisDomain } from "../common/utils.mjs";
|
|
8
|
+
import { styles } from "./styles.mjs";
|
|
9
|
+
import { Flexbox, Skeleton, cssVar } from "@lobehub/ui";
|
|
10
|
+
import { forwardRef, useState } from "react";
|
|
11
|
+
import { Legend, PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart as RadarChart$1, ResponsiveContainer, Tooltip as Tooltip$1 } from "recharts";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
//#region src/RadarChart/index.tsx
|
|
14
|
+
const RadarChart = forwardRef((props, ref) => {
|
|
15
|
+
const themeColorRange = useThemeColorRange();
|
|
16
|
+
const { data = [], categories = [], customCategories, index, colors = themeColorRange, valueFormatter = defaultValueFormatter, animationDuration = 900, showAnimation = false, showTooltip = true, showLegend = true, showGridLines = true, autoMinValue = false, minValue, maxValue, allowDecimals = true, noDataText, onValueChange, enableLegendSlider = false, customTooltip, loading, className, width = "100%", height = 280, style, shape = "polygon", fillOpacity = .33, showRadiusAxis = false, dimSecondarySeries = true, secondaryOpacity = .25, angleAxisLabelFormatter, xAxisLabelFormatter, yAxisDomain: yAxisDomainOverride, ...rest } = props;
|
|
17
|
+
const [activeLegend, setActiveLegend] = useState();
|
|
18
|
+
const [legendHeight, setLegendHeight] = useState(60);
|
|
19
|
+
if (loading || !data) return /* @__PURE__ */ jsx(Skeleton, {
|
|
20
|
+
height,
|
|
21
|
+
width
|
|
22
|
+
});
|
|
23
|
+
const CustomTooltip = customTooltip;
|
|
24
|
+
const categoryColors = constructCategoryColors(categories, colors);
|
|
25
|
+
const hasOnValueChange = !!onValueChange;
|
|
26
|
+
const yAxisDomain = yAxisDomainOverride ?? getYAxisDomain(autoMinValue, minValue, maxValue);
|
|
27
|
+
const onCategoryClick = (dataKey) => {
|
|
28
|
+
if (!hasOnValueChange) return;
|
|
29
|
+
if (dataKey === activeLegend) {
|
|
30
|
+
setActiveLegend(void 0);
|
|
31
|
+
onValueChange?.(null);
|
|
32
|
+
} else {
|
|
33
|
+
setActiveLegend(dataKey);
|
|
34
|
+
onValueChange?.({
|
|
35
|
+
categoryClicked: dataKey,
|
|
36
|
+
eventType: "category"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
41
|
+
className,
|
|
42
|
+
height,
|
|
43
|
+
ref,
|
|
44
|
+
style: {
|
|
45
|
+
position: "relative",
|
|
46
|
+
...style
|
|
47
|
+
},
|
|
48
|
+
width,
|
|
49
|
+
...rest,
|
|
50
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: data?.length ? /* @__PURE__ */ jsxs(RadarChart$1, {
|
|
51
|
+
data,
|
|
52
|
+
margin: {
|
|
53
|
+
bottom: 10,
|
|
54
|
+
left: 10,
|
|
55
|
+
right: 10,
|
|
56
|
+
top: 10
|
|
57
|
+
},
|
|
58
|
+
onClick: hasOnValueChange && activeLegend ? () => {
|
|
59
|
+
setActiveLegend(void 0);
|
|
60
|
+
onValueChange?.(null);
|
|
61
|
+
} : void 0,
|
|
62
|
+
children: [
|
|
63
|
+
showGridLines ? /* @__PURE__ */ jsx(PolarGrid, {
|
|
64
|
+
className: styles.gridLines,
|
|
65
|
+
fill: "none",
|
|
66
|
+
gridType: shape,
|
|
67
|
+
stroke: cssVar.colorBorderSecondary
|
|
68
|
+
}) : void 0,
|
|
69
|
+
/* @__PURE__ */ jsx(PolarAngleAxis, {
|
|
70
|
+
axisLine: false,
|
|
71
|
+
className: styles.label,
|
|
72
|
+
dataKey: index,
|
|
73
|
+
tick: (tickProps) => {
|
|
74
|
+
const { x, y, textAnchor, payload: tickPayload } = tickProps;
|
|
75
|
+
const value = tickPayload?.value;
|
|
76
|
+
const row = data.find((item) => item[index] === value);
|
|
77
|
+
let content = value;
|
|
78
|
+
if (angleAxisLabelFormatter) content = angleAxisLabelFormatter(value, row);
|
|
79
|
+
else if (xAxisLabelFormatter) content = xAxisLabelFormatter(value);
|
|
80
|
+
return /* @__PURE__ */ jsx("text", {
|
|
81
|
+
className: "recharts-polar-angle-axis-tick-value",
|
|
82
|
+
fill: cssVar.colorTextDescription,
|
|
83
|
+
fontSize: 12,
|
|
84
|
+
textAnchor,
|
|
85
|
+
x,
|
|
86
|
+
y,
|
|
87
|
+
children: content
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
tickLine: false
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ jsx(PolarRadiusAxis, {
|
|
93
|
+
allowDecimals,
|
|
94
|
+
axisLine: false,
|
|
95
|
+
className: styles.radiusLabel,
|
|
96
|
+
domain: yAxisDomain,
|
|
97
|
+
stroke: cssVar.colorTextQuaternary,
|
|
98
|
+
tick: showRadiusAxis,
|
|
99
|
+
tickFormatter: valueFormatter,
|
|
100
|
+
tickLine: false
|
|
101
|
+
}),
|
|
102
|
+
showTooltip ? /* @__PURE__ */ jsx(Tooltip$1, {
|
|
103
|
+
content: ({ active, payload, label }) => CustomTooltip ? /* @__PURE__ */ jsx(CustomTooltip, {
|
|
104
|
+
active,
|
|
105
|
+
customCategories,
|
|
106
|
+
label,
|
|
107
|
+
payload: payload?.map((payloadItem) => ({
|
|
108
|
+
...payloadItem,
|
|
109
|
+
color: categoryColors.get(payloadItem.dataKey) ?? cssVar.colorPrimary
|
|
110
|
+
})),
|
|
111
|
+
valueFormatter
|
|
112
|
+
}) : /* @__PURE__ */ jsx(ChartTooltip, {
|
|
113
|
+
active,
|
|
114
|
+
categoryColors,
|
|
115
|
+
customCategories,
|
|
116
|
+
label,
|
|
117
|
+
payload,
|
|
118
|
+
valueFormatter
|
|
119
|
+
}),
|
|
120
|
+
isAnimationActive: false,
|
|
121
|
+
wrapperStyle: { outline: "none" }
|
|
122
|
+
}) : void 0,
|
|
123
|
+
showLegend ? /* @__PURE__ */ jsx(Legend, {
|
|
124
|
+
content: ({ payload }) => ChartLegend({ payload: payload?.slice().reverse() }, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? (clickedLegendItem) => onCategoryClick(clickedLegendItem) : void 0, enableLegendSlider, customCategories),
|
|
125
|
+
height: legendHeight,
|
|
126
|
+
verticalAlign: "top"
|
|
127
|
+
}) : void 0,
|
|
128
|
+
[...categories].reverse().map((category) => {
|
|
129
|
+
const isInactive = Boolean(activeLegend && activeLegend !== category);
|
|
130
|
+
const isSecondary = dimSecondarySeries && category !== categories[0];
|
|
131
|
+
const seriesFillOpacity = isSecondary ? fillOpacity * secondaryOpacity : fillOpacity;
|
|
132
|
+
const seriesStrokeOpacity = isSecondary ? secondaryOpacity : 1;
|
|
133
|
+
const color = categoryColors.get(category) ?? cssVar.colorPrimary;
|
|
134
|
+
return /* @__PURE__ */ jsx(Radar, {
|
|
135
|
+
animationDuration,
|
|
136
|
+
dataKey: category,
|
|
137
|
+
fill: color,
|
|
138
|
+
fillOpacity: isInactive ? seriesFillOpacity * .3 : seriesFillOpacity,
|
|
139
|
+
isAnimationActive: showAnimation,
|
|
140
|
+
name: category,
|
|
141
|
+
stroke: color,
|
|
142
|
+
strokeOpacity: isInactive ? seriesStrokeOpacity * .3 : seriesStrokeOpacity,
|
|
143
|
+
strokeWidth: 2,
|
|
144
|
+
style: { cursor: onValueChange ? "pointer" : void 0 }
|
|
145
|
+
}, category);
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
}) : /* @__PURE__ */ jsx(NoData, { noDataText }) })
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
RadarChart.displayName = "RadarChart";
|
|
152
|
+
//#endregion
|
|
153
|
+
export { RadarChart as default };
|
|
154
|
+
|
|
155
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["ReChartsRadarChart","Tooltip"],"sources":["../../src/RadarChart/index.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox, Skeleton, cssVar } from '@lobehub/ui';\nimport { ReactNode, forwardRef, useState } from 'react';\nimport {\n Legend,\n PolarAngleAxis,\n PolarGrid,\n PolarRadiusAxis,\n Radar,\n RadarChart as ReChartsRadarChart,\n ResponsiveContainer,\n Tooltip,\n} from 'recharts';\nimport { AxisDomain } from 'recharts/types/util/types';\n\nimport BaseChartProps from '@/common/BaseChartProps';\nimport ChartLegend from '@/common/ChartLegend';\nimport ChartTooltip from '@/common/ChartTooltip';\nimport NoData from '@/common/NoData';\nimport { constructCategoryColors, getYAxisDomain } from '@/common/utils';\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport { defaultValueFormatter } from '@/utils';\n\nimport { styles } from './styles';\n\nexport interface RadarChartProps extends BaseChartProps {\n /**\n * Format angle-axis labels. Receives the index value and the matching data row.\n * Can return a string or ReactNode (e.g. colored `<tspan>`).\n */\n angleAxisLabelFormatter?: (value: string | number, payload?: Record<string, any>) => ReactNode;\n /**\n * When true, series after the first are rendered at `secondaryOpacity`.\n * @default true\n */\n dimSecondarySeries?: boolean;\n fillOpacity?: number;\n /**\n * Opacity applied to series after the first when `dimSecondarySeries` is enabled.\n * @default 0.25\n */\n secondaryOpacity?: number;\n shape?: 'polygon' | 'circle';\n showRadiusAxis?: boolean;\n}\n\nconst RadarChart = forwardRef<HTMLDivElement, RadarChartProps>((props, ref) => {\n const themeColorRange = useThemeColorRange();\n const {\n data = [],\n categories = [],\n customCategories,\n index,\n colors = themeColorRange,\n valueFormatter = defaultValueFormatter,\n animationDuration = 900,\n showAnimation = false,\n showTooltip = true,\n showLegend = true,\n showGridLines = true,\n autoMinValue = false,\n minValue,\n maxValue,\n allowDecimals = true,\n noDataText,\n onValueChange,\n enableLegendSlider = false,\n customTooltip,\n loading,\n className,\n width = '100%',\n height = 280,\n style,\n shape = 'polygon',\n fillOpacity = 0.33,\n showRadiusAxis = false,\n dimSecondarySeries = true,\n secondaryOpacity = 0.25,\n angleAxisLabelFormatter,\n xAxisLabelFormatter,\n yAxisDomain: yAxisDomainOverride,\n ...rest\n } = props;\n\n const [activeLegend, setActiveLegend] = useState<string | undefined>();\n const [legendHeight, setLegendHeight] = useState(60);\n\n if (loading || !data) return <Skeleton height={height} width={width} />;\n\n const CustomTooltip = customTooltip;\n const categoryColors = constructCategoryColors(categories, colors);\n const hasOnValueChange = !!onValueChange;\n const yAxisDomain = (yAxisDomainOverride ??\n getYAxisDomain(autoMinValue, minValue, maxValue)) as AxisDomain;\n\n const onCategoryClick = (dataKey: string) => {\n if (!hasOnValueChange) return;\n if (dataKey === activeLegend) {\n setActiveLegend(undefined);\n onValueChange?.(null);\n } else {\n setActiveLegend(dataKey);\n onValueChange?.({\n categoryClicked: dataKey,\n eventType: 'category',\n });\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 <ReChartsRadarChart\n data={data}\n margin={{ bottom: 10, left: 10, right: 10, top: 10 }}\n onClick={\n hasOnValueChange && activeLegend\n ? () => {\n setActiveLegend(undefined);\n onValueChange?.(null);\n }\n : undefined\n }\n >\n {showGridLines ? (\n <PolarGrid\n className={styles.gridLines}\n fill=\"none\"\n gridType={shape}\n stroke={cssVar.colorBorderSecondary}\n />\n ) : undefined}\n <PolarAngleAxis\n axisLine={false}\n className={styles.label}\n dataKey={index}\n tick={(tickProps: any) => {\n const { x, y, textAnchor, payload: tickPayload } = tickProps;\n const value = tickPayload?.value;\n const row = data.find((item) => item[index] === value);\n let content: ReactNode = value;\n if (angleAxisLabelFormatter) {\n content = angleAxisLabelFormatter(value, row);\n } else if (xAxisLabelFormatter) {\n content = xAxisLabelFormatter(value);\n }\n return (\n <text\n className=\"recharts-polar-angle-axis-tick-value\"\n fill={cssVar.colorTextDescription}\n fontSize={12}\n textAnchor={textAnchor}\n x={x}\n y={y}\n >\n {content}\n </text>\n );\n }}\n tickLine={false}\n />\n <PolarRadiusAxis\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.radiusLabel}\n domain={yAxisDomain}\n stroke={cssVar.colorTextQuaternary}\n tick={showRadiusAxis}\n tickFormatter={valueFormatter}\n tickLine={false}\n />\n {showTooltip ? (\n <Tooltip\n content={({ active, payload, label }) =>\n CustomTooltip ? (\n <CustomTooltip\n active={active}\n customCategories={customCategories}\n label={label}\n payload={payload?.map((payloadItem: any) => ({\n ...payloadItem,\n color: categoryColors.get(payloadItem.dataKey) ?? cssVar.colorPrimary,\n }))}\n valueFormatter={valueFormatter}\n />\n ) : (\n <ChartTooltip\n active={active}\n categoryColors={categoryColors}\n customCategories={customCategories}\n label={label}\n payload={payload}\n valueFormatter={valueFormatter}\n />\n )\n }\n isAnimationActive={false}\n wrapperStyle={{ outline: 'none' }}\n />\n ) : undefined}\n {showLegend ? (\n <Legend\n content={({ payload }) =>\n ChartLegend(\n { payload: payload?.slice().reverse() },\n categoryColors,\n setLegendHeight,\n activeLegend,\n hasOnValueChange\n ? (clickedLegendItem: string) => onCategoryClick(clickedLegendItem)\n : undefined,\n enableLegendSlider,\n customCategories,\n )\n }\n height={legendHeight}\n verticalAlign=\"top\"\n />\n ) : undefined}\n {/* Render later categories first so earlier ones (e.g. A) paint on top */}\n {[...categories].reverse().map((category) => {\n const isInactive = Boolean(activeLegend && activeLegend !== category);\n const isSecondary = dimSecondarySeries && category !== categories[0];\n const seriesFillOpacity = isSecondary ? fillOpacity * secondaryOpacity : fillOpacity;\n const seriesStrokeOpacity = isSecondary ? secondaryOpacity : 1;\n const color = categoryColors.get(category) ?? cssVar.colorPrimary;\n return (\n <Radar\n animationDuration={animationDuration}\n dataKey={category}\n fill={color}\n fillOpacity={isInactive ? seriesFillOpacity * 0.3 : seriesFillOpacity}\n isAnimationActive={showAnimation}\n key={category}\n name={category}\n stroke={color}\n strokeOpacity={isInactive ? seriesStrokeOpacity * 0.3 : seriesStrokeOpacity}\n strokeWidth={2}\n style={{\n cursor: onValueChange ? 'pointer' : undefined,\n }}\n />\n );\n })}\n </ReChartsRadarChart>\n ) : (\n <NoData noDataText={noDataText} />\n )}\n </ResponsiveContainer>\n </Flexbox>\n );\n});\n\nRadarChart.displayName = 'RadarChart';\n\nexport default RadarChart;\n"],"mappings":";;;;;;;;;;;;;AA+CA,MAAM,aAAa,YAA6C,OAAO,QAAQ;CAC7E,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,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AAG,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,aAAa;KAC3C,MAAM,aAAa,QAAQ,gBAAgB,iBAAiB,QAAQ;KACpE,MAAM,cAAc,sBAAsB,aAAa,WAAW;KAClE,MAAM,oBAAoB,cAAc,cAAc,mBAAmB;KACzE,MAAM,sBAAsB,cAAc,mBAAmB;KAC7D,MAAM,QAAQ,eAAe,IAAI,QAAQ,KAAK,OAAO;KACrD,OACE,oBAAC,OAAD;MACqB;MACnB,SAAS;MACT,MAAM;MACN,aAAa,aAAa,oBAAoB,KAAM;MACpD,mBAAmB;MAEnB,MAAM;MACN,QAAQ;MACR,eAAe,aAAa,sBAAsB,KAAM;MACxD,aAAa;MACb,OAAO,EACL,QAAQ,gBAAgB,YAAY,KAAA,EACtC;KACD,GARM,QAQN;IAEL,CAAC;GACiB;EAEpB,CAAA,IAAA,oBAAC,QAAD,EAAoB,WAAa,CAAA,EAEhB,CAAA;CACd,CAAA;AAEb,CAAC;AAED,WAAW,cAAc"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createStaticStyles } from "@lobehub/ui";
|
|
2
|
+
//#region src/RadarChart/styles.ts
|
|
3
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
4
|
+
gridLines: css`
|
|
5
|
+
fill: none;
|
|
6
|
+
stroke: ${cssVar.colorBorderSecondary};
|
|
7
|
+
stroke-width: 1;
|
|
8
|
+
`,
|
|
9
|
+
label: css`
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
line-height: 16px;
|
|
12
|
+
fill: ${cssVar.colorTextDescription};
|
|
13
|
+
`,
|
|
14
|
+
radiusLabel: css`
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
line-height: 16px;
|
|
17
|
+
fill: ${cssVar.colorTextQuaternary};
|
|
18
|
+
`
|
|
19
|
+
}));
|
|
20
|
+
//#endregion
|
|
21
|
+
export { styles };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=styles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.mjs","names":[],"sources":["../../src/RadarChart/styles.ts"],"sourcesContent":["import { createStaticStyles } from '@lobehub/ui';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n gridLines: css`\n fill: none;\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 radiusLabel: css`\n font-size: 12px;\n line-height: 16px;\n fill: ${cssVar.colorTextQuaternary};\n `,\n}));\n"],"mappings":";;AAEA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,WAAW,GAAG;;cAEF,OAAO,qBAAqB;;;CAGxC,OAAO,GAAG;;;YAGA,OAAO,qBAAqB;;CAEtC,aAAa,GAAG;;;YAGN,OAAO,oBAAoB;;AAEvC,EAAE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ScatterChartValueFormatter } from "../types/charts.mjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
//#region src/ScatterChart/ScatterChartTooltip.d.ts
|
|
4
|
+
export interface ScatterChartTooltipProps {
|
|
5
|
+
active: boolean | undefined;
|
|
6
|
+
axis: any;
|
|
7
|
+
category?: string;
|
|
8
|
+
categoryColors: Map<string, string>;
|
|
9
|
+
customCategories?: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
label: string;
|
|
13
|
+
payload: any;
|
|
14
|
+
valueFormatter: ScatterChartValueFormatter;
|
|
15
|
+
}
|
|
16
|
+
declare const ScatterChartTooltip: React.NamedExoticComponent<ScatterChartTooltipProps>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ScatterChartTooltip as default };
|
|
19
|
+
//# sourceMappingURL=ScatterChartTooltip.d.mts.map
|