onesight-charts 0.4.7 → 0.4.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.
|
@@ -182,12 +182,16 @@ function App() {
|
|
|
182
182
|
value: 26,
|
|
183
183
|
name2: 'LR'
|
|
184
184
|
}];
|
|
185
|
+
var handleClick = function handleClick(params) {
|
|
186
|
+
console.log('params', params);
|
|
187
|
+
};
|
|
185
188
|
return /*#__PURE__*/React.createElement("div", {
|
|
186
189
|
style: {
|
|
187
190
|
height: '360px'
|
|
188
191
|
}
|
|
189
192
|
}, /*#__PURE__*/React.createElement(MapChart, {
|
|
190
|
-
data: data
|
|
193
|
+
data: data,
|
|
194
|
+
handleClick: handleClick
|
|
191
195
|
}));
|
|
192
196
|
}
|
|
193
197
|
export default App;
|
|
@@ -15,7 +15,9 @@ function MapChart(props) {
|
|
|
15
15
|
_props$percentage = props.percentage,
|
|
16
16
|
percentage = _props$percentage === void 0 ? false : _props$percentage,
|
|
17
17
|
_props$currentLanguag = props.currentLanguage,
|
|
18
|
-
currentLanguage = _props$currentLanguag === void 0 ? 'zh-CN' : _props$currentLanguag
|
|
18
|
+
currentLanguage = _props$currentLanguag === void 0 ? 'zh-CN' : _props$currentLanguag,
|
|
19
|
+
_props$handleClick = props.handleClick,
|
|
20
|
+
handleClick = _props$handleClick === void 0 ? function () {} : _props$handleClick;
|
|
19
21
|
var chartRef = useRef(null);
|
|
20
22
|
useEffect(function () {
|
|
21
23
|
init();
|
|
@@ -118,6 +120,13 @@ function MapChart(props) {
|
|
|
118
120
|
data: data
|
|
119
121
|
}]
|
|
120
122
|
};
|
|
123
|
+
|
|
124
|
+
// 🔥 点击事件绑定
|
|
125
|
+
myChart.off('click');
|
|
126
|
+
myChart.on('click', function (params) {
|
|
127
|
+
console.log(params, 'params');
|
|
128
|
+
handleClick && handleClick(params);
|
|
129
|
+
});
|
|
121
130
|
myChart.setOption(option);
|
|
122
131
|
};
|
|
123
132
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -262,6 +262,9 @@ function App() {
|
|
|
262
262
|
name2: "LR"
|
|
263
263
|
}
|
|
264
264
|
];
|
|
265
|
-
|
|
265
|
+
const handleClick = (params) => {
|
|
266
|
+
console.log("params", params);
|
|
267
|
+
};
|
|
268
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { style: { height: "360px" } }, /* @__PURE__ */ import_react.default.createElement(import__.default, { data, handleClick }));
|
|
266
269
|
}
|
|
267
270
|
var base_default = App;
|
|
@@ -44,7 +44,9 @@ function MapChart(props) {
|
|
|
44
44
|
height = "100%",
|
|
45
45
|
data = [],
|
|
46
46
|
percentage = false,
|
|
47
|
-
currentLanguage = "zh-CN"
|
|
47
|
+
currentLanguage = "zh-CN",
|
|
48
|
+
handleClick = () => {
|
|
49
|
+
}
|
|
48
50
|
} = props;
|
|
49
51
|
const chartRef = (0, import_react.useRef)(null);
|
|
50
52
|
(0, import_react.useEffect)(() => {
|
|
@@ -154,6 +156,11 @@ function MapChart(props) {
|
|
|
154
156
|
}
|
|
155
157
|
]
|
|
156
158
|
};
|
|
159
|
+
myChart.off("click");
|
|
160
|
+
myChart.on("click", function(params) {
|
|
161
|
+
console.log(params, "params");
|
|
162
|
+
handleClick && handleClick(params);
|
|
163
|
+
});
|
|
157
164
|
myChart.setOption(option);
|
|
158
165
|
};
|
|
159
166
|
return /* @__PURE__ */ import_react.default.createElement("div", { style: { width, height, position: "relative" } }, /* @__PURE__ */ import_react.default.createElement("div", { style: { width, height }, ref: chartRef }));
|