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