@hitachivantara/uikit-react-viz 6.1.6 → 6.1.8
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/LICENSE +201 -0
- 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 +23 -11
|
@@ -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 };
|
|
@@ -1,142 +1,109 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
2
|
import { useTheme } from "@hitachivantara/uikit-react-utils";
|
|
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 {
|
|
35
|
-
colorScale: parsedColors || [colors?.textLight || "", colors?.cat3 || ""],
|
|
36
|
-
max,
|
|
37
|
-
min
|
|
38
|
-
};
|
|
39
|
-
}, [colors, custom, data, filterKey, delta]);
|
|
40
|
-
return colorScale;
|
|
3
|
+
//#region src/ConfusionMatrix/utils.ts
|
|
4
|
+
var useColorScale = ({ data, delta, custom, filterKey }) => {
|
|
5
|
+
const { colors } = useTheme();
|
|
6
|
+
return useMemo(() => {
|
|
7
|
+
if (custom == null && delta) return;
|
|
8
|
+
if (custom && typeof custom[0] === "object") return { pieces: custom.reduce((acc, curr) => {
|
|
9
|
+
acc.push({
|
|
10
|
+
...curr,
|
|
11
|
+
color: colors?.[curr.color] || curr.color
|
|
12
|
+
});
|
|
13
|
+
return acc;
|
|
14
|
+
}, []) };
|
|
15
|
+
const flatData = data.columnNames().filter((p) => p !== filterKey).reduce((acc, c) => {
|
|
16
|
+
acc.push(...data.array(c));
|
|
17
|
+
return acc;
|
|
18
|
+
}, []);
|
|
19
|
+
const max = Math.max(...flatData);
|
|
20
|
+
const min = Math.min(...flatData);
|
|
21
|
+
return {
|
|
22
|
+
colorScale: custom?.map((c) => typeof c === "string" ? colors?.[c] || c : c.color) || [colors?.textLight || "", colors?.cat3 || ""],
|
|
23
|
+
max,
|
|
24
|
+
min
|
|
25
|
+
};
|
|
26
|
+
}, [
|
|
27
|
+
colors,
|
|
28
|
+
custom,
|
|
29
|
+
data,
|
|
30
|
+
filterKey,
|
|
31
|
+
delta
|
|
32
|
+
]);
|
|
41
33
|
};
|
|
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
|
-
return racc;
|
|
88
|
-
}, []);
|
|
89
|
-
acc.push(...row);
|
|
90
|
-
return acc;
|
|
91
|
-
}, [])
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}, [colors, data, delta, filterKey, getDeltaColor, valuesProps]);
|
|
95
|
-
return chartSeries;
|
|
34
|
+
var useSeries = ({ data, filterKey, delta, valuesProps }) => {
|
|
35
|
+
const { colors } = useTheme();
|
|
36
|
+
const getDeltaColor = useCallback((value, diagonal) => {
|
|
37
|
+
if (diagonal && value > 0 || !diagonal && value < 0) return colors?.positive;
|
|
38
|
+
if (diagonal && value < 0 || !diagonal && value > 0) return colors?.negative;
|
|
39
|
+
return colors?.textLight;
|
|
40
|
+
}, [colors]);
|
|
41
|
+
return useMemo(() => {
|
|
42
|
+
return { series: {
|
|
43
|
+
id: `series~${filterKey}`,
|
|
44
|
+
type: "heatmap",
|
|
45
|
+
label: {
|
|
46
|
+
show: true,
|
|
47
|
+
...valuesProps,
|
|
48
|
+
...valuesProps?.color && { color: colors?.[valuesProps.color] || valuesProps.color }
|
|
49
|
+
},
|
|
50
|
+
emphasis: { disabled: true },
|
|
51
|
+
data: data.columnNames().filter((p) => p !== filterKey).reduce((acc, c, j) => {
|
|
52
|
+
const row = data.array(c).reduce((racc, rv, i) => {
|
|
53
|
+
racc.push({
|
|
54
|
+
value: [
|
|
55
|
+
data.array(filterKey)[i],
|
|
56
|
+
c,
|
|
57
|
+
rv != null ? rv : "-"
|
|
58
|
+
],
|
|
59
|
+
...delta && {
|
|
60
|
+
visualMap: false,
|
|
61
|
+
itemStyle: { color: getDeltaColor(rv, i === j) }
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return racc;
|
|
65
|
+
}, []);
|
|
66
|
+
acc.push(...row);
|
|
67
|
+
return acc;
|
|
68
|
+
}, [])
|
|
69
|
+
} };
|
|
70
|
+
}, [
|
|
71
|
+
colors,
|
|
72
|
+
data,
|
|
73
|
+
delta,
|
|
74
|
+
filterKey,
|
|
75
|
+
getDeltaColor,
|
|
76
|
+
valuesProps
|
|
77
|
+
]);
|
|
96
78
|
};
|
|
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
|
-
width: Math.max(SQUARE_SIZE * nCols, SQUARE_SIZE * 8)
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}, [
|
|
129
|
-
data,
|
|
130
|
-
filterKey,
|
|
131
|
-
format,
|
|
132
|
-
visualMapVisible,
|
|
133
|
-
visualMapYPosition,
|
|
134
|
-
xAxisPosition
|
|
135
|
-
]);
|
|
136
|
-
return size;
|
|
137
|
-
};
|
|
138
|
-
export {
|
|
139
|
-
useColorScale,
|
|
140
|
-
useGridLayout,
|
|
141
|
-
useSeries
|
|
79
|
+
var SQUARE_SIZE = 52;
|
|
80
|
+
var useGridLayout = ({ data, filterKey, format, xAxisPosition, visualMapVisible, visualMapYPosition }) => {
|
|
81
|
+
return useMemo(() => {
|
|
82
|
+
const nCols = data.array(filterKey).length;
|
|
83
|
+
const nRows = data.columnNames().filter((p) => p !== filterKey).length;
|
|
84
|
+
const itemHeight = format === "square" ? SQUARE_SIZE : SQUARE_SIZE / 2;
|
|
85
|
+
return {
|
|
86
|
+
padding: {
|
|
87
|
+
bottom: xAxisPosition === "bottom" || visualMapVisible && visualMapYPosition === "bottom" ? 60 : 20,
|
|
88
|
+
top: xAxisPosition === "top" || visualMapVisible && visualMapYPosition === "top" ? 60 : 20,
|
|
89
|
+
...visualMapVisible && visualMapYPosition === "bottom" && xAxisPosition === "bottom" && { bottom: 100 },
|
|
90
|
+
...visualMapVisible && visualMapYPosition === "top" && xAxisPosition === "top" && { top: 100 },
|
|
91
|
+
left: 80,
|
|
92
|
+
right: 80
|
|
93
|
+
},
|
|
94
|
+
size: {
|
|
95
|
+
height: Math.max(itemHeight * nRows, itemHeight * 8),
|
|
96
|
+
width: Math.max(SQUARE_SIZE * nCols, SQUARE_SIZE * 8)
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}, [
|
|
100
|
+
data,
|
|
101
|
+
filterKey,
|
|
102
|
+
format,
|
|
103
|
+
visualMapVisible,
|
|
104
|
+
visualMapYPosition,
|
|
105
|
+
xAxisPosition
|
|
106
|
+
]);
|
|
142
107
|
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { useColorScale, useGridLayout, useSeries };
|