@hitachivantara/uikit-react-viz 6.1.5 → 6.1.7
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/dist/BarChart/BarChart.js +86 -112
- package/dist/BaseChart/BaseChart.js +53 -51
- package/dist/Boxplot/Boxplot.js +68 -83
- package/dist/Boxplot/Boxplot.styles.js +22 -23
- package/dist/Boxplot/useBoxplot.js +56 -70
- package/dist/Boxplot/useBoxplotData.js +34 -37
- package/dist/ConfusionMatrix/ConfusionMatrix.js +151 -150
- package/dist/ConfusionMatrix/ConfusionMatrix.styles.js +23 -27
- package/dist/ConfusionMatrix/utils.js +105 -138
- package/dist/DonutChart/DonutChart.js +67 -85
- package/dist/Heatmap/Heatmap.js +81 -97
- package/dist/Heatmap/Heatmap.styles.js +22 -23
- package/dist/LineChart/LineChart.js +84 -110
- package/dist/ScatterPlot/ScatterPlot.js +80 -102
- package/dist/Treemap/Treemap.js +36 -50
- package/dist/hooks/tooltip/styles.js +76 -77
- package/dist/hooks/tooltip/useTooltip.js +66 -89
- package/dist/hooks/useData.js +122 -162
- package/dist/hooks/useDataZoom.js +17 -25
- package/dist/hooks/useDataset.js +10 -14
- package/dist/hooks/useGrid.js +21 -37
- package/dist/hooks/useLegend.js +35 -44
- package/dist/hooks/useOption.js +12 -18
- package/dist/hooks/useSeries.js +84 -117
- package/dist/hooks/useVisualMap.js +38 -55
- package/dist/hooks/useXAxis.js +42 -61
- package/dist/hooks/useYAxis.js +31 -55
- package/dist/index.js +2 -16
- package/dist/providers/Provider.js +41 -21
- package/dist/utils/index.js +120 -186
- package/dist/utils/registerTheme.js +84 -122
- package/package.json +4 -4
|
@@ -1,120 +1,94 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { BarChart } from "echarts/charts";
|
|
4
|
-
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent, DataZoomSliderComponent, DataZoomInsideComponent, MarkLineComponent } from "echarts/components";
|
|
5
|
-
import * as echarts from "echarts/core";
|
|
6
|
-
import { useData } from "../hooks/useData.js";
|
|
7
|
-
import { useDataset } from "../hooks/useDataset.js";
|
|
8
|
-
import { useYAxis } from "../hooks/useYAxis.js";
|
|
9
|
-
import { useXAxis } from "../hooks/useXAxis.js";
|
|
1
|
+
import { HvBaseChart } from "../BaseChart/BaseChart.js";
|
|
10
2
|
import { useDataZoom } from "../hooks/useDataZoom.js";
|
|
3
|
+
import { useXAxis } from "../hooks/useXAxis.js";
|
|
4
|
+
import { useYAxis } from "../hooks/useYAxis.js";
|
|
11
5
|
import { useGrid } from "../hooks/useGrid.js";
|
|
6
|
+
import { useData } from "../hooks/useData.js";
|
|
7
|
+
import { useDataset } from "../hooks/useDataset.js";
|
|
12
8
|
import { useSeries } from "../hooks/useSeries.js";
|
|
13
9
|
import { useLegend } from "../hooks/useLegend.js";
|
|
14
10
|
import { useTooltip } from "../hooks/tooltip/useTooltip.js";
|
|
15
11
|
import { useOption } from "../hooks/useOption.js";
|
|
16
|
-
import {
|
|
12
|
+
import { forwardRef } from "react";
|
|
13
|
+
import { DataZoomInsideComponent, DataZoomSliderComponent, DatasetComponent, GridComponent, LegendComponent, MarkLineComponent, TooltipComponent } from "echarts/components";
|
|
14
|
+
import * as echarts from "echarts/core";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
import { BarChart } from "echarts/charts";
|
|
17
|
+
//#region src/BarChart/BarChart.tsx
|
|
17
18
|
echarts.use([
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
BarChart,
|
|
20
|
+
DatasetComponent,
|
|
21
|
+
GridComponent,
|
|
22
|
+
TooltipComponent,
|
|
23
|
+
LegendComponent,
|
|
24
|
+
DataZoomSliderComponent,
|
|
25
|
+
DataZoomInsideComponent,
|
|
26
|
+
MarkLineComponent
|
|
26
27
|
]);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
option: {
|
|
95
|
-
...chartYAxis,
|
|
96
|
-
...chartXAxis,
|
|
97
|
-
...chartSlider,
|
|
98
|
-
...chartGrid,
|
|
99
|
-
...chartDataset,
|
|
100
|
-
...chartSeries,
|
|
101
|
-
...chartLegend,
|
|
102
|
-
...chartTooltip
|
|
103
|
-
},
|
|
104
|
-
onOptionChange
|
|
105
|
-
});
|
|
106
|
-
return /* @__PURE__ */ jsx(
|
|
107
|
-
HvBaseChart,
|
|
108
|
-
{
|
|
109
|
-
ref,
|
|
110
|
-
option,
|
|
111
|
-
width,
|
|
112
|
-
height,
|
|
113
|
-
...others
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
export {
|
|
119
|
-
HvBarChart
|
|
120
|
-
};
|
|
28
|
+
/**
|
|
29
|
+
* A bar chart is a chart or graph that presents categorical data with rectangular bars.
|
|
30
|
+
*/
|
|
31
|
+
var HvBarChart = forwardRef(function HvBarChart(props, ref) {
|
|
32
|
+
const { yAxis, xAxis, horizontal = false, horizontalRangeSlider, grid, data, groupBy, splitBy, sortBy, filters, stack, seriesNameFormatter, measures, legend, tooltip, classes, height, width, onOptionChange, ...others } = props;
|
|
33
|
+
const { data: chartData, mapping: measuresMapping } = useData({
|
|
34
|
+
data,
|
|
35
|
+
groupBy,
|
|
36
|
+
sortBy,
|
|
37
|
+
splitBy,
|
|
38
|
+
measures,
|
|
39
|
+
filters
|
|
40
|
+
});
|
|
41
|
+
const chartDataset = useDataset(chartData);
|
|
42
|
+
const chartYAxis = useYAxis({
|
|
43
|
+
axes: Array.isArray(yAxis) || yAxis == null ? yAxis : [yAxis],
|
|
44
|
+
defaultType: horizontal ? "categorical" : "continuous"
|
|
45
|
+
});
|
|
46
|
+
const chartXAxis = useXAxis({
|
|
47
|
+
type: horizontal ? "continuous" : "categorical",
|
|
48
|
+
...xAxis
|
|
49
|
+
});
|
|
50
|
+
const chartSlider = useDataZoom({ showHorizontal: horizontalRangeSlider?.show });
|
|
51
|
+
const chartGrid = useGrid({ ...grid });
|
|
52
|
+
const chartSeries = useSeries({
|
|
53
|
+
type: "bar",
|
|
54
|
+
data: chartData,
|
|
55
|
+
groupBy,
|
|
56
|
+
measuresMapping,
|
|
57
|
+
stack,
|
|
58
|
+
nameFormatter: seriesNameFormatter,
|
|
59
|
+
horizontal
|
|
60
|
+
});
|
|
61
|
+
const chartLegend = useLegend({
|
|
62
|
+
...legend,
|
|
63
|
+
series: chartSeries.series,
|
|
64
|
+
icon: "square"
|
|
65
|
+
});
|
|
66
|
+
const chartTooltip = useTooltip({
|
|
67
|
+
...tooltip,
|
|
68
|
+
trigger: "axis",
|
|
69
|
+
measuresMapping,
|
|
70
|
+
classes,
|
|
71
|
+
horizontal
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */ jsx(HvBaseChart, {
|
|
74
|
+
ref,
|
|
75
|
+
option: useOption({
|
|
76
|
+
option: {
|
|
77
|
+
...chartYAxis,
|
|
78
|
+
...chartXAxis,
|
|
79
|
+
...chartSlider,
|
|
80
|
+
...chartGrid,
|
|
81
|
+
...chartDataset,
|
|
82
|
+
...chartSeries,
|
|
83
|
+
...chartLegend,
|
|
84
|
+
...chartTooltip
|
|
85
|
+
},
|
|
86
|
+
onOptionChange
|
|
87
|
+
}),
|
|
88
|
+
width,
|
|
89
|
+
height,
|
|
90
|
+
...others
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
//#endregion
|
|
94
|
+
export { HvBarChart };
|
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef, useRef, useState
|
|
1
|
+
import { useVizTheme } from "../providers/Provider.js";
|
|
2
|
+
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { useForkRef } from "@mui/material/utils";
|
|
4
4
|
import ReactECharts from "echarts-for-react";
|
|
5
5
|
import { AriaComponent } from "echarts/components";
|
|
6
6
|
import * as echarts from "echarts/core";
|
|
7
7
|
import { CanvasRenderer } from "echarts/renderers";
|
|
8
|
-
import {
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/BaseChart/BaseChart.tsx
|
|
9
10
|
echarts.use([CanvasRenderer, AriaComponent]);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Base chart.
|
|
13
|
+
*/
|
|
14
|
+
var HvBaseChart = forwardRef(function HvBaseChart(props, ref) {
|
|
15
|
+
const { option, width, height, onEvents, ...others } = props;
|
|
16
|
+
const { theme, activeTheme } = useVizTheme();
|
|
17
|
+
const currentTheme = useRef(theme);
|
|
18
|
+
const chartRef = useRef(null);
|
|
19
|
+
const forkedRef = useForkRef(ref, chartRef);
|
|
20
|
+
const [initialOption, setInitialOption] = useState(option);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const instance = chartRef.current?.getEchartsInstance();
|
|
23
|
+
if (!instance) return;
|
|
24
|
+
return () => {
|
|
25
|
+
instance.dispose();
|
|
26
|
+
};
|
|
27
|
+
}, [activeTheme]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (theme !== currentTheme.current) {
|
|
30
|
+
setInitialOption(option);
|
|
31
|
+
currentTheme.current = theme;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const instance = chartRef.current?.getEchartsInstance();
|
|
35
|
+
if (!instance) return;
|
|
36
|
+
instance.setOption(option, { replaceMerge: [
|
|
37
|
+
"xAxis",
|
|
38
|
+
"yAxis",
|
|
39
|
+
"series",
|
|
40
|
+
"dataset",
|
|
41
|
+
"dataZoom"
|
|
42
|
+
] });
|
|
43
|
+
}, [theme, option]);
|
|
44
|
+
return /* @__PURE__ */ jsx(ReactECharts, {
|
|
45
|
+
ref: forkedRef,
|
|
46
|
+
echarts,
|
|
47
|
+
option: initialOption,
|
|
48
|
+
theme,
|
|
49
|
+
notMerge: true,
|
|
50
|
+
style: {
|
|
51
|
+
width: width ?? "100%",
|
|
52
|
+
height: height ?? "100%"
|
|
53
|
+
},
|
|
54
|
+
onEvents,
|
|
55
|
+
...others
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//#endregion
|
|
59
|
+
export { HvBaseChart };
|
package/dist/Boxplot/Boxplot.js
CHANGED
|
@@ -1,47 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { BoxplotChart } from "echarts/charts";
|
|
4
|
-
import { TooltipComponent, VisualMapComponent } from "echarts/components";
|
|
5
|
-
import * as echarts from "echarts/core";
|
|
6
|
-
import { useClasses } from "./Boxplot.styles.js";
|
|
7
|
-
import { useBoxplot } from "./useBoxplot.js";
|
|
8
|
-
import { useTooltip } from "../hooks/tooltip/useTooltip.js";
|
|
9
|
-
import { useGrid } from "../hooks/useGrid.js";
|
|
10
|
-
import { useLegend } from "../hooks/useLegend.js";
|
|
1
|
+
import { HvBaseChart } from "../BaseChart/BaseChart.js";
|
|
11
2
|
import { useXAxis } from "../hooks/useXAxis.js";
|
|
12
3
|
import { useYAxis } from "../hooks/useYAxis.js";
|
|
4
|
+
import { useGrid } from "../hooks/useGrid.js";
|
|
5
|
+
import { useLegend } from "../hooks/useLegend.js";
|
|
6
|
+
import { useTooltip } from "../hooks/tooltip/useTooltip.js";
|
|
13
7
|
import { useOption } from "../hooks/useOption.js";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const q1 = params?.value?.[2];
|
|
43
|
-
const lower = params?.value?.[1];
|
|
44
|
-
return `
|
|
8
|
+
import { useClasses } from "./Boxplot.styles.js";
|
|
9
|
+
import { useBoxplot } from "./useBoxplot.js";
|
|
10
|
+
import { forwardRef } from "react";
|
|
11
|
+
import { TooltipComponent, VisualMapComponent } from "echarts/components";
|
|
12
|
+
import * as echarts from "echarts/core";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
import { BoxplotChart } from "echarts/charts";
|
|
15
|
+
//#region src/Boxplot/Boxplot.tsx
|
|
16
|
+
echarts.use([
|
|
17
|
+
BoxplotChart,
|
|
18
|
+
TooltipComponent,
|
|
19
|
+
VisualMapComponent
|
|
20
|
+
]);
|
|
21
|
+
/**
|
|
22
|
+
* A Boxplot chart visually summarizes the distribution of a dataset by depicting key statistical measures such as the median, quartiles, and outliers.
|
|
23
|
+
*/
|
|
24
|
+
var HvBoxplot = forwardRef(function HvBoxplot(props, ref) {
|
|
25
|
+
const { name, data, xAxis, yAxis, grid, legend, measures, groupBy, tooltip, width, height, filters, classes: classesProp, onOptionChange, ...others } = props;
|
|
26
|
+
const { classes } = useClasses(classesProp);
|
|
27
|
+
const chartTooltip = useTooltip({
|
|
28
|
+
component: (params) => {
|
|
29
|
+
const title = params?.title;
|
|
30
|
+
const upper = params?.value?.[5];
|
|
31
|
+
const q3 = params?.value?.[4];
|
|
32
|
+
const median = params?.value?.[3];
|
|
33
|
+
const q1 = params?.value?.[2];
|
|
34
|
+
const lower = params?.value?.[1];
|
|
35
|
+
return `
|
|
45
36
|
<div class="${classes.tooltipRoot}">
|
|
46
37
|
<div class="${classes.tooltipContainer}">
|
|
47
38
|
<div>
|
|
@@ -54,45 +45,39 @@ const HvBoxplot = forwardRef(
|
|
|
54
45
|
</div>
|
|
55
46
|
</div>
|
|
56
47
|
</div>`;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
export {
|
|
97
|
-
HvBoxplot
|
|
98
|
-
};
|
|
48
|
+
},
|
|
49
|
+
...tooltip
|
|
50
|
+
});
|
|
51
|
+
const chartGrid = useGrid({ ...grid });
|
|
52
|
+
const chartLegend = useLegend({
|
|
53
|
+
...legend,
|
|
54
|
+
icon: "square"
|
|
55
|
+
});
|
|
56
|
+
const chartXAxis = useXAxis({ ...xAxis });
|
|
57
|
+
const chartYAxis = useYAxis({
|
|
58
|
+
axes: Array.isArray(yAxis) || yAxis == null ? yAxis : [yAxis],
|
|
59
|
+
defaultType: "continuous",
|
|
60
|
+
...yAxis
|
|
61
|
+
});
|
|
62
|
+
return /* @__PURE__ */ jsx(HvBaseChart, {
|
|
63
|
+
ref,
|
|
64
|
+
option: useOption({ option: {
|
|
65
|
+
...useBoxplot({
|
|
66
|
+
data,
|
|
67
|
+
groupBy,
|
|
68
|
+
measures,
|
|
69
|
+
filters
|
|
70
|
+
}),
|
|
71
|
+
...chartGrid,
|
|
72
|
+
...chartLegend,
|
|
73
|
+
...chartTooltip,
|
|
74
|
+
...chartXAxis,
|
|
75
|
+
...chartYAxis
|
|
76
|
+
} }),
|
|
77
|
+
width,
|
|
78
|
+
height,
|
|
79
|
+
...others
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
//#endregion
|
|
83
|
+
export { HvBoxplot };
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import { createClasses } from "@hitachivantara/uikit-react-utils";
|
|
2
2
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
//#region src/Boxplot/Boxplot.styles.tsx
|
|
4
|
+
var { useClasses, staticClasses } = createClasses("HvBoxplot", {
|
|
5
|
+
tooltipRoot: {
|
|
6
|
+
backgroundColor: theme.colors.bgContainer,
|
|
7
|
+
width: "fit-content",
|
|
8
|
+
minWidth: 150,
|
|
9
|
+
boxShadow: theme.colors.shadow,
|
|
10
|
+
zIndex: theme.zIndices.sticky
|
|
11
|
+
},
|
|
12
|
+
tooltipContainer: {
|
|
13
|
+
padding: theme.spacing("15px", "sm"),
|
|
14
|
+
display: "flex",
|
|
15
|
+
flexDirection: "column"
|
|
16
|
+
},
|
|
17
|
+
tooltipText: {
|
|
18
|
+
fontFamily: theme.fontFamily.body,
|
|
19
|
+
fontWeight: theme.fontWeights.normal,
|
|
20
|
+
fontSize: theme.fontSizes.sm,
|
|
21
|
+
color: theme.colors.text
|
|
22
|
+
}
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
useClasses
|
|
26
|
-
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { useClasses };
|
|
@@ -1,72 +1,58 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
1
|
import { useBoxplotData } from "./useBoxplotData.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
type: "boxplot",
|
|
58
|
-
datasetIndex: Object.keys(measuresFields).length + index,
|
|
59
|
-
yAxisId: measuresFields[m]
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
const datasets = {
|
|
63
|
-
dataset: [...sources, ...transforms],
|
|
64
|
-
series
|
|
65
|
-
};
|
|
66
|
-
return datasets;
|
|
67
|
-
}, [chartData, measuresFields]);
|
|
68
|
-
return boxplotData;
|
|
69
|
-
};
|
|
70
|
-
export {
|
|
71
|
-
useBoxplot
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
//#region src/Boxplot/useBoxplot.tsx
|
|
4
|
+
var useBoxplot = ({ data, groupBy, measures, filters }) => {
|
|
5
|
+
const measuresFields = useMemo(() => {
|
|
6
|
+
if (measures == null) return {};
|
|
7
|
+
if (typeof measures === "string") return { [measures]: void 0 };
|
|
8
|
+
if (Array.isArray(measures)) return measures.reduce((acc, value) => {
|
|
9
|
+
const field = typeof value === "string" ? value : value.field;
|
|
10
|
+
acc[field] = typeof value === "string" ? void 0 : value.yAxis;
|
|
11
|
+
return acc;
|
|
12
|
+
}, {});
|
|
13
|
+
return { [measures.field]: measures.yAxis };
|
|
14
|
+
}, [measures]);
|
|
15
|
+
const chartData = useBoxplotData({
|
|
16
|
+
data,
|
|
17
|
+
groupBy,
|
|
18
|
+
measures: measuresFields,
|
|
19
|
+
filters
|
|
20
|
+
});
|
|
21
|
+
return useMemo(() => {
|
|
22
|
+
const setData = {};
|
|
23
|
+
Object.keys(measuresFields).forEach((m) => {
|
|
24
|
+
setData[m] = [];
|
|
25
|
+
Object.keys(chartData).forEach((key) => {
|
|
26
|
+
setData[m].push(chartData[key][m]);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
const sources = [];
|
|
30
|
+
const transforms = [];
|
|
31
|
+
const series = [];
|
|
32
|
+
Object.keys(measuresFields).forEach((m, index) => {
|
|
33
|
+
sources.push({
|
|
34
|
+
source: setData[m],
|
|
35
|
+
id: m
|
|
36
|
+
});
|
|
37
|
+
transforms.push({
|
|
38
|
+
fromDatasetId: m,
|
|
39
|
+
transform: {
|
|
40
|
+
type: "boxplot",
|
|
41
|
+
config: { itemNameFormatter: (params) => Object.keys(chartData)[params.value] }
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
series.push({
|
|
45
|
+
name: m,
|
|
46
|
+
type: "boxplot",
|
|
47
|
+
datasetIndex: Object.keys(measuresFields).length + index,
|
|
48
|
+
yAxisId: measuresFields[m]
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
dataset: [...sources, ...transforms],
|
|
53
|
+
series
|
|
54
|
+
};
|
|
55
|
+
}, [chartData, measuresFields]);
|
|
72
56
|
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { useBoxplot };
|