@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,40 +1,37 @@
|
|
|
1
|
+
import { getHvArqueroCombinedFilters, normalizeColumnName, processTableData } from "../utils/index.js";
|
|
1
2
|
import { useMemo } from "react";
|
|
2
3
|
import { escape } from "arquero";
|
|
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
|
-
return results;
|
|
35
|
-
}, [data, filtersProp, groupByProp, measures]);
|
|
36
|
-
return chartData;
|
|
37
|
-
};
|
|
38
|
-
export {
|
|
39
|
-
useBoxplotData
|
|
4
|
+
//#region src/Boxplot/useBoxplotData.tsx
|
|
5
|
+
var useBoxplotData = ({ data, groupBy: groupByProp, measures, filters: filtersProp }) => {
|
|
6
|
+
return useMemo(() => {
|
|
7
|
+
const { data: processedData } = processTableData(data);
|
|
8
|
+
let tableData = processedData;
|
|
9
|
+
if (filtersProp) {
|
|
10
|
+
const filters = (Array.isArray(filtersProp) ? filtersProp : [filtersProp]).map((filter) => ({
|
|
11
|
+
...filter,
|
|
12
|
+
field: normalizeColumnName(filter.field)
|
|
13
|
+
}));
|
|
14
|
+
tableData = tableData.filter(escape((row) => getHvArqueroCombinedFilters(row, filters)));
|
|
15
|
+
}
|
|
16
|
+
const normalizedGroupBy = normalizeColumnName(groupByProp || "");
|
|
17
|
+
const uniqueGroupBy = new Set(tableData.array(normalizedGroupBy));
|
|
18
|
+
const results = {};
|
|
19
|
+
uniqueGroupBy.forEach((group) => {
|
|
20
|
+
results[group] = {};
|
|
21
|
+
Object.keys(measures).forEach((measure) => {
|
|
22
|
+
results[group][measure] = tableData.params({
|
|
23
|
+
group,
|
|
24
|
+
groupBy: normalizedGroupBy
|
|
25
|
+
}).filter((d, $) => d[$.groupBy] === $.group).array(normalizeColumnName(measure));
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return results;
|
|
29
|
+
}, [
|
|
30
|
+
data,
|
|
31
|
+
filtersProp,
|
|
32
|
+
groupByProp,
|
|
33
|
+
measures
|
|
34
|
+
]);
|
|
40
35
|
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useBoxplotData };
|
|
@@ -1,79 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
3
|
-
import { HeatmapChart } from "echarts/charts";
|
|
4
|
-
import { VisualMapComponent, GridComponent, TooltipComponent } from "echarts/components";
|
|
5
|
-
import * as echarts from "echarts/core";
|
|
1
|
+
import { HvBaseChart } from "../BaseChart/BaseChart.js";
|
|
6
2
|
import { getGroupKey } from "../utils/index.js";
|
|
7
|
-
import { useClasses } from "./ConfusionMatrix.styles.js";
|
|
8
|
-
import { useColorScale, useSeries, useGridLayout } from "./utils.js";
|
|
9
|
-
import { useVisualMap } from "../hooks/useVisualMap.js";
|
|
10
|
-
import { useData } from "../hooks/useData.js";
|
|
11
|
-
import { useTooltip } from "../hooks/tooltip/useTooltip.js";
|
|
12
|
-
import { useYAxis } from "../hooks/useYAxis.js";
|
|
13
3
|
import { useXAxis } from "../hooks/useXAxis.js";
|
|
4
|
+
import { useYAxis } from "../hooks/useYAxis.js";
|
|
14
5
|
import { useGrid } from "../hooks/useGrid.js";
|
|
6
|
+
import { useData } from "../hooks/useData.js";
|
|
7
|
+
import { useVisualMap } from "../hooks/useVisualMap.js";
|
|
8
|
+
import { useTooltip } from "../hooks/tooltip/useTooltip.js";
|
|
15
9
|
import { useOption } from "../hooks/useOption.js";
|
|
16
|
-
import {
|
|
10
|
+
import { useClasses } from "./ConfusionMatrix.styles.js";
|
|
11
|
+
import { useColorScale, useGridLayout, useSeries } from "./utils.js";
|
|
12
|
+
import { forwardRef, useMemo } from "react";
|
|
13
|
+
import { GridComponent, TooltipComponent, VisualMapComponent } from "echarts/components";
|
|
14
|
+
import * as echarts from "echarts/core";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
import { HeatmapChart } from "echarts/charts";
|
|
17
|
+
//#region src/ConfusionMatrix/ConfusionMatrix.tsx
|
|
17
18
|
echarts.use([
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
HeatmapChart,
|
|
20
|
+
VisualMapComponent,
|
|
21
|
+
GridComponent,
|
|
22
|
+
TooltipComponent
|
|
22
23
|
]);
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
custom: colorScaleProp,
|
|
62
|
-
filterKey: groupByKey
|
|
63
|
-
});
|
|
64
|
-
const chartVisualMap = useVisualMap({
|
|
65
|
-
show: colorScale?.pieces != null,
|
|
66
|
-
type: colorScale?.pieces != null ? "piecewise" : "continuous",
|
|
67
|
-
...colorScale,
|
|
68
|
-
...legend
|
|
69
|
-
});
|
|
70
|
-
const chartTooltip = useTooltip({
|
|
71
|
-
component: (params) => {
|
|
72
|
-
const value = params?.series?.[0].value;
|
|
73
|
-
const fmtValue = typeof measure !== "string" && measure.valueFormatter ? measure.valueFormatter(value) : tooltip?.valueFormatter ? tooltip?.valueFormatter(value) : value;
|
|
74
|
-
const ftmTitle = tooltip?.titleFormatter ? tooltip.titleFormatter(params?.title) : params?.title;
|
|
75
|
-
const content = `${ftmTitle} - ${params?.series?.[0].name}: ${fmtValue}`;
|
|
76
|
-
return `
|
|
24
|
+
/**
|
|
25
|
+
* A Confusion Matrix is a table used to evaluate the performance of a predictive model.
|
|
26
|
+
* Rows represent the actual classes, and columns show the predicted classes.
|
|
27
|
+
*
|
|
28
|
+
* - The diagonal cells show correct predictions and off-diagonal cells represent misclassifications.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
var HvConfusionMatrix = forwardRef(function HvConfusionMatrix(props, ref) {
|
|
32
|
+
const { legend, groupBy, measure, sortBy, splitBy, filters, grid, data: dataProp, tooltip, xAxis, yAxis, colorScale: colorScaleProp, delta, valuesProps, width, height, format = "square", classes: classesProp, onOptionChange, ...others } = props;
|
|
33
|
+
const { classes } = useClasses(classesProp);
|
|
34
|
+
const groupByKey = getGroupKey(groupBy);
|
|
35
|
+
const { data: chartData } = useData({
|
|
36
|
+
data: dataProp,
|
|
37
|
+
groupBy,
|
|
38
|
+
measures: [measure],
|
|
39
|
+
sortBy: sortBy ?? groupBy,
|
|
40
|
+
splitBy,
|
|
41
|
+
filters,
|
|
42
|
+
delta: typeof delta === "string" ? delta : void 0
|
|
43
|
+
});
|
|
44
|
+
const colorScale = useColorScale({
|
|
45
|
+
delta: !!delta,
|
|
46
|
+
data: chartData,
|
|
47
|
+
custom: colorScaleProp,
|
|
48
|
+
filterKey: groupByKey
|
|
49
|
+
});
|
|
50
|
+
const chartVisualMap = useVisualMap({
|
|
51
|
+
show: colorScale?.pieces != null,
|
|
52
|
+
type: colorScale?.pieces != null ? "piecewise" : "continuous",
|
|
53
|
+
...colorScale,
|
|
54
|
+
...legend
|
|
55
|
+
});
|
|
56
|
+
const chartTooltip = useTooltip({
|
|
57
|
+
component: (params) => {
|
|
58
|
+
const value = params?.series?.[0].value;
|
|
59
|
+
const fmtValue = typeof measure !== "string" && measure.valueFormatter ? measure.valueFormatter(value) : tooltip?.valueFormatter ? tooltip?.valueFormatter(value) : value;
|
|
60
|
+
const content = `${tooltip?.titleFormatter ? tooltip.titleFormatter(params?.title) : params?.title} - ${params?.series?.[0].name}: ${fmtValue}`;
|
|
61
|
+
return `
|
|
77
62
|
<div class="${classes.tooltipRoot}">
|
|
78
63
|
<div class="${classes.tooltipContainer}">
|
|
79
64
|
<div>
|
|
@@ -81,84 +66,100 @@ const HvConfusionMatrix = forwardRef(function HvConfusionMatrix2(props, ref) {
|
|
|
81
66
|
</div>
|
|
82
67
|
</div>
|
|
83
68
|
</div>`;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
69
|
+
},
|
|
70
|
+
...tooltip
|
|
71
|
+
});
|
|
72
|
+
const chartYAxis = useYAxis({ axes: [{
|
|
73
|
+
type: "categorical",
|
|
74
|
+
name: "True Label",
|
|
75
|
+
position: "left",
|
|
76
|
+
...yAxis,
|
|
77
|
+
nameProps: {
|
|
78
|
+
location: "center",
|
|
79
|
+
padding: yAxis?.nameProps?.location == null || yAxis?.nameProps?.location === "center" ? yAxis?.position === "right" ? [
|
|
80
|
+
50,
|
|
81
|
+
0,
|
|
82
|
+
0,
|
|
83
|
+
0
|
|
84
|
+
] : [
|
|
85
|
+
0,
|
|
86
|
+
0,
|
|
87
|
+
50,
|
|
88
|
+
0
|
|
89
|
+
] : void 0,
|
|
90
|
+
...yAxis?.nameProps
|
|
91
|
+
},
|
|
92
|
+
data: chartData.columnNames().filter((p) => p !== groupByKey).toReversed()
|
|
93
|
+
}] });
|
|
94
|
+
const chartXAxis = useXAxis({
|
|
95
|
+
name: "Predicted Value",
|
|
96
|
+
position: "top",
|
|
97
|
+
...xAxis,
|
|
98
|
+
nameProps: {
|
|
99
|
+
location: "center",
|
|
100
|
+
padding: xAxis?.nameProps?.location == null || xAxis?.nameProps?.location === "center" ? xAxis?.position === "bottom" ? [
|
|
101
|
+
30,
|
|
102
|
+
0,
|
|
103
|
+
0,
|
|
104
|
+
0
|
|
105
|
+
] : [
|
|
106
|
+
0,
|
|
107
|
+
0,
|
|
108
|
+
30,
|
|
109
|
+
0
|
|
110
|
+
] : void 0,
|
|
111
|
+
...xAxis?.nameProps
|
|
112
|
+
},
|
|
113
|
+
data: chartData.array(groupByKey)
|
|
114
|
+
});
|
|
115
|
+
const chartSeries = useSeries({
|
|
116
|
+
data: chartData,
|
|
117
|
+
filterKey: groupByKey,
|
|
118
|
+
valuesProps,
|
|
119
|
+
delta: !!(delta && colorScale == null)
|
|
120
|
+
});
|
|
121
|
+
const chartGridLayout = useGridLayout({
|
|
122
|
+
data: chartData,
|
|
123
|
+
format,
|
|
124
|
+
filterKey: groupByKey,
|
|
125
|
+
visualMapVisible: chartVisualMap.visualMap.show,
|
|
126
|
+
visualMapYPosition: chartVisualMap.visualMap.top,
|
|
127
|
+
xAxisPosition: chartXAxis.xAxis.position
|
|
128
|
+
});
|
|
129
|
+
const chartGrid = useGrid({
|
|
130
|
+
width: width != null ? void 0 : chartGridLayout.size.width,
|
|
131
|
+
height: height != null ? void 0 : chartGridLayout.size.height,
|
|
132
|
+
...chartGridLayout.padding,
|
|
133
|
+
...grid
|
|
134
|
+
});
|
|
135
|
+
const size = useMemo(() => {
|
|
136
|
+
return {
|
|
137
|
+
width,
|
|
138
|
+
height: height ?? chartGridLayout.size.height + chartGridLayout.padding.bottom + chartGridLayout.padding.top
|
|
139
|
+
};
|
|
140
|
+
}, [
|
|
141
|
+
chartGridLayout.padding.bottom,
|
|
142
|
+
chartGridLayout.padding.top,
|
|
143
|
+
chartGridLayout.size.height,
|
|
144
|
+
height,
|
|
145
|
+
width
|
|
146
|
+
]);
|
|
147
|
+
return /* @__PURE__ */ jsx(HvBaseChart, {
|
|
148
|
+
ref,
|
|
149
|
+
option: useOption({
|
|
150
|
+
option: {
|
|
151
|
+
...chartVisualMap,
|
|
152
|
+
...chartTooltip,
|
|
153
|
+
...chartGrid,
|
|
154
|
+
...chartXAxis,
|
|
155
|
+
...chartYAxis,
|
|
156
|
+
...chartSeries
|
|
157
|
+
},
|
|
158
|
+
onOptionChange
|
|
159
|
+
}),
|
|
160
|
+
...size,
|
|
161
|
+
...others
|
|
162
|
+
});
|
|
161
163
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
};
|
|
164
|
+
//#endregion
|
|
165
|
+
export { HvConfusionMatrix };
|
|
@@ -1,29 +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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
staticClasses,
|
|
28
|
-
useClasses
|
|
29
|
-
};
|
|
3
|
+
//#region src/ConfusionMatrix/ConfusionMatrix.styles.tsx
|
|
4
|
+
var { useClasses, staticClasses } = createClasses("HvConfusionMatrix", {
|
|
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
|
+
}
|
|
23
|
+
});
|
|
24
|
+
//#endregion
|
|
25
|
+
export { useClasses };
|