@lobehub/charts 6.0.1 → 6.1.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 +8 -10
- package/es/AccuracyBarChart/index.d.mts +7 -5
- package/es/AccuracyBarChart/index.mjs +36 -37
- package/es/AccuracyBarChart/index.mjs.map +1 -1
- package/es/AccuracyBarChart/styles.d.mts +1 -4
- package/es/AccuracyBarChart/styles.mjs +6 -7
- package/es/AccuracyBarChart/styles.mjs.map +1 -1
- package/es/AreaChart/index.d.mts +11 -7
- package/es/AreaChart/index.mjs +100 -60
- package/es/AreaChart/index.mjs.map +1 -1
- package/es/AreaChart/styles.d.mts +1 -4
- package/es/AreaChart/styles.mjs +1 -2
- package/es/BarChart/A2uiBarChart.d.mts +56 -0
- package/es/BarChart/A2uiBarChart.mjs +368 -0
- package/es/BarChart/A2uiBarChart.mjs.map +1 -0
- package/es/BarChart/index.d.mts +10 -6
- package/es/BarChart/index.mjs +70 -33
- package/es/BarChart/index.mjs.map +1 -1
- package/es/BarChart/renderShape.d.mts +1 -4
- package/es/BarChart/renderShape.mjs +5 -6
- package/es/BarChart/renderShape.mjs.map +1 -1
- package/es/BarChart/styles.d.mts +1 -4
- package/es/BarChart/styles.mjs +1 -2
- package/es/BarList/index.d.mts +8 -6
- package/es/BarList/index.mjs +13 -14
- package/es/BarList/index.mjs.map +1 -1
- package/es/BarList/styles.d.mts +1 -4
- package/es/BarList/styles.mjs +3 -5
- package/es/BarList/styles.mjs.map +1 -1
- package/es/BenchmarkColumnChart/index.d.mts +8 -6
- package/es/BenchmarkColumnChart/index.mjs +38 -39
- package/es/BenchmarkColumnChart/index.mjs.map +1 -1
- package/es/BenchmarkColumnChart/styles.d.mts +1 -4
- package/es/BenchmarkColumnChart/styles.mjs +6 -8
- package/es/BenchmarkColumnChart/styles.mjs.map +1 -1
- package/es/BenchmarkRankingChart/index.d.mts +8 -6
- package/es/BenchmarkRankingChart/index.mjs +16 -17
- package/es/BenchmarkRankingChart/index.mjs.map +1 -1
- package/es/BenchmarkRankingChart/styles.d.mts +1 -4
- package/es/BenchmarkRankingChart/styles.mjs +25 -27
- package/es/BenchmarkRankingChart/styles.mjs.map +1 -1
- package/es/BenchmarkScatterChart/index.d.mts +7 -5
- package/es/BenchmarkScatterChart/index.mjs +22 -23
- package/es/BenchmarkScatterChart/index.mjs.map +1 -1
- package/es/BenchmarkScatterChart/styles.d.mts +1 -4
- package/es/BenchmarkScatterChart/styles.mjs +3 -2
- package/es/BenchmarkScatterChart/styles.mjs.map +1 -1
- package/es/BenchmarkScatterChart/utils.d.mts +1 -4
- package/es/BenchmarkScatterChart/utils.mjs +4 -5
- package/es/BenchmarkScatterChart/utils.mjs.map +1 -1
- package/es/CandlestickChart/index.d.mts +52 -0
- package/es/CandlestickChart/index.mjs +205 -0
- package/es/CandlestickChart/index.mjs.map +1 -0
- package/es/CandlestickChart/styles.d.mts +5 -0
- package/es/CandlestickChart/styles.mjs +24 -0
- package/es/CandlestickChart/styles.mjs.map +1 -0
- package/es/CandlestickChart/utils.d.mts +17 -0
- package/es/CandlestickChart/utils.mjs +56 -0
- package/es/CandlestickChart/utils.mjs.map +1 -0
- package/es/ChartFrame/index.d.mts +40 -0
- package/es/ChartFrame/index.mjs +18 -0
- package/es/ChartFrame/index.mjs.map +1 -0
- package/es/ComposedChart/index.d.mts +7 -5
- package/es/ComposedChart/index.mjs +37 -38
- package/es/ComposedChart/index.mjs.map +1 -1
- package/es/ComposedChart/styles.d.mts +1 -4
- package/es/ComposedChart/styles.mjs +1 -2
- package/es/ComposedChart/types.d.mts +3 -6
- package/es/DataBars/CategoryBar.d.mts +8 -6
- package/es/DataBars/CategoryBar.mjs +13 -14
- package/es/DataBars/CategoryBar.mjs.map +1 -1
- package/es/DataBars/DeltaBar.d.mts +7 -5
- package/es/DataBars/DeltaBar.mjs +10 -12
- package/es/DataBars/DeltaBar.mjs.map +1 -1
- package/es/DataBars/MarkerBar.d.mts +7 -5
- package/es/DataBars/MarkerBar.mjs +10 -12
- package/es/DataBars/MarkerBar.mjs.map +1 -1
- package/es/DataBars/ProgressBar.d.mts +7 -5
- package/es/DataBars/ProgressBar.mjs +10 -12
- package/es/DataBars/ProgressBar.mjs.map +1 -1
- package/es/DataBars/styles.d.mts +1 -4
- package/es/DataBars/styles.mjs +2 -3
- package/es/DataBars/styles.mjs.map +1 -1
- package/es/DonutChart/A2uiDonutChart.d.mts +35 -0
- package/es/DonutChart/A2uiDonutChart.mjs +189 -0
- package/es/DonutChart/A2uiDonutChart.mjs.map +1 -0
- package/es/DonutChart/DonutChartTooltip.d.mts +2 -5
- package/es/DonutChart/DonutChartTooltip.mjs +3 -4
- package/es/DonutChart/DonutChartTooltip.mjs.map +1 -1
- package/es/DonutChart/a2uiStyles.d.mts +13 -0
- package/es/DonutChart/a2uiStyles.mjs +90 -0
- package/es/DonutChart/a2uiStyles.mjs.map +1 -0
- package/es/DonutChart/index.d.mts +42 -9
- package/es/DonutChart/index.mjs +48 -16
- package/es/DonutChart/index.mjs.map +1 -1
- package/es/DonutChart/inputParser.d.mts +1 -4
- package/es/DonutChart/inputParser.mjs +1 -2
- package/es/DonutChart/inputParser.mjs.map +1 -1
- package/es/DonutChart/renderInactiveShape.d.mts +1 -4
- package/es/DonutChart/renderInactiveShape.mjs +1 -2
- package/es/DonutChart/styles.d.mts +1 -4
- package/es/DonutChart/styles.mjs +1 -2
- package/es/FunnelChart/ArrowRightIcon.d.mts +1 -4
- package/es/FunnelChart/ArrowRightIcon.mjs +1 -2
- package/es/FunnelChart/index.d.mts +7 -5
- package/es/FunnelChart/index.mjs +43 -44
- package/es/FunnelChart/index.mjs.map +1 -1
- package/es/FunnelChart/styles.d.mts +1 -4
- package/es/FunnelChart/styles.mjs +1 -2
- package/es/FunnelChart/types.d.mts +1 -4
- package/es/GaugeChart/index.d.mts +49 -0
- package/es/GaugeChart/index.mjs +77 -0
- package/es/GaugeChart/index.mjs.map +1 -0
- package/es/GaugeChart/styles.d.mts +9 -0
- package/es/GaugeChart/styles.mjs +73 -0
- package/es/GaugeChart/styles.mjs.map +1 -0
- package/es/GaugeChart/utils.d.mts +5 -0
- package/es/GaugeChart/utils.mjs +32 -0
- package/es/GaugeChart/utils.mjs.map +1 -0
- package/es/HeatmapChart/index.d.mts +68 -0
- package/es/HeatmapChart/index.mjs +162 -0
- package/es/HeatmapChart/index.mjs.map +1 -0
- package/es/HeatmapChart/styles.d.mts +4 -0
- package/es/HeatmapChart/styles.mjs +24 -0
- package/es/HeatmapChart/styles.mjs.map +1 -0
- package/es/HeatmapChart/utils.d.mts +18 -0
- package/es/HeatmapChart/utils.mjs +40 -0
- package/es/HeatmapChart/utils.mjs.map +1 -0
- package/es/Heatmaps/Calendar.d.mts +2 -5
- package/es/Heatmaps/Calendar.mjs +8 -9
- package/es/Heatmaps/Calendar.mjs.map +1 -1
- package/es/Heatmaps/ChartLabels.d.mts +2 -5
- package/es/Heatmaps/ChartLabels.mjs +3 -4
- package/es/Heatmaps/ChartLabels.mjs.map +1 -1
- package/es/Heatmaps/Footer.d.mts +1 -4
- package/es/Heatmaps/Footer.mjs +3 -4
- package/es/Heatmaps/index.d.mts +10 -8
- package/es/Heatmaps/index.mjs +10 -11
- package/es/Heatmaps/index.mjs.map +1 -1
- package/es/Heatmaps/styles.d.mts +1 -4
- package/es/Heatmaps/styles.mjs +2 -3
- package/es/Heatmaps/styles.mjs.map +1 -1
- package/es/Legend/LegendItem.d.mts +1 -4
- package/es/Legend/LegendItem.mjs +7 -8
- package/es/Legend/LegendItem.mjs.map +1 -1
- package/es/Legend/ScrollButton.d.mts +1 -4
- package/es/Legend/ScrollButton.mjs +6 -7
- package/es/Legend/ScrollButton.mjs.map +1 -1
- package/es/Legend/index.d.mts +7 -5
- package/es/Legend/index.mjs +13 -18
- package/es/Legend/index.mjs.map +1 -1
- package/es/LineChart/index.d.mts +11 -7
- package/es/LineChart/index.mjs +91 -53
- package/es/LineChart/index.mjs.map +1 -1
- package/es/LineChart/styles.d.mts +1 -4
- package/es/LineChart/styles.mjs +1 -2
- package/es/RadarChart/A2uiRadarChart.d.mts +37 -0
- package/es/RadarChart/A2uiRadarChart.mjs +203 -0
- package/es/RadarChart/A2uiRadarChart.mjs.map +1 -0
- package/es/RadarChart/index.d.mts +11 -7
- package/es/RadarChart/index.mjs +51 -18
- package/es/RadarChart/index.mjs.map +1 -1
- package/es/RadarChart/styles.d.mts +1 -4
- package/es/RadarChart/styles.mjs +1 -2
- package/es/SankeyChart/index.d.mts +73 -0
- package/es/SankeyChart/index.mjs +156 -0
- package/es/SankeyChart/index.mjs.map +1 -0
- package/es/SankeyChart/utils.d.mts +54 -0
- package/es/SankeyChart/utils.mjs +270 -0
- package/es/SankeyChart/utils.mjs.map +1 -0
- package/es/ScatterChart/A2uiScatterChart.d.mts +41 -0
- package/es/ScatterChart/A2uiScatterChart.mjs +259 -0
- package/es/ScatterChart/A2uiScatterChart.mjs.map +1 -0
- package/es/ScatterChart/ScatterChartTooltip.d.mts +2 -5
- package/es/ScatterChart/ScatterChartTooltip.mjs +7 -8
- package/es/ScatterChart/ScatterChartTooltip.mjs.map +1 -1
- package/es/ScatterChart/ScatterChartTooltipRow.d.mts +1 -4
- package/es/ScatterChart/ScatterChartTooltipRow.mjs +3 -4
- package/es/ScatterChart/ScatterChartTooltipRow.mjs.map +1 -1
- package/es/ScatterChart/index.d.mts +15 -9
- package/es/ScatterChart/index.mjs +70 -33
- package/es/ScatterChart/index.mjs.map +1 -1
- package/es/ScatterChart/renderShape.d.mts +1 -4
- package/es/ScatterChart/renderShape.mjs +4 -5
- package/es/ScatterChart/renderShape.mjs.map +1 -1
- package/es/ScatterChart/styles.d.mts +1 -4
- package/es/ScatterChart/styles.mjs +1 -2
- package/es/SparkChart/A2uiSparkChart.d.mts +41 -0
- package/es/SparkChart/A2uiSparkChart.mjs +179 -0
- package/es/SparkChart/A2uiSparkChart.mjs.map +1 -0
- package/es/SparkChart/SparkAreaChart.d.mts +12 -7
- package/es/SparkChart/SparkAreaChart.mjs +47 -22
- package/es/SparkChart/SparkAreaChart.mjs.map +1 -1
- package/es/SparkChart/SparkBarChart.d.mts +11 -6
- package/es/SparkChart/SparkBarChart.mjs +39 -16
- package/es/SparkChart/SparkBarChart.mjs.map +1 -1
- package/es/SparkChart/SparkLineChart.d.mts +12 -7
- package/es/SparkChart/SparkLineChart.mjs +41 -16
- package/es/SparkChart/SparkLineChart.mjs.map +1 -1
- package/es/SparkChart/index.d.mts +2 -1
- package/es/Tracker/TrackerBlock.d.mts +5 -5
- package/es/Tracker/TrackerBlock.mjs +8 -9
- package/es/Tracker/TrackerBlock.mjs.map +1 -1
- package/es/Tracker/index.d.mts +8 -6
- package/es/Tracker/index.mjs +11 -13
- package/es/Tracker/index.mjs.map +1 -1
- package/es/Tracker/styles.d.mts +1 -4
- package/es/Tracker/styles.mjs +1 -2
- package/es/TreemapChart/index.d.mts +64 -0
- package/es/TreemapChart/index.mjs +140 -0
- package/es/TreemapChart/index.mjs.map +1 -0
- package/es/TreemapChart/utils.d.mts +23 -0
- package/es/TreemapChart/utils.mjs +175 -0
- package/es/TreemapChart/utils.mjs.map +1 -0
- package/es/common/BaseAnimationTimingProps.d.mts +1 -4
- package/es/common/BaseChartProps.d.mts +3 -6
- package/es/common/BaseSparkChartProps.d.mts +2 -5
- package/es/common/ChartLegend.d.mts +1 -4
- package/es/common/ChartLegend.mjs +4 -5
- package/es/common/ChartLegend.mjs.map +1 -1
- package/es/common/ChartTooltip/ChartTooltipFrame.d.mts +1 -4
- package/es/common/ChartTooltip/ChartTooltipFrame.mjs +1 -2
- package/es/common/ChartTooltip/ChartTooltipFrame.mjs.map +1 -1
- package/es/common/ChartTooltip/ChartTooltipRow.d.mts +1 -4
- package/es/common/ChartTooltip/ChartTooltipRow.mjs +5 -6
- package/es/common/ChartTooltip/ChartTooltipRow.mjs.map +1 -1
- package/es/common/ChartTooltip/index.d.mts +2 -5
- package/es/common/ChartTooltip/index.mjs +3 -4
- package/es/common/ChartTooltip/index.mjs.map +1 -1
- package/es/common/CustomTooltipProps.d.mts +3 -6
- package/es/common/CustomYAxisTick.d.mts +2 -5
- package/es/common/CustomYAxisTick.mjs +1 -2
- package/es/common/CustomYAxisTick.mjs.map +1 -1
- package/es/common/NoData.d.mts +1 -4
- package/es/common/NoData.mjs +2 -3
- package/es/common/NoData.mjs.map +1 -1
- package/es/common/a2ui/A2uiTrendChart.d.mts +43 -0
- package/es/common/a2ui/A2uiTrendChart.mjs +353 -0
- package/es/common/a2ui/A2uiTrendChart.mjs.map +1 -0
- package/es/common/a2ui/Frame.d.mts +20 -0
- package/es/common/a2ui/Frame.mjs +43 -0
- package/es/common/a2ui/Frame.mjs.map +1 -0
- package/es/common/a2ui/HoverTooltip.d.mts +28 -0
- package/es/common/a2ui/HoverTooltip.mjs +36 -0
- package/es/common/a2ui/HoverTooltip.mjs.map +1 -0
- package/es/common/a2ui/Legend.d.mts +11 -0
- package/es/common/a2ui/Legend.mjs +33 -0
- package/es/common/a2ui/Legend.mjs.map +1 -0
- package/es/common/a2ui/PlacedTooltip.d.mts +22 -0
- package/es/common/a2ui/PlacedTooltip.mjs +58 -0
- package/es/common/a2ui/PlacedTooltip.mjs.map +1 -0
- package/es/common/a2ui/Tooltip.d.mts +13 -0
- package/es/common/a2ui/Tooltip.mjs +33 -0
- package/es/common/a2ui/Tooltip.mjs.map +1 -0
- package/es/common/a2ui/axis.d.mts +38 -0
- package/es/common/a2ui/axis.mjs +48 -0
- package/es/common/a2ui/axis.mjs.map +1 -0
- package/es/common/a2ui/curve.d.mts +20 -0
- package/es/common/a2ui/curve.mjs +58 -0
- package/es/common/a2ui/curve.mjs.map +1 -0
- package/es/common/a2ui/format.d.mts +17 -0
- package/es/common/a2ui/format.mjs +56 -0
- package/es/common/a2ui/format.mjs.map +1 -0
- package/es/common/a2ui/index.d.mts +16 -0
- package/es/common/a2ui/index.mjs +15 -0
- package/es/common/a2ui/scale.d.mts +20 -0
- package/es/common/a2ui/scale.mjs +112 -0
- package/es/common/a2ui/scale.mjs.map +1 -0
- package/es/common/a2ui/styles.d.mts +35 -0
- package/es/common/a2ui/styles.mjs +254 -0
- package/es/common/a2ui/styles.mjs.map +1 -0
- package/es/common/a2ui/tokens.d.mts +20 -0
- package/es/common/a2ui/tokens.mjs +103 -0
- package/es/common/a2ui/tokens.mjs.map +1 -0
- package/es/common/a2ui/types.d.mts +25 -0
- package/es/common/a2ui/types.mjs +0 -0
- package/es/common/a2ui/useA2uiTheme.d.mts +2 -0
- package/es/common/a2ui/useA2uiTheme.mjs +11 -0
- package/es/common/a2ui/useA2uiTheme.mjs.map +1 -0
- package/es/common/a2ui/useElementWidth.d.mts +2 -0
- package/es/common/a2ui/useElementWidth.mjs +31 -0
- package/es/common/a2ui/useElementWidth.mjs.map +1 -0
- package/es/common/benchmark/types.d.mts +2 -5
- package/es/common/benchmark/utils.d.mts +1 -4
- package/es/common/benchmark/utils.mjs +1 -2
- package/es/common/utils.d.mts +1 -4
- package/es/common/utils.mjs +1 -2
- package/es/hooks/useOnWindowResize.d.mts +1 -4
- package/es/hooks/useOnWindowResize.mjs +2 -3
- package/es/hooks/usePrefersReducedMotion.d.mts +1 -4
- package/es/hooks/usePrefersReducedMotion.mjs +2 -3
- package/es/hooks/useThemeColorRange.d.mts +1 -4
- package/es/hooks/useThemeColorRange.mjs +1 -2
- package/es/index.d.mts +20 -9
- package/es/index.mjs +15 -9
- package/es/types/charts.d.mts +1 -4
- package/es/types/charts.mjs +1 -2
- package/es/utils/calendar.d.mts +2 -5
- package/es/utils/calendar.mjs +2 -3
- package/es/utils/getMaxLabelLength.d.mts +1 -4
- package/es/utils/getMaxLabelLength.mjs +1 -2
- package/es/utils/getMaxLabelLength.mjs.map +1 -1
- package/es/utils/index.d.mts +1 -4
- package/es/utils/index.mjs +1 -2
- package/es/utils/index.mjs.map +1 -1
- package/es/utils/theme.d.mts +1 -4
- package/es/utils/theme.mjs +1 -2
- package/package.json +32 -8
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// src/TreemapChart/utils.ts
|
|
2
|
+
const PHI = (1 + Math.sqrt(5)) / 2;
|
|
3
|
+
const dice = (parent, x0, y0, x1, y1) => {
|
|
4
|
+
const nodes = parent.children;
|
|
5
|
+
const k = parent.value && (x1 - x0) / parent.value;
|
|
6
|
+
for (const node of nodes) {
|
|
7
|
+
node.y0 = y0;
|
|
8
|
+
node.y1 = y1;
|
|
9
|
+
node.x0 = x0;
|
|
10
|
+
node.x1 = x0 += node.value * k;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const slice = (parent, x0, y0, x1, y1) => {
|
|
14
|
+
const nodes = parent.children;
|
|
15
|
+
const k = parent.value && (y1 - y0) / parent.value;
|
|
16
|
+
for (const node of nodes) {
|
|
17
|
+
node.x0 = x0;
|
|
18
|
+
node.x1 = x1;
|
|
19
|
+
node.y0 = y0;
|
|
20
|
+
node.y1 = y0 += node.value * k;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const squarify = (parent, x0, y0, x1, y1, ratio = PHI) => {
|
|
24
|
+
const nodes = parent.children;
|
|
25
|
+
const n = nodes.length;
|
|
26
|
+
let i0 = 0;
|
|
27
|
+
let i1 = 0;
|
|
28
|
+
let value = parent.value;
|
|
29
|
+
while (i0 < n) {
|
|
30
|
+
const dx = x1 - x0;
|
|
31
|
+
const dy = y1 - y0;
|
|
32
|
+
let sumValue;
|
|
33
|
+
do
|
|
34
|
+
sumValue = nodes[i1++].value;
|
|
35
|
+
while (!sumValue && i1 < n);
|
|
36
|
+
let minValue = sumValue;
|
|
37
|
+
let maxValue = sumValue;
|
|
38
|
+
const alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
|
|
39
|
+
let beta = sumValue * sumValue * alpha;
|
|
40
|
+
let minRatio = Math.max(maxValue / beta, beta / minValue);
|
|
41
|
+
for (; i1 < n; ++i1) {
|
|
42
|
+
const nodeValue = nodes[i1].value;
|
|
43
|
+
sumValue += nodeValue;
|
|
44
|
+
if (nodeValue < minValue) minValue = nodeValue;
|
|
45
|
+
if (nodeValue > maxValue) maxValue = nodeValue;
|
|
46
|
+
beta = sumValue * sumValue * alpha;
|
|
47
|
+
const newRatio = Math.max(maxValue / beta, beta / minValue);
|
|
48
|
+
if (newRatio > minRatio) {
|
|
49
|
+
sumValue -= nodeValue;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
minRatio = newRatio;
|
|
53
|
+
}
|
|
54
|
+
const row = {
|
|
55
|
+
children: nodes.slice(i0, i1),
|
|
56
|
+
depth: 0,
|
|
57
|
+
value: sumValue,
|
|
58
|
+
x0,
|
|
59
|
+
x1,
|
|
60
|
+
y0,
|
|
61
|
+
y1
|
|
62
|
+
};
|
|
63
|
+
if (dx < dy) dice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
|
|
64
|
+
else slice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
|
|
65
|
+
value -= sumValue;
|
|
66
|
+
i0 = i1;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Lays out leaves (optionally grouped one level deep) in a `width` x `height` box. Children are sorted by
|
|
71
|
+
* value, largest first, at every level. Returns the leaf cells and the colour keys in input order.
|
|
72
|
+
*/
|
|
73
|
+
const layoutTreemap = (leaves, width, height, { paddingInner = 3, paddingOuter = 1.5 } = {}) => {
|
|
74
|
+
const merged = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const leaf of leaves) {
|
|
76
|
+
if (!(leaf.value > 0)) continue;
|
|
77
|
+
const key = `${leaf.group}\u0000${leaf.name}`;
|
|
78
|
+
const prev = merged.get(key);
|
|
79
|
+
merged.set(key, prev ? {
|
|
80
|
+
...prev,
|
|
81
|
+
value: prev.value + leaf.value
|
|
82
|
+
} : { ...leaf });
|
|
83
|
+
}
|
|
84
|
+
const root = {
|
|
85
|
+
children: [],
|
|
86
|
+
depth: 0,
|
|
87
|
+
value: 0,
|
|
88
|
+
x0: 0,
|
|
89
|
+
x1: width,
|
|
90
|
+
y0: 0,
|
|
91
|
+
y1: height
|
|
92
|
+
};
|
|
93
|
+
const groups = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const leaf of merged.values()) {
|
|
95
|
+
const node = {
|
|
96
|
+
depth: 0,
|
|
97
|
+
leaf,
|
|
98
|
+
value: leaf.value,
|
|
99
|
+
x0: 0,
|
|
100
|
+
x1: 0,
|
|
101
|
+
y0: 0,
|
|
102
|
+
y1: 0
|
|
103
|
+
};
|
|
104
|
+
if (leaf.group) {
|
|
105
|
+
let group = groups.get(leaf.group);
|
|
106
|
+
if (!group) {
|
|
107
|
+
group = {
|
|
108
|
+
children: [],
|
|
109
|
+
depth: 1,
|
|
110
|
+
value: 0,
|
|
111
|
+
x0: 0,
|
|
112
|
+
x1: 0,
|
|
113
|
+
y0: 0,
|
|
114
|
+
y1: 0
|
|
115
|
+
};
|
|
116
|
+
groups.set(leaf.group, group);
|
|
117
|
+
root.children.push(group);
|
|
118
|
+
}
|
|
119
|
+
node.depth = 2;
|
|
120
|
+
group.children.push(node);
|
|
121
|
+
} else {
|
|
122
|
+
node.depth = 1;
|
|
123
|
+
root.children.push(node);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const sum = (node) => {
|
|
127
|
+
if (node.children) {
|
|
128
|
+
node.value = node.children.reduce((s, c) => s + sum(c), 0);
|
|
129
|
+
node.children.sort((a, b) => b.value - a.value);
|
|
130
|
+
}
|
|
131
|
+
return node.value;
|
|
132
|
+
};
|
|
133
|
+
sum(root);
|
|
134
|
+
const paddingStack = [0];
|
|
135
|
+
const cells = [];
|
|
136
|
+
const position = (node) => {
|
|
137
|
+
let p = paddingStack[node.depth];
|
|
138
|
+
let x0 = node.x0 + p;
|
|
139
|
+
let y0 = node.y0 + p;
|
|
140
|
+
let x1 = node.x1 - p;
|
|
141
|
+
let y1 = node.y1 - p;
|
|
142
|
+
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
143
|
+
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
144
|
+
node.x0 = x0;
|
|
145
|
+
node.y0 = y0;
|
|
146
|
+
node.x1 = x1;
|
|
147
|
+
node.y1 = y1;
|
|
148
|
+
if (node.children && node.children.length > 0) {
|
|
149
|
+
p = paddingStack[node.depth + 1] = paddingInner / 2;
|
|
150
|
+
x0 += paddingOuter - p;
|
|
151
|
+
y0 += paddingOuter - p;
|
|
152
|
+
x1 -= paddingOuter - p;
|
|
153
|
+
y1 -= paddingOuter - p;
|
|
154
|
+
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
155
|
+
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
156
|
+
squarify(node, x0, y0, x1, y1);
|
|
157
|
+
for (const child of node.children) position(child);
|
|
158
|
+
} else if (node.leaf) cells.push({
|
|
159
|
+
...node.leaf,
|
|
160
|
+
x0: node.x0,
|
|
161
|
+
x1: node.x1,
|
|
162
|
+
y0: node.y0,
|
|
163
|
+
y1: node.y1
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
if (root.value > 0) position(root);
|
|
167
|
+
return {
|
|
168
|
+
cells,
|
|
169
|
+
keys: Array.from(new Set([...merged.values()].map((l) => l.group || l.name))),
|
|
170
|
+
total: root.value
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export { layoutTreemap };
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/TreemapChart/utils.ts"],"sourcesContent":["// Treemap layout: squarified tiling with inner / outer padding.\n// Ported from d3-hierarchy 3.1.2 `treemap` and `treemapSquarify` (ISC License, Copyright 2010-2021 Mike Bostock),\n// as used by the official A2UI Treemap (CopilotKit a2ui-playground, MIT).\n\nexport interface TreemapLeafInput {\n group: string;\n name: string;\n value: number;\n}\n\nexport interface TreemapCell extends TreemapLeafInput {\n x0: number;\n x1: number;\n y0: number;\n y1: number;\n}\n\ninterface Node {\n children?: Node[];\n depth: number;\n leaf?: TreemapLeafInput;\n value: number;\n x0: number;\n x1: number;\n y0: number;\n y1: number;\n}\n\nconst PHI = (1 + Math.sqrt(5)) / 2;\n\nconst dice = (parent: Node, x0: number, y0: number, x1: number, y1: number) => {\n const nodes = parent.children!;\n const k = parent.value && (x1 - x0) / parent.value;\n for (const node of nodes) {\n node.y0 = y0;\n node.y1 = y1;\n node.x0 = x0;\n node.x1 = x0 += node.value * k;\n }\n};\n\nconst slice = (parent: Node, x0: number, y0: number, x1: number, y1: number) => {\n const nodes = parent.children!;\n const k = parent.value && (y1 - y0) / parent.value;\n for (const node of nodes) {\n node.x0 = x0;\n node.x1 = x1;\n node.y0 = y0;\n node.y1 = y0 += node.value * k;\n }\n};\n\nconst squarify = (parent: Node, x0: number, y0: number, x1: number, y1: number, ratio = PHI) => {\n const nodes = parent.children!;\n const n = nodes.length;\n let i0 = 0;\n let i1 = 0;\n let value = parent.value;\n while (i0 < n) {\n const dx = x1 - x0;\n const dy = y1 - y0;\n let sumValue: number;\n do sumValue = nodes[i1++].value;\n while (!sumValue && i1 < n);\n let minValue = sumValue;\n let maxValue = sumValue;\n const alpha = Math.max(dy / dx, dx / dy) / (value * ratio);\n let beta = sumValue * sumValue * alpha;\n let minRatio = Math.max(maxValue / beta, beta / minValue);\n for (; i1 < n; ++i1) {\n const nodeValue = nodes[i1].value;\n sumValue += nodeValue;\n if (nodeValue < minValue) minValue = nodeValue;\n if (nodeValue > maxValue) maxValue = nodeValue;\n beta = sumValue * sumValue * alpha;\n const newRatio = Math.max(maxValue / beta, beta / minValue);\n if (newRatio > minRatio) {\n sumValue -= nodeValue;\n break;\n }\n minRatio = newRatio;\n }\n const row: Node = { children: nodes.slice(i0, i1), depth: 0, value: sumValue, x0, x1, y0, y1 };\n if (dx < dy) dice(row, x0, y0, x1, value ? (y0 += (dy * sumValue) / value) : y1);\n else slice(row, x0, y0, value ? (x0 += (dx * sumValue) / value) : x1, y1);\n value -= sumValue;\n i0 = i1;\n }\n};\n\n/**\n * Lays out leaves (optionally grouped one level deep) in a `width` x `height` box. Children are sorted by\n * value, largest first, at every level. Returns the leaf cells and the colour keys in input order.\n */\nexport const layoutTreemap = (\n leaves: TreemapLeafInput[],\n width: number,\n height: number,\n { paddingInner = 3, paddingOuter = 1.5 } = {},\n) => {\n // Merge duplicates (same group + name) and build root -> group -> leaf.\n const merged = new Map<string, TreemapLeafInput>();\n for (const leaf of leaves) {\n if (!(leaf.value > 0)) continue;\n const key = `${leaf.group}\\u0000${leaf.name}`;\n const prev = merged.get(key);\n merged.set(key, prev ? { ...prev, value: prev.value + leaf.value } : { ...leaf });\n }\n const root: Node = { children: [], depth: 0, value: 0, x0: 0, x1: width, y0: 0, y1: height };\n const groups = new Map<string, Node>();\n for (const leaf of merged.values()) {\n const node: Node = { depth: 0, leaf, value: leaf.value, x0: 0, x1: 0, y0: 0, y1: 0 };\n if (leaf.group) {\n let group = groups.get(leaf.group);\n if (!group) {\n group = { children: [], depth: 1, value: 0, x0: 0, x1: 0, y0: 0, y1: 0 };\n groups.set(leaf.group, group);\n root.children!.push(group);\n }\n node.depth = 2;\n group.children!.push(node);\n } else {\n node.depth = 1;\n root.children!.push(node);\n }\n }\n // Sum and sort, largest first (stable for ties).\n const sum = (node: Node): number => {\n if (node.children) {\n node.value = node.children.reduce((s, c) => s + sum(c), 0);\n node.children.sort((a, b) => b.value - a.value);\n }\n return node.value;\n };\n sum(root);\n\n const paddingStack = [0];\n const cells: TreemapCell[] = [];\n const position = (node: Node) => {\n let p = paddingStack[node.depth];\n let x0 = node.x0 + p;\n let y0 = node.y0 + p;\n let x1 = node.x1 - p;\n let y1 = node.y1 - p;\n if (x1 < x0) x0 = x1 = (x0 + x1) / 2;\n if (y1 < y0) y0 = y1 = (y0 + y1) / 2;\n node.x0 = x0;\n node.y0 = y0;\n node.x1 = x1;\n node.y1 = y1;\n if (node.children && node.children.length > 0) {\n p = paddingStack[node.depth + 1] = paddingInner / 2;\n x0 += paddingOuter - p;\n y0 += paddingOuter - p;\n x1 -= paddingOuter - p;\n y1 -= paddingOuter - p;\n if (x1 < x0) x0 = x1 = (x0 + x1) / 2;\n if (y1 < y0) y0 = y1 = (y0 + y1) / 2;\n squarify(node, x0, y0, x1, y1);\n for (const child of node.children) position(child);\n } else if (node.leaf) {\n cells.push({ ...node.leaf, x0: node.x0, x1: node.x1, y0: node.y0, y1: node.y1 });\n }\n };\n if (root.value > 0) position(root);\n\n // Colour keys (group, or the leaf's own name when ungrouped) in the order they first appear.\n const keys = Array.from(new Set([...merged.values()].map((l) => l.group || l.name)));\n return { cells, keys, total: root.value };\n};\n"],"mappings":"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"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
//#region src/common/BaseAnimationTimingProps.d.ts
|
|
2
1
|
interface BaseAnimationTimingProps {
|
|
3
2
|
animationDuration?: number;
|
|
4
3
|
height?: string | number;
|
|
5
4
|
showAnimation?: boolean;
|
|
6
5
|
width?: string | number;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
|
-
export { BaseAnimationTimingProps as default };
|
|
10
|
-
//# sourceMappingURL=BaseAnimationTimingProps.d.mts.map
|
|
7
|
+
export { BaseAnimationTimingProps as default };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { ComponentType, HTMLAttributes } from "react";
|
|
2
|
+
import { AxisDomain } from "recharts/types/util/types";
|
|
1
3
|
import { NoDataProps } from "./NoData.mjs";
|
|
2
4
|
import { IntervalType, LabelFormatter, ValueFormatter } from "../types/charts.mjs";
|
|
3
5
|
import BaseAnimationTimingProps from "./BaseAnimationTimingProps.mjs";
|
|
4
6
|
import { CustomTooltipProps } from "./CustomTooltipProps.mjs";
|
|
5
|
-
import { ComponentType, HTMLAttributes } from "react";
|
|
6
|
-
import { AxisDomain } from "recharts/types/util/types";
|
|
7
|
-
//#region src/common/BaseChartProps.d.ts
|
|
8
7
|
type FixedProps = {
|
|
9
8
|
categoryClicked: string;
|
|
10
9
|
eventType: 'dot' | 'category' | 'bar' | 'slice' | 'bubble';
|
|
@@ -56,6 +55,4 @@ interface BaseChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDi
|
|
|
56
55
|
yAxisLabel?: string;
|
|
57
56
|
yAxisWidth?: number;
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
export { BaseChartProps as default };
|
|
61
|
-
//# sourceMappingURL=BaseChartProps.d.mts.map
|
|
58
|
+
export { BaseChartProps as default };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
1
2
|
import { NoDataProps } from "./NoData.mjs";
|
|
2
3
|
import BaseAnimationTimingProps from "./BaseAnimationTimingProps.mjs";
|
|
3
|
-
import { HTMLAttributes } from "react";
|
|
4
|
-
//#region src/common/BaseSparkChartProps.d.ts
|
|
5
4
|
interface BaseSparkChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {
|
|
6
5
|
autoMinValue?: boolean;
|
|
7
6
|
categories: string[];
|
|
@@ -12,6 +11,4 @@ interface BaseSparkChartProps extends BaseAnimationTimingProps, HTMLAttributes<H
|
|
|
12
11
|
minValue?: number;
|
|
13
12
|
noDataText?: NoDataProps['noDataText'];
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
export { BaseSparkChartProps as default };
|
|
17
|
-
//# sourceMappingURL=BaseSparkChartProps.d.mts.map
|
|
14
|
+
export { BaseSparkChartProps as default };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from "react";
|
|
2
|
-
//#region src/common/ChartLegend.d.ts
|
|
3
2
|
declare const ChartLegend: ({ payload }: any, categoryColors: Map<string, string>, setLegendHeight: Dispatch<SetStateAction<number>>, activeLegend: string | undefined, onClick?: (category: string, color: string) => void, enableLegendSlider?: boolean, customCategories?: {
|
|
4
3
|
[key: string]: string;
|
|
5
4
|
}) => import("react").JSX.Element;
|
|
6
|
-
|
|
7
|
-
export { ChartLegend as default };
|
|
8
|
-
//# sourceMappingURL=ChartLegend.d.mts.map
|
|
5
|
+
export { ChartLegend as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Legend from "../Legend/index.mjs";
|
|
2
|
-
import { useOnWindowResize } from "../hooks/useOnWindowResize.mjs";
|
|
3
1
|
import { Flexbox } from "@lobehub/ui";
|
|
4
2
|
import { useRef } from "react";
|
|
3
|
+
import { useOnWindowResize } from "../hooks/useOnWindowResize.mjs";
|
|
4
|
+
import Legend from "../Legend/index.mjs";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/common/ChartLegend.tsx
|
|
7
7
|
const calculateHeight = (height) => height ? Number(height) + 20 : 60;
|
|
8
8
|
const ChartLegend = ({ payload }, categoryColors, setLegendHeight, activeLegend, onClick, enableLegendSlider, customCategories) => {
|
|
9
9
|
const legendRef = useRef(null);
|
|
@@ -12,8 +12,8 @@ const ChartLegend = ({ payload }, categoryColors, setLegendHeight, activeLegend,
|
|
|
12
12
|
});
|
|
13
13
|
const filteredPayload = payload.filter((item) => item.type !== "none");
|
|
14
14
|
return /* @__PURE__ */ jsx(Flexbox, {
|
|
15
|
-
align: "center",
|
|
16
15
|
horizontal: true,
|
|
16
|
+
align: "center",
|
|
17
17
|
justify: "flex-end",
|
|
18
18
|
ref: legendRef,
|
|
19
19
|
children: /* @__PURE__ */ jsx(Legend, {
|
|
@@ -26,7 +26,6 @@ const ChartLegend = ({ payload }, categoryColors, setLegendHeight, activeLegend,
|
|
|
26
26
|
})
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
-
//#endregion
|
|
30
29
|
export { ChartLegend as default };
|
|
31
30
|
|
|
32
31
|
//# sourceMappingURL=ChartLegend.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegend.mjs","names":[],"sources":["../../src/common/ChartLegend.tsx"],"sourcesContent":["import { Flexbox } from '@lobehub/ui';\nimport { Dispatch, SetStateAction
|
|
1
|
+
{"version":3,"file":"ChartLegend.mjs","names":[],"sources":["../../src/common/ChartLegend.tsx"],"sourcesContent":["import { Flexbox } from '@lobehub/ui';\nimport type { Dispatch, SetStateAction } from 'react';\nimport { useRef } from 'react';\n\nimport { useOnWindowResize } from '@/hooks/useOnWindowResize';\nimport Legend from '@/Legend';\n\nconst calculateHeight = (height: number | undefined) =>\n height\n ? Number(height) + 20 // 20px extra padding\n : 60; // default height\n\nconst ChartLegend = (\n { payload }: any,\n categoryColors: Map<string, string>,\n setLegendHeight: Dispatch<SetStateAction<number>>,\n activeLegend: string | undefined,\n onClick?: (category: string, color: string) => void,\n enableLegendSlider?: boolean,\n customCategories?: {\n [key: string]: string;\n },\n) => {\n const legendRef = useRef<HTMLDivElement>(null);\n\n useOnWindowResize(() => {\n setLegendHeight(calculateHeight(legendRef.current?.clientHeight));\n });\n\n const filteredPayload = payload.filter((item: any) => item.type !== 'none');\n\n return (\n <Flexbox horizontal align={'center'} justify={'flex-end'} ref={legendRef}>\n <Legend\n activeLegend={activeLegend}\n categories={filteredPayload.map((entry: any) => entry.value)}\n colors={filteredPayload.map((entry: any) => categoryColors.get(entry.value))}\n customCategories={customCategories}\n enableLegendSlider={enableLegendSlider}\n onClickLegendItem={onClick}\n />\n </Flexbox>\n );\n};\n\nexport default ChartLegend;\n"],"mappings":";;;;;;AAOA,MAAM,mBAAmB,WACvB,SACI,OAAO,MAAM,IAAI,KACjB;AAEN,MAAM,eACJ,EAAE,WACF,gBACA,iBACA,cACA,SACA,oBACA,qBAGG;CACH,MAAM,YAAY,OAAuB,IAAI;CAE7C,wBAAwB;EACtB,gBAAgB,gBAAgB,UAAU,SAAS,YAAY,CAAC;CAClE,CAAC;CAED,MAAM,kBAAkB,QAAQ,QAAQ,SAAc,KAAK,SAAS,MAAM;CAE1E,OACE,oBAAC,SAAD;EAAS,YAAA;EAAW,OAAO;EAAU,SAAS;EAAY,KAAK;EAC7D,UAAA,oBAAC,QAAD;GACgB;GACd,YAAY,gBAAgB,KAAK,UAAe,MAAM,KAAK;GAC3D,QAAQ,gBAAgB,KAAK,UAAe,eAAe,IAAI,MAAM,KAAK,CAAC;GACzD;GACE;GACpB,mBAAmB;EACpB,CAAA;CACM,CAAA;AAEb"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
//#region src/common/ChartTooltip/ChartTooltipFrame.d.ts
|
|
2
1
|
export declare const styles: {
|
|
3
2
|
container: string;
|
|
4
3
|
};
|
|
5
4
|
export declare const ChartTooltipFrame: import("react").NamedExoticComponent<import("@lobehub/ui").FlexBasicProps>;
|
|
6
|
-
|
|
7
|
-
export { ChartTooltipFrame as default };
|
|
8
|
-
//# sourceMappingURL=ChartTooltipFrame.d.mts.map
|
|
5
|
+
export { ChartTooltipFrame as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flexbox, createStaticStyles } from "@lobehub/ui";
|
|
2
2
|
import { memo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/common/ChartTooltip/ChartTooltipFrame.tsx
|
|
5
5
|
const styles = createStaticStyles(({ css, cssVar }) => ({ container: css`
|
|
6
6
|
overflow: hidden;
|
|
7
7
|
|
|
@@ -20,7 +20,6 @@ const ChartTooltipFrame = memo(({ children, ...rest }) => {
|
|
|
20
20
|
children
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
|
-
//#endregion
|
|
24
23
|
export { ChartTooltipFrame, ChartTooltipFrame as default, styles };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=ChartTooltipFrame.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartTooltipFrame.mjs","names":[],"sources":["../../../src/common/ChartTooltip/ChartTooltipFrame.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ChartTooltipFrame.mjs","names":[],"sources":["../../../src/common/ChartTooltip/ChartTooltipFrame.tsx"],"sourcesContent":["import type { FlexboxProps } from '@lobehub/ui';\nimport { createStaticStyles, Flexbox } from '@lobehub/ui';\nimport { memo } from 'react';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n container: css`\n overflow: hidden;\n\n width: max-content;\n min-width: 160px;\n border: 1px solid ${cssVar.colorBorderSecondary};\n border-radius: ${cssVar.borderRadiusLG};\n\n background: ${cssVar.colorBgElevated};\n box-shadow: ${cssVar.boxShadow};\n `,\n}));\n\nexport const ChartTooltipFrame = memo<FlexboxProps>(({ children, ...rest }) => {\n return (\n <Flexbox className={styles.container} {...rest}>\n {children}\n </Flexbox>\n );\n});\n\nexport default ChartTooltipFrame;\n"],"mappings":";;;;AAIA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc,EAC7D,WAAW,GAAG;;;;;wBAKQ,OAAO,qBAAqB;qBAC/B,OAAO,eAAe;;kBAEzB,OAAO,gBAAgB;kBACvB,OAAO,UAAU;IAEnC,EAAE;AAEF,MAAa,oBAAoB,MAAoB,EAAE,UAAU,GAAG,WAAW;CAC7E,OACE,oBAAC,SAAD;EAAS,WAAW,OAAO;EAAW,GAAI;EACvC;CACM,CAAA;AAEb,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
//#region src/common/ChartTooltip/ChartTooltipRow.d.ts
|
|
2
1
|
export interface ChartTooltipRowProps {
|
|
3
2
|
color: string;
|
|
4
3
|
name: string;
|
|
5
4
|
value: string;
|
|
6
5
|
}
|
|
7
6
|
declare const ChartTooltipRow: import("react").NamedExoticComponent<ChartTooltipRowProps>;
|
|
8
|
-
|
|
9
|
-
export { ChartTooltipRow as default };
|
|
10
|
-
//# sourceMappingURL=ChartTooltipRow.d.mts.map
|
|
7
|
+
export { ChartTooltipRow as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Flexbox, Icon, Text, createStaticStyles } from "@lobehub/ui";
|
|
2
|
-
import { memo } from "react";
|
|
3
2
|
import { Circle } from "lucide-react";
|
|
3
|
+
import { memo } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/common/ChartTooltip/ChartTooltipRow.tsx
|
|
6
6
|
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
7
7
|
number: css`
|
|
8
8
|
flex-shrink: 0;
|
|
@@ -15,15 +15,15 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
|
15
15
|
}));
|
|
16
16
|
const ChartTooltipRow = memo(({ value, name, color }) => {
|
|
17
17
|
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
18
|
+
horizontal: true,
|
|
18
19
|
align: "center",
|
|
19
20
|
gap: 32,
|
|
20
|
-
horizontal: true,
|
|
21
21
|
justify: "space-between",
|
|
22
22
|
width: "max-content",
|
|
23
23
|
children: [/* @__PURE__ */ jsxs(Flexbox, {
|
|
24
|
+
horizontal: true,
|
|
24
25
|
align: "center",
|
|
25
26
|
gap: 8,
|
|
26
|
-
horizontal: true,
|
|
27
27
|
width: "auto",
|
|
28
28
|
children: [/* @__PURE__ */ jsx(Icon, {
|
|
29
29
|
color,
|
|
@@ -31,8 +31,8 @@ const ChartTooltipRow = memo(({ value, name, color }) => {
|
|
|
31
31
|
icon: Circle,
|
|
32
32
|
size: 10
|
|
33
33
|
}), /* @__PURE__ */ jsx(Text, {
|
|
34
|
-
className: styles.title,
|
|
35
34
|
ellipsis: true,
|
|
35
|
+
className: styles.title,
|
|
36
36
|
style: { margin: 0 },
|
|
37
37
|
children: name
|
|
38
38
|
})]
|
|
@@ -43,7 +43,6 @@ const ChartTooltipRow = memo(({ value, name, color }) => {
|
|
|
43
43
|
})]
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
-
//#endregion
|
|
47
46
|
export { ChartTooltipRow as default };
|
|
48
47
|
|
|
49
48
|
//# sourceMappingURL=ChartTooltipRow.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartTooltipRow.mjs","names":[],"sources":["../../../src/common/ChartTooltip/ChartTooltipRow.tsx"],"sourcesContent":["import { Flexbox, Icon, Text
|
|
1
|
+
{"version":3,"file":"ChartTooltipRow.mjs","names":[],"sources":["../../../src/common/ChartTooltip/ChartTooltipRow.tsx"],"sourcesContent":["import { createStaticStyles, Flexbox, Icon, Text } from '@lobehub/ui';\nimport { Circle } from 'lucide-react';\nimport { memo } from 'react';\n\nconst styles = createStaticStyles(({ css, cssVar }) => ({\n number: css`\n flex-shrink: 0;\n font-weight: 500;\n white-space: nowrap;\n `,\n title: css`\n color: ${cssVar.colorTextSecondary};\n `,\n}));\nexport interface ChartTooltipRowProps {\n color: string;\n name: string;\n value: string;\n}\n\nconst ChartTooltipRow = memo<ChartTooltipRowProps>(({ value, name, color }) => {\n return (\n <Flexbox horizontal align={'center'} gap={32} justify={'space-between'} width={'max-content'}>\n <Flexbox horizontal align={'center'} gap={8} width={'auto'}>\n <Icon color={color} fill={color} icon={Circle} size={10} />\n <Text ellipsis className={styles.title} style={{ margin: 0 }}>\n {name}\n </Text>\n </Flexbox>\n <Text className={styles.number} style={{ margin: 0 }}>\n {value}\n </Text>\n </Flexbox>\n );\n});\n\nexport default ChartTooltipRow;\n"],"mappings":";;;;;AAIA,MAAM,SAAS,oBAAoB,EAAE,KAAK,cAAc;CACtD,QAAQ,GAAG;;;;;CAKX,OAAO,GAAG;aACC,OAAO,mBAAmB;;AAEvC,EAAE;AAOF,MAAM,kBAAkB,MAA4B,EAAE,OAAO,MAAM,YAAY;CAC7E,OACE,qBAAC,SAAD;EAAS,YAAA;EAAW,OAAO;EAAU,KAAK;EAAI,SAAS;EAAiB,OAAO;EAA/E,UAAA,CACE,qBAAC,SAAD;GAAS,YAAA;GAAW,OAAO;GAAU,KAAK;GAAG,OAAO;GAApD,UAAA,CACE,oBAAC,MAAD;IAAa;IAAO,MAAM;IAAO,MAAM;IAAQ,MAAM;GAAK,CAAA,GAC1D,oBAAC,MAAD;IAAM,UAAA;IAAS,WAAW,OAAO;IAAO,OAAO,EAAE,QAAQ,EAAE;IACxD,UAAA;GACG,CAAA,CACC;EACT,CAAA,GAAA,oBAAC,MAAD;GAAM,WAAW,OAAO;GAAQ,OAAO,EAAE,QAAQ,EAAE;GAChD,UAAA;EACG,CAAA,CACC;;AAEb,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ValueFormatter } from "../../types/charts.mjs";
|
|
2
1
|
import { ReactNode } from "react";
|
|
3
|
-
|
|
2
|
+
import { ValueFormatter } from "../../types/charts.mjs";
|
|
4
3
|
export interface ChartTooltipProps {
|
|
5
4
|
active: boolean | undefined;
|
|
6
5
|
categoryColors: Map<string, string>;
|
|
@@ -13,6 +12,4 @@ export interface ChartTooltipProps {
|
|
|
13
12
|
valueFormatter: ValueFormatter | ((value: number, name?: string) => string);
|
|
14
13
|
}
|
|
15
14
|
declare const ChartTooltip: ({ active, payload, label, categoryColors, valueFormatter, customCategories, footer }: ChartTooltipProps) => import("react").JSX.Element | null;
|
|
16
|
-
|
|
17
|
-
export { ChartTooltip as default };
|
|
18
|
-
//# sourceMappingURL=index.d.mts.map
|
|
15
|
+
export { ChartTooltip as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Flexbox, Text, createStaticStyles, cssVar, cx } from "@lobehub/ui";
|
|
1
2
|
import { ChartTooltipFrame } from "./ChartTooltipFrame.mjs";
|
|
2
3
|
import ChartTooltipRow from "./ChartTooltipRow.mjs";
|
|
3
|
-
import { Flexbox, Text, createStaticStyles, cssVar, cx } from "@lobehub/ui";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/common/ChartTooltip/index.tsx
|
|
6
6
|
const styles = createStaticStyles(({ css, cssVar }) => ({ header: css`
|
|
7
|
-
border-
|
|
7
|
+
border-block-end: 1px solid ${cssVar.colorBorderSecondary};
|
|
8
8
|
font-weight: 500;
|
|
9
9
|
` }));
|
|
10
10
|
const ChartTooltip = ({ active, payload, label, categoryColors, valueFormatter, customCategories, footer }) => {
|
|
@@ -42,7 +42,6 @@ const ChartTooltip = ({ active, payload, label, categoryColors, valueFormatter,
|
|
|
42
42
|
}
|
|
43
43
|
return null;
|
|
44
44
|
};
|
|
45
|
-
//#endregion
|
|
46
45
|
export { ChartTooltip as default };
|
|
47
46
|
|
|
48
47
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/common/ChartTooltip/index.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/common/ChartTooltip/index.tsx"],"sourcesContent":["import { createStaticStyles, cssVar, cx, Flexbox, Text } from '@lobehub/ui';\nimport type { ReactNode } from 'react';\n\nimport type { ValueFormatter } from '@/types/charts';\n\nimport ChartTooltipFrame from './ChartTooltipFrame';\nimport ChartTooltipRow from './ChartTooltipRow';\n\nconst styles = createStaticStyles(({ css, cssVar }) => ({\n header: css`\n border-block-end: 1px solid ${cssVar.colorBorderSecondary};\n font-weight: 500;\n `,\n}));\n\nexport interface ChartTooltipProps {\n active: boolean | undefined;\n categoryColors: Map<string, string>;\n customCategories?: {\n [key: string]: string;\n };\n footer?: ReactNode;\n label: string;\n payload: any;\n valueFormatter: ValueFormatter | ((value: number, name?: string) => string);\n}\n\nconst ChartTooltip = ({\n active,\n payload,\n label,\n categoryColors,\n valueFormatter,\n customCategories,\n footer,\n}: ChartTooltipProps) => {\n if (active && payload) {\n const filteredPayload = payload.filter((item: any) => item.type !== 'none');\n\n return (\n <ChartTooltipFrame>\n <Flexbox className={cx(styles.header)} paddingBlock={8} paddingInline={16} width={'auto'}>\n <Text ellipsis style={{ margin: 0 }}>\n {label}\n </Text>\n </Flexbox>\n <Flexbox\n gap={4}\n paddingBlock={8}\n paddingInline={16}\n style={{ flexDirection: 'column-reverse', marginTop: 4 }}\n width={'auto'}\n >\n {filteredPayload.map(({ value, name }: { name: string; value: number }, idx: number) => (\n <ChartTooltipRow\n color={categoryColors.get(name) ?? cssVar.colorPrimary}\n key={`id-${idx}`}\n name={customCategories?.[name] || name}\n value={valueFormatter(value, name)}\n />\n ))}\n </Flexbox>\n {footer}\n </ChartTooltipFrame>\n );\n }\n return null;\n};\n\nexport default ChartTooltip;\n"],"mappings":";;;;;AAQA,MAAM,SAAS,oBAAoB,EAAE,KAAK,cAAc,EACtD,QAAQ,GAAG;kCACqB,OAAO,qBAAqB;;IAG9D,EAAE;AAcF,MAAM,gBAAgB,EACpB,QACA,SACA,OACA,gBACA,gBACA,kBACA,aACuB;CACvB,IAAI,UAAU,SAAS;EACrB,MAAM,kBAAkB,QAAQ,QAAQ,SAAc,KAAK,SAAS,MAAM;EAE1E,OACE,qBAAC,mBAAD,EAAA,UAAA;GACE,oBAAC,SAAD;IAAS,WAAW,GAAG,OAAO,MAAM;IAAG,cAAc;IAAG,eAAe;IAAI,OAAO;IAChF,UAAA,oBAAC,MAAD;KAAM,UAAA;KAAS,OAAO,EAAE,QAAQ,EAAE;KAC/B,UAAA;IACG,CAAA;GACC,CAAA;GACT,oBAAC,SAAD;IACE,KAAK;IACL,cAAc;IACd,eAAe;IACf,OAAO;KAAE,eAAe;KAAkB,WAAW;IAAE;IACvD,OAAO;IAEN,UAAA,gBAAgB,KAAK,EAAE,OAAO,QAAyC,QACtE,oBAAC,iBAAD;KACE,OAAO,eAAe,IAAI,IAAI,KAAK,OAAO;KAE1C,MAAM,mBAAmB,SAAS;KAClC,OAAO,eAAe,OAAO,IAAI;IAClC,GAHM,MAAM,KAGZ,CACF;GACM,CAAA;GACR;EACgB,EAAA,CAAA;CAEvB;CACA,OAAO;AACT"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ValueFormatter } from "../types/charts.mjs";
|
|
2
|
-
import { ScatterChartValueFormatter } from "../ScatterChart/index.mjs";
|
|
3
1
|
import { NameType, Payload } from "recharts/types/component/DefaultTooltipContent";
|
|
4
|
-
|
|
2
|
+
import { ScatterChartValueFormatter } from "../ScatterChart/index.mjs";
|
|
3
|
+
import { ValueFormatter } from "../types/charts.mjs";
|
|
5
4
|
export type CustomTooltipProps = {
|
|
6
5
|
active: boolean | undefined;
|
|
7
6
|
customCategories?: {
|
|
@@ -10,6 +9,4 @@ export type CustomTooltipProps = {
|
|
|
10
9
|
label: NameType | undefined;
|
|
11
10
|
payload: Payload<string | number | (string | number)[], string | number>[] | undefined;
|
|
12
11
|
valueFormatter: ValueFormatter | ScatterChartValueFormatter;
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
//# sourceMappingURL=CustomTooltipProps.d.mts.map
|
|
12
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ValueFormatter } from "../types/charts.mjs";
|
|
2
1
|
import React from "react";
|
|
3
|
-
|
|
2
|
+
import { ValueFormatter } from "../types/charts.mjs";
|
|
4
3
|
interface CustomYAxisTickProps {
|
|
5
4
|
align: 'left' | 'right';
|
|
6
5
|
anchor?: 'end' | 'middle' | 'start';
|
|
@@ -13,6 +12,4 @@ interface CustomYAxisTickProps {
|
|
|
13
12
|
yAxisLabel?: boolean;
|
|
14
13
|
}
|
|
15
14
|
declare const CustomYAxisTick: React.NamedExoticComponent<CustomYAxisTickProps>;
|
|
16
|
-
|
|
17
|
-
export { CustomYAxisTick as default };
|
|
18
|
-
//# sourceMappingURL=CustomYAxisTick.d.mts.map
|
|
15
|
+
export { CustomYAxisTick as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cssVar } from "@lobehub/ui";
|
|
2
2
|
import { memo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/common/CustomYAxisTick.tsx
|
|
5
5
|
const CustomYAxisTick = memo(({ yAxisLabel, x, y, payload, align, formatter, anchor }) => {
|
|
6
6
|
const yAxisLabelWidth = yAxisLabel ? 24 : 0;
|
|
7
7
|
const resolvedTextAnchor = anchor ?? (align === "left" ? "start" : "end");
|
|
@@ -18,7 +18,6 @@ const CustomYAxisTick = memo(({ yAxisLabel, x, y, payload, align, formatter, anc
|
|
|
18
18
|
})
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
|
-
//#endregion
|
|
22
21
|
export { CustomYAxisTick as default };
|
|
23
22
|
|
|
24
23
|
//# sourceMappingURL=CustomYAxisTick.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomYAxisTick.mjs","names":[],"sources":["../../src/common/CustomYAxisTick.tsx"],"sourcesContent":["import { cssVar } from '@lobehub/ui';\nimport React, { memo } from 'react';\n\nimport { ValueFormatter } from '@/types/charts';\n\ninterface CustomYAxisTickProps {\n align: 'left' | 'right';\n anchor?: 'end' | 'middle' | 'start';\n formatter: ValueFormatter;\n\n payload: {\n value: number;\n };\n\n x: number;\n y: number;\n yAxisLabel?: boolean;\n}\n\nconst CustomYAxisTick = memo<CustomYAxisTickProps>(\n ({ yAxisLabel, x, y, payload, align, formatter, anchor }) => {\n const yAxisLabelWidth = yAxisLabel ? 24 : 0;\n const resolvedTextAnchor = anchor ?? (align === 'left' ? 'start' : 'end');\n\n return (\n <g transform={`translate(${align === 'left' ? yAxisLabelWidth : x + yAxisLabelWidth},${y})`}>\n <text\n dy={4}\n fill={cssVar.colorTextDescription}\n fontSize={12}\n textAnchor={resolvedTextAnchor}\n x={0}\n y={0}\n >\n {formatter(payload.value)}\n </text>\n </g>\n );\n },\n);\n\nexport default CustomYAxisTick;\n"],"mappings":";;;;AAmBA,MAAM,kBAAkB,MACrB,EAAE,YAAY,GAAG,GAAG,SAAS,OAAO,WAAW,aAAa;CAC3D,MAAM,kBAAkB,aAAa,KAAK;CAC1C,MAAM,qBAAqB,WAAW,UAAU,SAAS,UAAU;CAEnE,OACE,oBAAC,KAAD;EAAG,WAAW,aAAa,UAAU,SAAS,kBAAkB,IAAI,gBAAgB,GAAG,EAAE;EACvF,UAAA,oBAAC,QAAD;GACE,IAAI;GACJ,MAAM,OAAO;GACb,UAAU;GACV,YAAY;GACZ,GAAG;GACH,GAAG;GAEF,UAAA,UAAU,QAAQ,KAAK;EACpB,CAAA;CACL,CAAA;AAEP,CACF"}
|
|
1
|
+
{"version":3,"file":"CustomYAxisTick.mjs","names":[],"sources":["../../src/common/CustomYAxisTick.tsx"],"sourcesContent":["import { cssVar } from '@lobehub/ui';\nimport React, { memo } from 'react';\n\nimport type { ValueFormatter } from '@/types/charts';\n\ninterface CustomYAxisTickProps {\n align: 'left' | 'right';\n anchor?: 'end' | 'middle' | 'start';\n formatter: ValueFormatter;\n\n payload: {\n value: number;\n };\n\n x: number;\n y: number;\n yAxisLabel?: boolean;\n}\n\nconst CustomYAxisTick = memo<CustomYAxisTickProps>(\n ({ yAxisLabel, x, y, payload, align, formatter, anchor }) => {\n const yAxisLabelWidth = yAxisLabel ? 24 : 0;\n const resolvedTextAnchor = anchor ?? (align === 'left' ? 'start' : 'end');\n\n return (\n <g transform={`translate(${align === 'left' ? yAxisLabelWidth : x + yAxisLabelWidth},${y})`}>\n <text\n dy={4}\n fill={cssVar.colorTextDescription}\n fontSize={12}\n textAnchor={resolvedTextAnchor}\n x={0}\n y={0}\n >\n {formatter(payload.value)}\n </text>\n </g>\n );\n },\n);\n\nexport default CustomYAxisTick;\n"],"mappings":";;;;AAmBA,MAAM,kBAAkB,MACrB,EAAE,YAAY,GAAG,GAAG,SAAS,OAAO,WAAW,aAAa;CAC3D,MAAM,kBAAkB,aAAa,KAAK;CAC1C,MAAM,qBAAqB,WAAW,UAAU,SAAS,UAAU;CAEnE,OACE,oBAAC,KAAD;EAAG,WAAW,aAAa,UAAU,SAAS,kBAAkB,IAAI,gBAAgB,GAAG,EAAE;EACvF,UAAA,oBAAC,QAAD;GACE,IAAI;GACJ,MAAM,OAAO;GACb,UAAU;GACV,YAAY;GACZ,GAAG;GACH,GAAG;GAEF,UAAA,UAAU,QAAQ,KAAK;EACpB,CAAA;CACL,CAAA;AAEP,CACF"}
|
package/es/common/NoData.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
//#region src/common/NoData.d.ts
|
|
3
2
|
export interface NoDataProps {
|
|
4
3
|
className?: string;
|
|
5
4
|
noDataText?: ReactNode | {
|
|
@@ -8,6 +7,4 @@ export interface NoDataProps {
|
|
|
8
7
|
};
|
|
9
8
|
}
|
|
10
9
|
declare const NoData: import("react").NamedExoticComponent<NoDataProps>;
|
|
11
|
-
|
|
12
|
-
export { NoData as default };
|
|
13
|
-
//# sourceMappingURL=NoData.d.mts.map
|
|
10
|
+
export { NoData as default };
|
package/es/common/NoData.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Center, Empty } from "@lobehub/ui";
|
|
2
|
-
import { isValidElement, memo } from "react";
|
|
3
2
|
import { Inbox } from "lucide-react";
|
|
3
|
+
import { isValidElement, memo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/common/NoData.tsx
|
|
6
6
|
const NoData = memo(({ noDataText = {
|
|
7
7
|
desc: "There's no data available for your selection.",
|
|
8
8
|
title: "No Data"
|
|
@@ -19,7 +19,6 @@ const NoData = memo(({ noDataText = {
|
|
|
19
19
|
})
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
-
//#endregion
|
|
23
22
|
export { NoData as default };
|
|
24
23
|
|
|
25
24
|
//# sourceMappingURL=NoData.mjs.map
|
package/es/common/NoData.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoData.mjs","names":[],"sources":["../../src/common/NoData.tsx"],"sourcesContent":["import { Center, Empty } from '@lobehub/ui';\nimport { Inbox } from 'lucide-react';\nimport { ReactNode
|
|
1
|
+
{"version":3,"file":"NoData.mjs","names":[],"sources":["../../src/common/NoData.tsx"],"sourcesContent":["import { Center, Empty } from '@lobehub/ui';\nimport { Inbox } from 'lucide-react';\nimport type { ReactNode } from 'react';\nimport { isValidElement, memo } from 'react';\n\nexport interface NoDataProps {\n className?: string;\n noDataText?:\n | ReactNode\n | {\n desc: ReactNode;\n title: ReactNode;\n };\n}\n\nconst NoData = memo<NoDataProps>(\n ({\n noDataText = {\n desc: \"There's no data available for your selection.\",\n title: 'No Data',\n },\n className,\n }) => {\n const isReactNodeText = isValidElement(noDataText);\n return (\n <Center height={'100%'} width={'100%'}>\n <Empty\n className={className}\n description={isReactNodeText ? noDataText : (noDataText as any)?.desc}\n icon={Inbox}\n title={isReactNodeText ? undefined : (noDataText as any)?.title}\n />\n </Center>\n );\n },\n);\n\nexport default NoData;\n"],"mappings":";;;;;AAeA,MAAM,SAAS,MACZ,EACC,aAAa;CACX,MAAM;CACN,OAAO;AACT,GACA,gBACI;CACJ,MAAM,kBAAkB,eAAe,UAAU;CACjD,OACE,oBAAC,QAAD;EAAQ,QAAQ;EAAQ,OAAO;EAC7B,UAAA,oBAAC,OAAD;GACa;GACX,aAAa,kBAAkB,aAAc,YAAoB;GACjE,MAAM;GACN,OAAO,kBAAkB,KAAA,IAAa,YAAoB;EAC3D,CAAA;CACK,CAAA;AAEZ,CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode, Ref } from "react";
|
|
2
|
+
import { EventProps } from "../BaseChartProps.mjs";
|
|
3
|
+
import { CurveType, ValueFormatter } from "../../types/charts.mjs";
|
|
4
|
+
import { ChartNumberFormat } from "./format.mjs";
|
|
5
|
+
export interface A2uiTrendChartProps {
|
|
6
|
+
categories: string[];
|
|
7
|
+
className?: string;
|
|
8
|
+
colors?: string[];
|
|
9
|
+
connectNulls?: boolean;
|
|
10
|
+
currency?: string;
|
|
11
|
+
curveType?: CurveType;
|
|
12
|
+
customCategories?: Record<string, string>;
|
|
13
|
+
data: any[];
|
|
14
|
+
format?: ChartNumberFormat;
|
|
15
|
+
height?: number | string;
|
|
16
|
+
index: string;
|
|
17
|
+
kind: 'line' | 'area';
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
maxValue?: number;
|
|
20
|
+
minValue?: number;
|
|
21
|
+
noDataText?: ReactNode;
|
|
22
|
+
onValueChange?: (value: EventProps) => void;
|
|
23
|
+
ref?: Ref<HTMLElement>;
|
|
24
|
+
showAnimation?: boolean;
|
|
25
|
+
showGradient?: boolean;
|
|
26
|
+
showGridLines?: boolean;
|
|
27
|
+
showLegend?: boolean;
|
|
28
|
+
showTooltip?: boolean;
|
|
29
|
+
showXAxis?: boolean;
|
|
30
|
+
showYAxis?: boolean;
|
|
31
|
+
stack?: boolean;
|
|
32
|
+
style?: CSSProperties;
|
|
33
|
+
subtitle?: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
unit?: string;
|
|
36
|
+
valueFormatter?: ValueFormatter;
|
|
37
|
+
xAxisLabelFormatter?: (v: any) => string;
|
|
38
|
+
}
|
|
39
|
+
declare const A2uiTrendChart: {
|
|
40
|
+
({ kind, data, index, categories, colors, stack, connectNulls, curveType, format, currency, unit, valueFormatter, xAxisLabelFormatter, title, subtitle, height, loading, noDataText, showAnimation, showGradient, showGridLines, showLegend, showTooltip, showXAxis, showYAxis, minValue, maxValue, customCategories, onValueChange, className, style, ref }: A2uiTrendChartProps): import("react").JSX.Element;
|
|
41
|
+
displayName: string;
|
|
42
|
+
};
|
|
43
|
+
export { A2uiTrendChart as default };
|