@vuu-ui/vuu-chart 3.1.0 → 3.3.0
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/package.json +6 -6
- package/src/Chart.js +35 -10
- package/types/Chart.d.ts +3 -3
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.
|
|
2
|
+
"version": "3.3.0",
|
|
3
3
|
"description": "support for apache echarts using vuu data",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@vuu-ui/vuu-data-types": "3.
|
|
13
|
-
"@vuu-ui/vuu-protocol-types": "3.
|
|
14
|
-
"@vuu-ui/vuu-data-local": "3.
|
|
12
|
+
"@vuu-ui/vuu-data-types": "3.3.0",
|
|
13
|
+
"@vuu-ui/vuu-protocol-types": "3.3.0",
|
|
14
|
+
"@vuu-ui/vuu-data-local": "3.3.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@salt-ds/styles": "0.2.1",
|
|
18
18
|
"@salt-ds/window": "0.1.1",
|
|
19
|
-
"@vuu-ui/vuu-context-menu": "3.
|
|
20
|
-
"@vuu-ui/vuu-utils": "3.
|
|
19
|
+
"@vuu-ui/vuu-context-menu": "3.3.0",
|
|
20
|
+
"@vuu-ui/vuu-utils": "3.3.0",
|
|
21
21
|
"clsx": "^2.0.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
package/src/Chart.js
CHANGED
|
@@ -3,22 +3,23 @@ import { useComponentCssInjection } from "@salt-ds/styles";
|
|
|
3
3
|
import { useWindow } from "@salt-ds/window";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { getInstanceByDom, init } from "echarts";
|
|
6
|
-
import { useEffect, useRef } from "react";
|
|
6
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
7
7
|
import { useChartContextMenu } from "./useChartContextMenu.js";
|
|
8
8
|
import { useChartOptions } from "./useChartOptions.js";
|
|
9
9
|
import { useChartSelection } from "./useChartSelection.js";
|
|
10
10
|
import { buildColumnMap } from "@vuu-ui/vuu-utils";
|
|
11
|
+
import { MeasuredContainer } from "@vuu-ui/vuu-ui-controls";
|
|
11
12
|
import Chart from "./Chart.css";
|
|
12
13
|
const classBase = "vuuChart";
|
|
13
14
|
const Chart_Chart = ({ categoryColumnName, chartSettings = {
|
|
14
15
|
useCoarsePointer: true,
|
|
15
16
|
renderer: "svg"
|
|
16
|
-
}, className, config, dataExclusions, dataSource, optionSettings = {
|
|
17
|
+
}, className, config, dataExclusions, dataSource, height, optionSettings = {
|
|
17
18
|
notMerge: true
|
|
18
|
-
}, palette, showTooltip, style = {
|
|
19
|
+
}, palette, resizeStrategy, showTooltip, style = {
|
|
19
20
|
width: "100%",
|
|
20
21
|
height: "100%"
|
|
21
|
-
}, seriesColumnNames, ...htmlAttributes })=>{
|
|
22
|
+
}, seriesColumnNames, width, ...htmlAttributes })=>{
|
|
22
23
|
const targetWindow = useWindow();
|
|
23
24
|
useComponentCssInjection({
|
|
24
25
|
testId: "vuu-toast-notification",
|
|
@@ -26,6 +27,17 @@ const Chart_Chart = ({ categoryColumnName, chartSettings = {
|
|
|
26
27
|
window: targetWindow
|
|
27
28
|
});
|
|
28
29
|
const chartRef = useRef(null);
|
|
30
|
+
const [chartElement, setChartElement] = useState(null);
|
|
31
|
+
const setChartRef = useCallback((element)=>{
|
|
32
|
+
chartRef.current = element;
|
|
33
|
+
setChartElement(element);
|
|
34
|
+
}, []);
|
|
35
|
+
const onResize = useCallback((size)=>{
|
|
36
|
+
if (chartRef.current) getInstanceByDom(chartRef.current)?.resize({
|
|
37
|
+
height: size.height,
|
|
38
|
+
width: size.width
|
|
39
|
+
});
|
|
40
|
+
}, []);
|
|
29
41
|
const columnMap = buildColumnMap(dataSource.columns);
|
|
30
42
|
const onContextMenu = useChartContextMenu({
|
|
31
43
|
categoryColumnName,
|
|
@@ -47,7 +59,8 @@ const Chart_Chart = ({ categoryColumnName, chartSettings = {
|
|
|
47
59
|
showTooltip
|
|
48
60
|
});
|
|
49
61
|
useEffect(()=>{
|
|
50
|
-
|
|
62
|
+
if (!chartElement) return;
|
|
63
|
+
const chart = init(chartElement, null, chartSettings);
|
|
51
64
|
chart.on("contextmenu", onContextMenu);
|
|
52
65
|
chart.on("click", onClick);
|
|
53
66
|
chart.on("mouseover", onMouseOver);
|
|
@@ -56,6 +69,7 @@ const Chart_Chart = ({ categoryColumnName, chartSettings = {
|
|
|
56
69
|
chart?.dispose();
|
|
57
70
|
};
|
|
58
71
|
}, [
|
|
72
|
+
chartElement,
|
|
59
73
|
chartSettings,
|
|
60
74
|
onClick,
|
|
61
75
|
onContextMenu,
|
|
@@ -63,19 +77,30 @@ const Chart_Chart = ({ categoryColumnName, chartSettings = {
|
|
|
63
77
|
onMouseOut
|
|
64
78
|
]);
|
|
65
79
|
useEffect(()=>{
|
|
66
|
-
if (
|
|
67
|
-
const chart = getInstanceByDom(
|
|
80
|
+
if (chartElement) {
|
|
81
|
+
const chart = getInstanceByDom(chartElement);
|
|
68
82
|
chart?.setOption(option, optionSettings);
|
|
69
83
|
}
|
|
70
84
|
}, [
|
|
85
|
+
chartElement,
|
|
71
86
|
option,
|
|
72
87
|
optionSettings
|
|
73
88
|
]);
|
|
74
|
-
return /*#__PURE__*/ jsx(
|
|
89
|
+
return /*#__PURE__*/ jsx(MeasuredContainer, {
|
|
75
90
|
...htmlAttributes,
|
|
76
91
|
className: clsx(classBase, className),
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
height: height,
|
|
93
|
+
onResize: onResize,
|
|
94
|
+
resizeStrategy: resizeStrategy,
|
|
95
|
+
style: style,
|
|
96
|
+
width: width,
|
|
97
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
98
|
+
ref: setChartRef,
|
|
99
|
+
style: {
|
|
100
|
+
height: "100%",
|
|
101
|
+
width: "100%"
|
|
102
|
+
}
|
|
103
|
+
})
|
|
79
104
|
});
|
|
80
105
|
};
|
|
81
106
|
export { Chart_Chart as Chart };
|
package/types/Chart.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HTMLAttributes } from "react";
|
|
2
1
|
import { ChartOptionsProps } from "./useChartOptions";
|
|
2
|
+
import { type MeasuredContainerProps } from "@vuu-ui/vuu-ui-controls";
|
|
3
3
|
type OptionSettings = {
|
|
4
4
|
notMerge: boolean;
|
|
5
5
|
};
|
|
@@ -14,7 +14,7 @@ type ChartSettings = {
|
|
|
14
14
|
*/
|
|
15
15
|
useCoarsePointer: boolean;
|
|
16
16
|
};
|
|
17
|
-
export interface ChartProps extends ChartOptionsProps,
|
|
17
|
+
export interface ChartProps extends ChartOptionsProps, Omit<MeasuredContainerProps, "children" | "onResize"> {
|
|
18
18
|
chartSettings?: Partial<ChartSettings>;
|
|
19
19
|
optionSettings?: OptionSettings;
|
|
20
20
|
/**
|
|
@@ -24,5 +24,5 @@ export interface ChartProps extends ChartOptionsProps, HTMLAttributes<HTMLDivEle
|
|
|
24
24
|
palette?: string[];
|
|
25
25
|
showTooltip?: boolean;
|
|
26
26
|
}
|
|
27
|
-
export declare const Chart: ({ categoryColumnName, chartSettings, className, config, dataExclusions, dataSource, optionSettings, palette, showTooltip, style, seriesColumnNames, ...htmlAttributes }: ChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const Chart: ({ categoryColumnName, chartSettings, className, config, dataExclusions, dataSource, height, optionSettings, palette, resizeStrategy, showTooltip, style, seriesColumnNames, width, ...htmlAttributes }: ChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
28
|
export {};
|