@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,110 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { ScatterChart } 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 { ScatterChart } from "echarts/charts";
|
|
17
|
+
//#region src/ScatterPlot/ScatterPlot.tsx
|
|
17
18
|
echarts.use([
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
ScatterChart,
|
|
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
|
-
...chartGrid,
|
|
89
|
-
...chartDataset,
|
|
90
|
-
...chartSeries,
|
|
91
|
-
...chartLegend,
|
|
92
|
-
...chartTooltip
|
|
93
|
-
},
|
|
94
|
-
onOptionChange
|
|
95
|
-
});
|
|
96
|
-
return /* @__PURE__ */ jsx(
|
|
97
|
-
HvBaseChart,
|
|
98
|
-
{
|
|
99
|
-
ref,
|
|
100
|
-
option,
|
|
101
|
-
width,
|
|
102
|
-
height,
|
|
103
|
-
...others
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
export {
|
|
109
|
-
HvScatterPlot
|
|
110
|
-
};
|
|
28
|
+
/**
|
|
29
|
+
* A scatter plot is a type of chart which displays dots to represent two numeric variables.
|
|
30
|
+
* This type of chart is used to determine the relationship between two variables.
|
|
31
|
+
*/
|
|
32
|
+
var HvScatterPlot = forwardRef(function HvScatterPlot(props, ref) {
|
|
33
|
+
const { yAxis, xAxis, horizontalRangeSlider, grid, data, groupBy, splitBy, sortBy, filters, measures, seriesNameFormatter, legend, classes, tooltip, width, height, onOptionChange, ...others } = props;
|
|
34
|
+
const { data: chartData, mapping: measuresMapping } = useData({
|
|
35
|
+
data,
|
|
36
|
+
groupBy,
|
|
37
|
+
measures,
|
|
38
|
+
splitBy,
|
|
39
|
+
sortBy,
|
|
40
|
+
filters
|
|
41
|
+
});
|
|
42
|
+
const chartDataset = useDataset(chartData);
|
|
43
|
+
const chartYAxis = useYAxis({ axes: Array.isArray(yAxis) || yAxis == null ? yAxis : [yAxis] });
|
|
44
|
+
const chartXAxis = useXAxis({
|
|
45
|
+
type: "continuous",
|
|
46
|
+
...xAxis
|
|
47
|
+
});
|
|
48
|
+
const chartSlider = useDataZoom({ showHorizontal: horizontalRangeSlider?.show });
|
|
49
|
+
const chartGrid = useGrid({ ...grid });
|
|
50
|
+
const chartSeries = useSeries({
|
|
51
|
+
type: "scatter",
|
|
52
|
+
data: chartData,
|
|
53
|
+
groupBy,
|
|
54
|
+
measuresMapping,
|
|
55
|
+
nameFormatter: seriesNameFormatter
|
|
56
|
+
});
|
|
57
|
+
const chartLegend = useLegend({
|
|
58
|
+
...legend,
|
|
59
|
+
series: chartSeries.series
|
|
60
|
+
});
|
|
61
|
+
const chartTooltip = useTooltip({
|
|
62
|
+
...tooltip,
|
|
63
|
+
trigger: "axis",
|
|
64
|
+
measuresMapping,
|
|
65
|
+
classes
|
|
66
|
+
});
|
|
67
|
+
return /* @__PURE__ */ jsx(HvBaseChart, {
|
|
68
|
+
ref,
|
|
69
|
+
option: useOption({
|
|
70
|
+
option: {
|
|
71
|
+
...chartYAxis,
|
|
72
|
+
...chartXAxis,
|
|
73
|
+
...chartSlider,
|
|
74
|
+
...chartGrid,
|
|
75
|
+
...chartDataset,
|
|
76
|
+
...chartSeries,
|
|
77
|
+
...chartLegend,
|
|
78
|
+
...chartTooltip
|
|
79
|
+
},
|
|
80
|
+
onOptionChange
|
|
81
|
+
}),
|
|
82
|
+
width,
|
|
83
|
+
height,
|
|
84
|
+
...others
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
//#endregion
|
|
88
|
+
export { HvScatterPlot };
|
package/dist/Treemap/Treemap.js
CHANGED
|
@@ -1,54 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HvBaseChart } from "../BaseChart/BaseChart.js";
|
|
2
|
+
import { useTooltip } from "../hooks/tooltip/useTooltip.js";
|
|
3
|
+
import { useOption } from "../hooks/useOption.js";
|
|
2
4
|
import { forwardRef } from "react";
|
|
3
|
-
import { TreemapChart } from "echarts/charts";
|
|
4
5
|
import { TooltipComponent } from "echarts/components";
|
|
5
6
|
import * as echarts from "echarts/core";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { TreemapChart } from "echarts/charts";
|
|
9
|
+
//#region src/Treemap/Treemap.tsx
|
|
9
10
|
echarts.use([TreemapChart, TooltipComponent]);
|
|
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
|
-
return /* @__PURE__ */ jsx(
|
|
41
|
-
HvBaseChart,
|
|
42
|
-
{
|
|
43
|
-
ref,
|
|
44
|
-
option,
|
|
45
|
-
width,
|
|
46
|
-
height,
|
|
47
|
-
...others
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
export {
|
|
53
|
-
HvTreemapChart
|
|
54
|
-
};
|
|
11
|
+
/**
|
|
12
|
+
* A tree map chart visually represents hierarchical data using nested rectangles, with each rectangle's size proportional to the value it represents.
|
|
13
|
+
*/
|
|
14
|
+
var HvTreemapChart = forwardRef(function HvTreemapChart(props, ref) {
|
|
15
|
+
const { name, data, classes, width, height, tooltip, onOptionChange, ...others } = props;
|
|
16
|
+
const chartTooltip = useTooltip({
|
|
17
|
+
...tooltip,
|
|
18
|
+
type: "single",
|
|
19
|
+
classes
|
|
20
|
+
});
|
|
21
|
+
return /* @__PURE__ */ jsx(HvBaseChart, {
|
|
22
|
+
ref,
|
|
23
|
+
option: useOption({
|
|
24
|
+
option: {
|
|
25
|
+
series: [{
|
|
26
|
+
name,
|
|
27
|
+
type: "treemap",
|
|
28
|
+
data
|
|
29
|
+
}],
|
|
30
|
+
...chartTooltip
|
|
31
|
+
},
|
|
32
|
+
onOptionChange
|
|
33
|
+
}),
|
|
34
|
+
width,
|
|
35
|
+
height,
|
|
36
|
+
...others
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//#endregion
|
|
40
|
+
export { HvTreemapChart };
|
|
@@ -1,80 +1,79 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
3
|
+
//#region src/hooks/tooltip/styles.tsx
|
|
4
|
+
var { useClasses, staticClasses } = createClasses("HvChartTooltip", {
|
|
5
|
+
/** Single tooltip styles */
|
|
6
|
+
singleTooltipRoot: {
|
|
7
|
+
width: "fit-content",
|
|
8
|
+
boxShadow: theme.colors.shadow,
|
|
9
|
+
backgroundColor: theme.colors.bgContainer,
|
|
10
|
+
padding: theme.space.sm,
|
|
11
|
+
display: "flex"
|
|
12
|
+
},
|
|
13
|
+
singleTooltipTitle: {
|
|
14
|
+
fontFamily: theme.fontFamily.body,
|
|
15
|
+
fontWeight: theme.fontWeights.semibold,
|
|
16
|
+
fontSize: theme.fontSizes.sm,
|
|
17
|
+
color: theme.colors.text
|
|
18
|
+
},
|
|
19
|
+
singleTooltipValue: {
|
|
20
|
+
fontFamily: theme.fontFamily.body,
|
|
21
|
+
fontWeight: theme.fontWeights.normal,
|
|
22
|
+
fontSize: theme.fontSizes.sm,
|
|
23
|
+
color: theme.colors.text,
|
|
24
|
+
marginLeft: theme.space.xs
|
|
25
|
+
},
|
|
26
|
+
/** Multiple tooltip styles */
|
|
27
|
+
multipleTooltipRoot: {
|
|
28
|
+
width: "fit-content",
|
|
29
|
+
boxShadow: theme.colors.shadow,
|
|
30
|
+
backgroundColor: theme.colors.bgContainer
|
|
31
|
+
},
|
|
32
|
+
multipleTooltipTitleContainer: {
|
|
33
|
+
padding: `15px ${theme.space.sm}`,
|
|
34
|
+
borderBottom: `3px solid ${theme.colors.bgPage}`
|
|
35
|
+
},
|
|
36
|
+
multipleTooltipTitle: {
|
|
37
|
+
fontFamily: theme.fontFamily.body,
|
|
38
|
+
fontWeight: theme.fontWeights.semibold,
|
|
39
|
+
fontSize: theme.fontSizes.sm,
|
|
40
|
+
color: theme.colors.text
|
|
41
|
+
},
|
|
42
|
+
multipleTooltipValuesContainer: {
|
|
43
|
+
display: "flex",
|
|
44
|
+
flexDirection: "column",
|
|
45
|
+
padding: theme.space.sm,
|
|
46
|
+
"& > *:not(:last-child)": { paddingBottom: theme.space.sm }
|
|
47
|
+
},
|
|
48
|
+
multipleTooltipSeriesContainer: {
|
|
49
|
+
display: "flex",
|
|
50
|
+
flexDirection: "row",
|
|
51
|
+
justifyContent: "space-between",
|
|
52
|
+
alignItems: "center"
|
|
53
|
+
},
|
|
54
|
+
multipleTooltipSeriesNameContainer: {
|
|
55
|
+
display: "flex",
|
|
56
|
+
flexDirection: "row",
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
marginRight: theme.space.sm
|
|
59
|
+
},
|
|
60
|
+
multipleTooltipSeriesColor: {
|
|
61
|
+
width: "10px",
|
|
62
|
+
height: "10px",
|
|
63
|
+
marginRight: "5px"
|
|
64
|
+
},
|
|
65
|
+
multipleTooltipSeriesName: {
|
|
66
|
+
fontFamily: theme.fontFamily.body,
|
|
67
|
+
fontWeight: theme.fontWeights.semibold,
|
|
68
|
+
fontSize: theme.fontSizes.sm,
|
|
69
|
+
color: theme.colors.text
|
|
70
|
+
},
|
|
71
|
+
multipleTooltipSeriesValue: {
|
|
72
|
+
fontFamily: theme.fontFamily.body,
|
|
73
|
+
fontWeight: theme.fontWeights.normal,
|
|
74
|
+
fontSize: theme.fontSizes.sm,
|
|
75
|
+
color: theme.colors.text
|
|
76
|
+
}
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
useClasses
|
|
80
|
-
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { useClasses };
|
|
@@ -1,38 +1,24 @@
|
|
|
1
|
-
import { useCallback, useMemo } from "react";
|
|
2
1
|
import { getMeasure } from "../../utils/index.js";
|
|
3
2
|
import { useClasses } from "./styles.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const { classes: hvClasses } = useClasses(classes);
|
|
17
|
-
const renderTooltip = useCallback(
|
|
18
|
-
(params) => {
|
|
19
|
-
const title = params[0].seriesType === "treemap" || params[0].seriesType === "heatmap" || params[0].seriesType === "boxplot" ? params[0].name : params[0].seriesType === "pie" ? params[0].seriesName : horizontal ? params[0].value[params[0].encode.y[0]] : params[0].value[params[0].encode.x[0]];
|
|
20
|
-
const formattedTitle = titleFormatter ? titleFormatter(title) : title;
|
|
21
|
-
if (type === "single") {
|
|
22
|
-
const measure = getMeasure(
|
|
23
|
-
params[0].seriesType === "pie" || params[0].seriesType === "treemap" || params[0].seriesType === "heatmap" || params[0].seriesType === "boxplot" ? params[0].name : horizontal ? params[0].dimensionNames[params[0].encode.x[0]] : params[0].dimensionNames[params[0].encode.y[0]],
|
|
24
|
-
measuresMapping
|
|
25
|
-
);
|
|
26
|
-
const value = params[0].seriesType === "pie" || params[0].seriesType === "treemap" || params[0].seriesType === "heatmap" ? params[0].value[params[0].encode.value[0]] : horizontal ? params[0].value[params[0].encode.x[0]] : params[0].value[params[0].encode.y[0]];
|
|
27
|
-
const formattedValue = measure && typeof measure !== "string" && measure.valueFormatter ? measure.valueFormatter(value) : valueFormatter ? valueFormatter(value) : value;
|
|
28
|
-
return `
|
|
3
|
+
import { useCallback, useMemo } from "react";
|
|
4
|
+
//#region src/hooks/tooltip/useTooltip.tsx
|
|
5
|
+
var useTooltip = ({ measuresMapping = {}, classes, component, show = true, horizontal = false, trigger = "item", type = "multiple", valueFormatter, titleFormatter, nameFormatter }) => {
|
|
6
|
+
const { classes: hvClasses } = useClasses(classes);
|
|
7
|
+
const renderTooltip = useCallback((params) => {
|
|
8
|
+
const title = params[0].seriesType === "treemap" || params[0].seriesType === "heatmap" || params[0].seriesType === "boxplot" ? params[0].name : params[0].seriesType === "pie" ? params[0].seriesName : horizontal ? params[0].value[params[0].encode.y[0]] : params[0].value[params[0].encode.x[0]];
|
|
9
|
+
const formattedTitle = titleFormatter ? titleFormatter(title) : title;
|
|
10
|
+
if (type === "single") {
|
|
11
|
+
const measure = getMeasure(params[0].seriesType === "pie" || params[0].seriesType === "treemap" || params[0].seriesType === "heatmap" || params[0].seriesType === "boxplot" ? params[0].name : horizontal ? params[0].dimensionNames[params[0].encode.x[0]] : params[0].dimensionNames[params[0].encode.y[0]], measuresMapping);
|
|
12
|
+
const value = params[0].seriesType === "pie" || params[0].seriesType === "treemap" || params[0].seriesType === "heatmap" ? params[0].value[params[0].encode.value[0]] : horizontal ? params[0].value[params[0].encode.x[0]] : params[0].value[params[0].encode.y[0]];
|
|
13
|
+
const formattedValue = measure && typeof measure !== "string" && measure.valueFormatter ? measure.valueFormatter(value) : valueFormatter ? valueFormatter(value) : value;
|
|
14
|
+
return `
|
|
29
15
|
<div class="${hvClasses?.singleTooltipRoot}">
|
|
30
16
|
<p class="${hvClasses?.singleTooltipTitle}">${formattedTitle}</p>
|
|
31
17
|
<p class="${hvClasses?.singleTooltipValue}">${formattedValue}</p>
|
|
32
18
|
</div>
|
|
33
19
|
`;
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
}
|
|
21
|
+
return `
|
|
36
22
|
<div class="${hvClasses?.multipleTooltipRoot}">
|
|
37
23
|
<div class="${hvClasses?.multipleTooltipTitleContainer}">
|
|
38
24
|
<div>
|
|
@@ -41,15 +27,12 @@ const useTooltip = ({
|
|
|
41
27
|
</div>
|
|
42
28
|
<div class="${hvClasses?.multipleTooltipValuesContainer}">
|
|
43
29
|
${params.map((s) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const name = s.seriesType === "pie" ? s.name : s.seriesName;
|
|
51
|
-
const formattedName = nameFormatter ? nameFormatter(name) : name;
|
|
52
|
-
return `
|
|
30
|
+
const measure = getMeasure(s.seriesType === "pie" ? s.name : horizontal ? s.dimensionNames[s.encode.x[0]] : s.dimensionNames[s.encode.y[0]], measuresMapping);
|
|
31
|
+
const value = s.seriesType === "pie" ? s.value[s.encode.value[0]] : horizontal ? s.value[s.encode.x[0]] : s.value[s.encode.y[0]];
|
|
32
|
+
const formattedValue = typeof measure !== "string" && measure?.valueFormatter ? measure.valueFormatter(value) : valueFormatter ? valueFormatter(value) : value;
|
|
33
|
+
const name = s.seriesType === "pie" ? s.name : s.seriesName;
|
|
34
|
+
const formattedName = nameFormatter ? nameFormatter(name) : name;
|
|
35
|
+
return `
|
|
53
36
|
<div key="${s.seriesName}" class="${hvClasses?.multipleTooltipSeriesContainer}">
|
|
54
37
|
<div class="${hvClasses?.multipleTooltipSeriesNameContainer}">
|
|
55
38
|
<p style="background-color: ${s.color};" class="${hvClasses?.multipleTooltipSeriesColor}" />
|
|
@@ -58,59 +41,53 @@ const useTooltip = ({
|
|
|
58
41
|
<p class="${hvClasses?.multipleTooltipSeriesValue}">${formattedValue}</p>
|
|
59
42
|
</div>
|
|
60
43
|
`;
|
|
61
|
-
|
|
44
|
+
}).join(" ")}
|
|
62
45
|
</div>
|
|
63
46
|
</div>
|
|
64
47
|
`;
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}, [trigger, component, show, renderTooltip, renderCustomTooltip]);
|
|
112
|
-
return option;
|
|
113
|
-
};
|
|
114
|
-
export {
|
|
115
|
-
useTooltip
|
|
48
|
+
}, [
|
|
49
|
+
hvClasses,
|
|
50
|
+
horizontal,
|
|
51
|
+
type,
|
|
52
|
+
measuresMapping,
|
|
53
|
+
nameFormatter,
|
|
54
|
+
titleFormatter,
|
|
55
|
+
valueFormatter
|
|
56
|
+
]);
|
|
57
|
+
const renderCustomTooltip = useCallback((params) => {
|
|
58
|
+
if (typeof component === "function") return component({
|
|
59
|
+
title: params[0].seriesType === "boxplot" ? params[0].name : params[0].seriesType === "pie" || params[0].seriesType === "treemap" || params[0].seriesType === "heatmap" ? params[0].seriesName : horizontal ? params[0].value[params[0].encode.y[0]] : params[0].value[params[0].encode.x[0]],
|
|
60
|
+
series: params.map((p) => {
|
|
61
|
+
return {
|
|
62
|
+
color: p.color,
|
|
63
|
+
name: p.seriesType === "heatmap" ? String(p.value[p.encode.y[0]]) : p.seriesType === "pie" || p.seriesType === "treemap" ? p.name : p.seriesName,
|
|
64
|
+
value: p.seriesType === "pie" || p.seriesType === "treemap" || p.seriesType === "heatmap" ? p.value[p.encode.value[0]] : horizontal ? p.value[p.encode.x[0]] : p.value[p.encode.y[0]]
|
|
65
|
+
};
|
|
66
|
+
}),
|
|
67
|
+
value: params[0].value
|
|
68
|
+
});
|
|
69
|
+
return component;
|
|
70
|
+
}, [component, horizontal]);
|
|
71
|
+
return useMemo(() => {
|
|
72
|
+
return { tooltip: {
|
|
73
|
+
confine: false,
|
|
74
|
+
show,
|
|
75
|
+
trigger,
|
|
76
|
+
position: (point, params, dom, rect, size) => {
|
|
77
|
+
return [point[0], point[1] - size.contentSize[1]];
|
|
78
|
+
},
|
|
79
|
+
formatter: (params) => {
|
|
80
|
+
const tooltipParams = Array.isArray(params) ? params : [params];
|
|
81
|
+
return component ? renderCustomTooltip(tooltipParams) : renderTooltip(tooltipParams);
|
|
82
|
+
}
|
|
83
|
+
} };
|
|
84
|
+
}, [
|
|
85
|
+
trigger,
|
|
86
|
+
component,
|
|
87
|
+
show,
|
|
88
|
+
renderTooltip,
|
|
89
|
+
renderCustomTooltip
|
|
90
|
+
]);
|
|
116
91
|
};
|
|
92
|
+
//#endregion
|
|
93
|
+
export { useTooltip };
|