@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
package/dist/hooks/useLegend.js
CHANGED
|
@@ -1,46 +1,37 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
1
|
import { getLegendIcon } from "../utils/index.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
|
-
}) : void 0
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}, [series, show, icon, formatter, positionProp, direction]);
|
|
42
|
-
return option;
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
useLegend
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
//#region src/hooks/useLegend.tsx
|
|
4
|
+
var useLegend = ({ series, show, icon, formatter, position: positionProp, direction = "horizontal" }) => {
|
|
5
|
+
return useMemo(() => {
|
|
6
|
+
const position = {
|
|
7
|
+
y: positionProp?.y ?? "top",
|
|
8
|
+
x: positionProp?.x ?? "center"
|
|
9
|
+
};
|
|
10
|
+
return { legend: {
|
|
11
|
+
show: show ?? (Array.isArray(series) && series.length > 1),
|
|
12
|
+
itemGap: 20,
|
|
13
|
+
formatter,
|
|
14
|
+
orient: direction,
|
|
15
|
+
...position,
|
|
16
|
+
...icon && { icon: getLegendIcon(icon) },
|
|
17
|
+
...!icon && { data: show !== false && Array.isArray(series) ? series.map((s) => {
|
|
18
|
+
let iconType = "line";
|
|
19
|
+
if (s.areaStyle != null) iconType = "square";
|
|
20
|
+
if (s.type === "scatter") iconType = "circle";
|
|
21
|
+
return {
|
|
22
|
+
name: s.name,
|
|
23
|
+
icon: getLegendIcon(iconType)
|
|
24
|
+
};
|
|
25
|
+
}) : void 0 }
|
|
26
|
+
} };
|
|
27
|
+
}, [
|
|
28
|
+
series,
|
|
29
|
+
show,
|
|
30
|
+
icon,
|
|
31
|
+
formatter,
|
|
32
|
+
positionProp,
|
|
33
|
+
direction
|
|
34
|
+
]);
|
|
46
35
|
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useLegend };
|
package/dist/hooks/useOption.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
const opt = { ...baseOption, ...optionProp };
|
|
14
|
-
return onOptionChange ? onOptionChange(opt) : opt;
|
|
15
|
-
}, [onOptionChange, optionProp]);
|
|
16
|
-
return option;
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
useOption
|
|
2
|
+
//#region src/hooks/useOption.ts
|
|
3
|
+
var useOption = ({ option: optionProp, onOptionChange }) => {
|
|
4
|
+
return useMemo(() => {
|
|
5
|
+
const opt = {
|
|
6
|
+
aria: { enabled: true },
|
|
7
|
+
animation: false,
|
|
8
|
+
...optionProp
|
|
9
|
+
};
|
|
10
|
+
return onOptionChange ? onOptionChange(opt) : opt;
|
|
11
|
+
}, [onOptionChange, optionProp]);
|
|
20
12
|
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { useOption };
|
package/dist/hooks/useSeries.js
CHANGED
|
@@ -1,119 +1,86 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
1
|
import { getGroupKey, getMeasure } from "../utils/index.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
|
-
|
|
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
|
-
connectNulls,
|
|
86
|
-
showSymbol,
|
|
87
|
-
areaStyle: isArea ? { opacity: aOpacity } : void 0
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
id: `series~${groupByKey}~${c}`,
|
|
93
|
-
type,
|
|
94
|
-
name: nameFormatter ? nameFormatter(c) : c,
|
|
95
|
-
...pieOps,
|
|
96
|
-
...barOps,
|
|
97
|
-
...lineOps,
|
|
98
|
-
...scatterOps
|
|
99
|
-
};
|
|
100
|
-
})
|
|
101
|
-
};
|
|
102
|
-
}, [
|
|
103
|
-
data,
|
|
104
|
-
groupByKey,
|
|
105
|
-
measuresMapping,
|
|
106
|
-
type,
|
|
107
|
-
nameFormatter,
|
|
108
|
-
radius,
|
|
109
|
-
stack,
|
|
110
|
-
horizontal,
|
|
111
|
-
emptyCellMode,
|
|
112
|
-
area,
|
|
113
|
-
areaOpacity
|
|
114
|
-
]);
|
|
115
|
-
return option;
|
|
116
|
-
};
|
|
117
|
-
export {
|
|
118
|
-
useSeries
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
//#region src/hooks/useSeries.tsx
|
|
4
|
+
var useSeries = ({ groupBy, type, data, measuresMapping, nameFormatter, stack, emptyCellMode, radius, horizontal = false, area = false, areaOpacity = .5 }) => {
|
|
5
|
+
const groupByKey = getGroupKey(groupBy);
|
|
6
|
+
return useMemo(() => {
|
|
7
|
+
return { series: data.columnNames().filter((c) => c !== groupByKey).map((c) => {
|
|
8
|
+
const measure = getMeasure(c, measuresMapping);
|
|
9
|
+
let pieOps = {};
|
|
10
|
+
let lineOps = {};
|
|
11
|
+
let barOps = {};
|
|
12
|
+
let scatterOps = {};
|
|
13
|
+
if (type === "scatter") scatterOps = {
|
|
14
|
+
yAxisId: typeof measure !== "string" ? measure.yAxis : void 0,
|
|
15
|
+
encode: {
|
|
16
|
+
x: groupByKey,
|
|
17
|
+
y: c
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
if (type === "pie") pieOps = {
|
|
21
|
+
encode: {
|
|
22
|
+
value: c,
|
|
23
|
+
itemName: groupByKey
|
|
24
|
+
},
|
|
25
|
+
labelLine: { show: false },
|
|
26
|
+
label: { show: false },
|
|
27
|
+
emphasis: { label: { show: false } },
|
|
28
|
+
radius
|
|
29
|
+
};
|
|
30
|
+
if (type === "line" || type === "bar") {
|
|
31
|
+
const axisOps = {
|
|
32
|
+
sampling: typeof measure !== "string" ? measure.sampling : void 0,
|
|
33
|
+
yAxisId: typeof measure !== "string" ? measure.yAxis : void 0,
|
|
34
|
+
stack: typeof measure !== "string" ? measure.stack ?? stack ?? void 0 : stack ?? void 0,
|
|
35
|
+
encode: horizontal ? {
|
|
36
|
+
x: c,
|
|
37
|
+
y: groupByKey
|
|
38
|
+
} : {
|
|
39
|
+
x: groupByKey,
|
|
40
|
+
y: c
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
if (type === "bar") barOps = {
|
|
44
|
+
...axisOps,
|
|
45
|
+
barMaxWidth: 90,
|
|
46
|
+
barMinWidth: 3
|
|
47
|
+
};
|
|
48
|
+
if (type === "line") {
|
|
49
|
+
const showSymbol = typeof measure !== "string" ? !measure.hideSymbol : true;
|
|
50
|
+
const connectNulls = typeof measure !== "string" && measure.emptyCellMode ? measure.emptyCellMode === "connect" : emptyCellMode === "connect";
|
|
51
|
+
const isArea = typeof measure !== "string" ? measure.area ?? area : area;
|
|
52
|
+
const aOpacity = typeof measure !== "string" ? measure.areaOpacity ?? areaOpacity : areaOpacity;
|
|
53
|
+
lineOps = {
|
|
54
|
+
...axisOps,
|
|
55
|
+
connectNulls,
|
|
56
|
+
showSymbol,
|
|
57
|
+
areaStyle: isArea ? { opacity: aOpacity } : void 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
id: `series~${groupByKey}~${c}`,
|
|
63
|
+
type,
|
|
64
|
+
name: nameFormatter ? nameFormatter(c) : c,
|
|
65
|
+
...pieOps,
|
|
66
|
+
...barOps,
|
|
67
|
+
...lineOps,
|
|
68
|
+
...scatterOps
|
|
69
|
+
};
|
|
70
|
+
}) };
|
|
71
|
+
}, [
|
|
72
|
+
data,
|
|
73
|
+
groupByKey,
|
|
74
|
+
measuresMapping,
|
|
75
|
+
type,
|
|
76
|
+
nameFormatter,
|
|
77
|
+
radius,
|
|
78
|
+
stack,
|
|
79
|
+
horizontal,
|
|
80
|
+
emptyCellMode,
|
|
81
|
+
area,
|
|
82
|
+
areaOpacity
|
|
83
|
+
]);
|
|
119
84
|
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { useSeries };
|
|
@@ -1,57 +1,40 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
1
|
import { getLegendIcon } from "../utils/index.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
|
-
colorScale,
|
|
43
|
-
direction,
|
|
44
|
-
max,
|
|
45
|
-
min,
|
|
46
|
-
others,
|
|
47
|
-
pieces,
|
|
48
|
-
positionProp?.x,
|
|
49
|
-
positionProp?.y,
|
|
50
|
-
show,
|
|
51
|
-
type
|
|
52
|
-
]);
|
|
53
|
-
return option;
|
|
54
|
-
};
|
|
55
|
-
export {
|
|
56
|
-
useVisualMap
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
//#region src/hooks/useVisualMap.tsx
|
|
4
|
+
var useVisualMap = ({ show = true, direction = "horizontal", type = "continuous", pieces, max, min, colorScale, position: positionProp, ...others }) => {
|
|
5
|
+
return useMemo(() => {
|
|
6
|
+
return { visualMap: {
|
|
7
|
+
type,
|
|
8
|
+
show,
|
|
9
|
+
...pieces && { pieces },
|
|
10
|
+
...type === "piecewise" && {
|
|
11
|
+
itemSymbol: getLegendIcon("square"),
|
|
12
|
+
itemGap: 20,
|
|
13
|
+
itemHeight: 16,
|
|
14
|
+
itemWidth: 16
|
|
15
|
+
},
|
|
16
|
+
...colorScale && {
|
|
17
|
+
max,
|
|
18
|
+
min,
|
|
19
|
+
inRange: { color: colorScale }
|
|
20
|
+
},
|
|
21
|
+
orient: direction,
|
|
22
|
+
top: positionProp?.y || "top",
|
|
23
|
+
left: positionProp?.x || "center",
|
|
24
|
+
...others
|
|
25
|
+
} };
|
|
26
|
+
}, [
|
|
27
|
+
colorScale,
|
|
28
|
+
direction,
|
|
29
|
+
max,
|
|
30
|
+
min,
|
|
31
|
+
others,
|
|
32
|
+
pieces,
|
|
33
|
+
positionProp?.x,
|
|
34
|
+
positionProp?.y,
|
|
35
|
+
show,
|
|
36
|
+
type
|
|
37
|
+
]);
|
|
57
38
|
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { useVisualMap };
|
package/dist/hooks/useXAxis.js
CHANGED
|
@@ -1,64 +1,45 @@
|
|
|
1
|
+
import { getAxisType } from "../utils/index.js";
|
|
1
2
|
import { useMemo } from "react";
|
|
2
3
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
...data && { data },
|
|
43
|
-
...position && { position }
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}, [
|
|
47
|
-
nameProps,
|
|
48
|
-
id,
|
|
49
|
-
type,
|
|
50
|
-
name,
|
|
51
|
-
scale,
|
|
52
|
-
labelRotation,
|
|
53
|
-
labelFormatter,
|
|
54
|
-
maxValue,
|
|
55
|
-
minValue,
|
|
56
|
-
data,
|
|
57
|
-
position,
|
|
58
|
-
colors
|
|
59
|
-
]);
|
|
60
|
-
return option;
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
useXAxis
|
|
4
|
+
//#region src/hooks/useXAxis.tsx
|
|
5
|
+
var useXAxis = ({ id, type = "categorical", labelFormatter, labelRotation, name, maxValue, minValue, scale = false, data, position, nameProps }) => {
|
|
6
|
+
const { colors } = useTheme();
|
|
7
|
+
return useMemo(() => {
|
|
8
|
+
const nameStyleKeys = nameProps ? Object.keys(nameProps).filter((key) => key !== "location") : void 0;
|
|
9
|
+
const nameStyle = nameProps && nameStyleKeys ? nameStyleKeys.reduce((acc, curr) => {
|
|
10
|
+
acc[curr] = curr === "color" && colors?.[nameProps[curr]] || nameProps[curr];
|
|
11
|
+
return acc;
|
|
12
|
+
}, {}) : void 0;
|
|
13
|
+
return { xAxis: {
|
|
14
|
+
id,
|
|
15
|
+
type: getAxisType(type),
|
|
16
|
+
name,
|
|
17
|
+
scale,
|
|
18
|
+
axisLabel: {
|
|
19
|
+
rotate: labelRotation ?? 0,
|
|
20
|
+
formatter: labelFormatter
|
|
21
|
+
},
|
|
22
|
+
max: maxValue === "max" ? "dataMax" : maxValue,
|
|
23
|
+
min: minValue === "min" ? "dataMin" : minValue,
|
|
24
|
+
...nameProps?.location && { nameLocation: nameProps.location },
|
|
25
|
+
...nameStyle && { nameTextStyle: nameStyle },
|
|
26
|
+
...data && { data },
|
|
27
|
+
...position && { position }
|
|
28
|
+
} };
|
|
29
|
+
}, [
|
|
30
|
+
nameProps,
|
|
31
|
+
id,
|
|
32
|
+
type,
|
|
33
|
+
name,
|
|
34
|
+
scale,
|
|
35
|
+
labelRotation,
|
|
36
|
+
labelFormatter,
|
|
37
|
+
maxValue,
|
|
38
|
+
minValue,
|
|
39
|
+
data,
|
|
40
|
+
position,
|
|
41
|
+
colors
|
|
42
|
+
]);
|
|
64
43
|
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { useXAxis };
|
package/dist/hooks/useYAxis.js
CHANGED
|
@@ -1,58 +1,34 @@
|
|
|
1
|
+
import { getAxisType } from "../utils/index.js";
|
|
1
2
|
import { useCallback, useMemo } from "react";
|
|
2
3
|
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
|
-
axisLabel: {
|
|
32
|
-
rotate: labelRotation ?? 0,
|
|
33
|
-
formatter: labelFormatter
|
|
34
|
-
},
|
|
35
|
-
max: maxValue === "max" ? "dataMax" : maxValue,
|
|
36
|
-
min: minValue === "min" ? "dataMin" : minValue,
|
|
37
|
-
...nameProps?.location && {
|
|
38
|
-
nameLocation: nameProps?.location
|
|
39
|
-
},
|
|
40
|
-
...nameStyle && {
|
|
41
|
-
nameTextStyle: nameStyle
|
|
42
|
-
},
|
|
43
|
-
...data && { data },
|
|
44
|
-
...position && { position }
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
[colors, defaultType]
|
|
48
|
-
);
|
|
49
|
-
const option = useMemo(() => {
|
|
50
|
-
return {
|
|
51
|
-
yAxis: Array.isArray(axes) ? axes.map((axis) => createAxis(axis)) : [createAxis({})]
|
|
52
|
-
};
|
|
53
|
-
}, [axes, createAxis]);
|
|
54
|
-
return option;
|
|
55
|
-
};
|
|
56
|
-
export {
|
|
57
|
-
useYAxis
|
|
4
|
+
//#region src/hooks/useYAxis.tsx
|
|
5
|
+
var useYAxis = ({ axes, defaultType = "continuous" }) => {
|
|
6
|
+
const { colors } = useTheme();
|
|
7
|
+
const createAxis = useCallback(({ id, type, name, labelFormatter, labelRotation, maxValue, minValue, nameProps, data, position }) => {
|
|
8
|
+
const nameStyleKeys = nameProps ? Object.keys(nameProps).filter((key) => key !== "location") : void 0;
|
|
9
|
+
const nameStyle = nameProps && nameStyleKeys ? nameStyleKeys.reduce((acc, curr) => {
|
|
10
|
+
acc[curr] = curr === "color" && colors?.[nameProps[curr]] || nameProps[curr];
|
|
11
|
+
return acc;
|
|
12
|
+
}, {}) : void 0;
|
|
13
|
+
return {
|
|
14
|
+
id,
|
|
15
|
+
type: getAxisType(type) ?? getAxisType(defaultType),
|
|
16
|
+
name,
|
|
17
|
+
axisLabel: {
|
|
18
|
+
rotate: labelRotation ?? 0,
|
|
19
|
+
formatter: labelFormatter
|
|
20
|
+
},
|
|
21
|
+
max: maxValue === "max" ? "dataMax" : maxValue,
|
|
22
|
+
min: minValue === "min" ? "dataMin" : minValue,
|
|
23
|
+
...nameProps?.location && { nameLocation: nameProps?.location },
|
|
24
|
+
...nameStyle && { nameTextStyle: nameStyle },
|
|
25
|
+
...data && { data },
|
|
26
|
+
...position && { position }
|
|
27
|
+
};
|
|
28
|
+
}, [colors, defaultType]);
|
|
29
|
+
return useMemo(() => {
|
|
30
|
+
return { yAxis: Array.isArray(axes) ? axes.map((axis) => createAxis(axis)) : [createAxis({})] };
|
|
31
|
+
}, [axes, createAxis]);
|
|
58
32
|
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { useYAxis };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HvVizContext, HvVizProvider, useVizTheme } from "./providers/Provider.js";
|
|
2
|
+
import { HvBaseChart } from "./BaseChart/BaseChart.js";
|
|
2
3
|
import { getHvArqueroCombinedFilters } from "./utils/index.js";
|
|
3
4
|
import { HvBarChart } from "./BarChart/BarChart.js";
|
|
4
|
-
import { HvBaseChart } from "./BaseChart/BaseChart.js";
|
|
5
5
|
import { HvBoxplot } from "./Boxplot/Boxplot.js";
|
|
6
6
|
import { HvConfusionMatrix } from "./ConfusionMatrix/ConfusionMatrix.js";
|
|
7
7
|
import { HvDonutChart } from "./DonutChart/DonutChart.js";
|
|
@@ -9,18 +9,4 @@ import { HvHeatmap } from "./Heatmap/Heatmap.js";
|
|
|
9
9
|
import { HvLineChart } from "./LineChart/LineChart.js";
|
|
10
10
|
import { HvScatterPlot } from "./ScatterPlot/ScatterPlot.js";
|
|
11
11
|
import { HvTreemapChart } from "./Treemap/Treemap.js";
|
|
12
|
-
export {
|
|
13
|
-
HvBarChart,
|
|
14
|
-
HvBaseChart,
|
|
15
|
-
HvBoxplot,
|
|
16
|
-
HvConfusionMatrix,
|
|
17
|
-
HvDonutChart,
|
|
18
|
-
HvHeatmap,
|
|
19
|
-
HvLineChart,
|
|
20
|
-
HvScatterPlot,
|
|
21
|
-
HvTreemapChart,
|
|
22
|
-
HvVizContext,
|
|
23
|
-
HvVizProvider,
|
|
24
|
-
getHvArqueroCombinedFilters,
|
|
25
|
-
useVizTheme
|
|
26
|
-
};
|
|
12
|
+
export { HvBarChart, HvBaseChart, HvBoxplot, HvConfusionMatrix, HvDonutChart, HvHeatmap, HvLineChart, HvScatterPlot, HvTreemapChart, HvVizContext, HvVizProvider, getHvArqueroCombinedFilters, useVizTheme };
|