@easyv/charts 1.8.23 → 1.8.25

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.
@@ -168,8 +168,8 @@ var Label = function Label(_ref5) {
168
168
  _ref5$rotate = _ref5.rotate,
169
169
  rotate = _ref5$rotate === void 0 ? 0 : _ref5$rotate,
170
170
  config = _ref5.config,
171
- _ref5$onClick = _ref5.onClick,
172
- onClick = _ref5$onClick === void 0 ? defaultEvent : _ref5$onClick,
171
+ _ref5$events = _ref5.events,
172
+ events = _ref5$events === void 0 ? defaultEvent : _ref5$events,
173
173
  _ref5$config = _ref5.config,
174
174
  show = _ref5$config.show,
175
175
  style = _ref5$config.style,
@@ -205,7 +205,9 @@ var Label = function Label(_ref5) {
205
205
  }
206
206
  }, /*#__PURE__*/_react["default"].createElement("div", {
207
207
  className: className,
208
- onClick: onClick,
208
+ onClick: function onClick(e) {
209
+ return events(e, "click");
210
+ },
209
211
  "data-data": JSON.stringify({
210
212
  x: label
211
213
  }),
@@ -217,6 +219,7 @@ var Label = function Label(_ref5) {
217
219
  top: y + (isIOS ? iosY : 0)
218
220
  })
219
221
  }, /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
222
+ ShowType: "normal",
220
223
  type: textOverflow,
221
224
  speed: speed,
222
225
  value: _label,
@@ -236,7 +239,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
236
239
  ticks = _ref6.ticks,
237
240
  formatter = _ref6.formatter,
238
241
  rotate = _ref6.rotate,
239
- triggerClick = _ref6.triggerClick,
242
+ triggerEvents = _ref6.triggerEvents,
240
243
  _ref6$config = _ref6.config,
241
244
  on = _ref6$config.on,
242
245
  label = _ref6$config.label,
@@ -331,7 +334,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
331
334
  tickSize: _tickSize,
332
335
  formatter: formatter,
333
336
  rotate: rotate,
334
- onClick: triggerClick
337
+ events: triggerEvents
335
338
  }), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
336
339
  className: "__easyv-gridLine",
337
340
  config: gridLine
@@ -88,7 +88,7 @@ var getBorderRadius = function getBorderRadius(_ref2) {
88
88
  return isVertical ? positive ? "0px " + seriesWidth + "px " + seriesWidth + "px 0" : seriesWidth + "px 0 0 " + seriesWidth + "px" : positive ? seriesWidth / 2 + "px " + seriesWidth / 2 + "px 0 0" : "0 0 " + seriesWidth / 2 + "px " + seriesWidth / 2 + "px";
89
89
  };
90
90
  var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
91
- var triggerClick = _ref3.triggerClick,
91
+ var triggerEvents = _ref3.triggerEvents,
92
92
  indicatorWidth = _ref3.indicatorWidth,
93
93
  _ref3$isControlChart = _ref3.isControlChart,
94
94
  isControlChart = _ref3$isControlChart === void 0 ? false : _ref3$isControlChart,
@@ -243,7 +243,10 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
243
243
  }
244
244
  }, bgAttr, {
245
245
  onClick: function onClick(e) {
246
- return triggerClick(e, "setCurrent");
246
+ return triggerEvents(e, "setCurrent");
247
+ },
248
+ onMouseMove: function onMouseMove(e) {
249
+ return triggerEvents(e, "mouseenter");
247
250
  },
248
251
  onMouseEnter: function onMouseEnter() {
249
252
  if (isControlChart) {
@@ -265,7 +268,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
265
268
  });
266
269
  }
267
270
  },
268
- onMouseLeave: function onMouseLeave() {
271
+ onMouseLeave: function onMouseLeave(e) {
272
+ triggerEvents(e, "mouseleave");
269
273
  if (isControlChart && !auto) {
270
274
  setCtlTip(function (pre) {
271
275
  return {
@@ -81,6 +81,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
81
81
  curXLabel = _useState4[0],
82
82
  setCurXLabel = _useState4[1];
83
83
  var isIOS = context.isIOS,
84
+ scale = context.scale,
85
+ screenPos = context.screenPos,
84
86
  chartWidth = context.width,
85
87
  chartHeight = context.height,
86
88
  triggerOnRelative = context.triggerOnRelative,
@@ -265,16 +267,32 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
265
267
  };
266
268
  var onInteraction = (0, _react.useCallback)(function (e, type) {
267
269
  e.stopPropagation();
270
+ var _e$nativeEvent = e.nativeEvent,
271
+ pageX = _e$nativeEvent.pageX,
272
+ pageY = _e$nativeEvent.pageY;
268
273
  var data = e.currentTarget.dataset.data;
269
274
  var _data = JSON.parse(data);
275
+ var _scale$current = (0, _slicedToArray2["default"])(scale.current, 2),
276
+ scaleX = _scale$current[0],
277
+ scaleY = _scale$current[1];
278
+ var _screenPos$current = screenPos.current,
279
+ left = _screenPos$current.left,
280
+ top = _screenPos$current.top;
281
+ var eventData = _objectSpread(_objectSpread({}, _data), {}, {
282
+ xPos: (pageX - left) * scaleX,
283
+ yPos: (pageY - top) * scaleY
284
+ });
270
285
  if (type == "setCurrent") {
271
286
  setCurXLabel(function (pre) {
272
287
  return pre == _data.x ? "" : _data.x;
273
288
  });
289
+ triggerOnRelative("click", eventData);
290
+ onEmit("click", eventData);
291
+ } else {
292
+ triggerOnRelative(type, eventData);
293
+ onEmit(type, eventData);
274
294
  }
275
- triggerOnRelative('click', _data);
276
- onEmit("click", _data);
277
- }, [triggerOnRelative, onEmit]);
295
+ }, [triggerOnRelative, onEmit, scale]);
278
296
 
279
297
  /**
280
298
  * 控制图相关
@@ -538,7 +556,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
538
556
  ref: function ref(d) {
539
557
  axisElList.current[index] = d;
540
558
  },
541
- triggerClick: onInteraction,
559
+ triggerEvents: onInteraction,
542
560
  xLineRange: xLineRange,
543
561
  yLineRange: yLineRange,
544
562
  controlInfo: controlInfo,
@@ -601,7 +619,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
601
619
  ,
602
620
  isControlChart: !!control,
603
621
  indicatorWidth: indicatorWidth,
604
- triggerClick: onInteraction,
622
+ triggerEvents: onInteraction,
605
623
  setCtlTip: setCtlTip,
606
624
  isXRepeat: isXRepeat
607
625
  }));
@@ -620,7 +638,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
620
638
  bandLength: bandLength,
621
639
  xAxis: axisX,
622
640
  yAxis: yAxis,
623
- triggerClick: onInteraction
641
+ triggerEvents: onInteraction
624
642
  }));
625
643
  }), /*#__PURE__*/_react["default"].createElement("g", null, control && zIndex != "bottom" && ctlIndicatorList.map(function (item, index) {
626
644
  var x = axisX.scaler(item.tick);
@@ -30,7 +30,7 @@ var getCallbackData = function getCallbackData(action, callbacks, data) {
30
30
  target = _ref.target,
31
31
  _action = _ref.actions;
32
32
  if (action === _action) {
33
- callbackData[target] = data[origin];
33
+ callbackData[target] = origin ? data[origin] : data;
34
34
  }
35
35
  });
36
36
  }
@@ -64,19 +64,23 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
64
64
  active = _useState2[0],
65
65
  setActive = _useState2[1];
66
66
  var scaleRef = (0, _react.useRef)([1, 1]);
67
+ var screenPosRef = (0, _react.useRef)({
68
+ left: 0,
69
+ top: 0
70
+ });
67
71
  var triggerOnRelative = (0, _react.useCallback)(function (action, data) {
68
72
  if (!interaction) return;
69
73
  var callbacks = interaction.callbacks,
70
74
  remoteControls = interaction.remoteControls;
71
75
  var callbackData = getCallbackData(action, callbacks, data);
72
- if (JSON.stringify(callbackData) != "{}") {
76
+ if (Object.keys(callbackData).length > 0) {
73
77
  onRelative && onRelative(id, callbackData);
74
78
  remoteControls && emitEvent && remoteControls.forEach(function (o) {
75
79
  var control = JSON.parse(o.control);
76
- if (control.screen && control.type && control.type === 'callback') {
80
+ if (control.screen && control.type && control.type === "callback") {
77
81
  emitEvent({
78
82
  screen: control.screen,
79
- type: 'callback',
83
+ type: "callback",
80
84
  callbackData: callbackData
81
85
  });
82
86
  }
@@ -84,7 +88,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
84
88
  }
85
89
  }, [JSON.stringify(interaction)]);
86
90
  var onEmit = (0, _react.useCallback)(function () {
87
- var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'click';
91
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "click";
88
92
  var data = arguments.length > 1 ? arguments[1] : undefined;
89
93
  return emit && emit(type, data);
90
94
  }, [emit]);
@@ -95,6 +99,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
95
99
  //是否为IOS设备
96
100
  scale: scaleRef,
97
101
  //大屏的缩放比
102
+ screenPos: screenPosRef,
103
+ //大屏的偏移位置
98
104
  width: chartWidth,
99
105
  height: chartHeight,
100
106
  triggerOnRelative: triggerOnRelative,
@@ -121,7 +127,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
121
127
  var data = checkData(originData);
122
128
  return /*#__PURE__*/_react["default"].createElement(_context.chartContext.Provider, {
123
129
  value: context
124
- }, type == 'pie' ? /*#__PURE__*/_react["default"].createElement(_.PieChart, (0, _extends2["default"])({
130
+ }, type == "pie" ? /*#__PURE__*/_react["default"].createElement(_.PieChart, (0, _extends2["default"])({
125
131
  id: id,
126
132
  config: config,
127
133
  data: data,
@@ -142,8 +148,12 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
142
148
  var scale = transform ? transform.match(/^scale\((.+)\)$/)[1] : "1,1";
143
149
  var arr = scale.split(",");
144
150
  scaleRef.current = [1 / arr[0], 1 / (arr.length === 1 ? arr[0] : arr[1])]; //这里做一次除法,后面就可以用乘法计算值了
151
+ screenPosRef.current = {
152
+ left: parseFloat(dom.style.left),
153
+ top: parseFloat(dom.style.top)
154
+ };
145
155
  }
146
- }, 50);
156
+ }, 100);
147
157
  }
148
158
  //预检数据格式是否规范
149
159
  function checkData(data) {
@@ -51,7 +51,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
51
51
  _ref$config$paddingIn = _ref$config.paddingInner,
52
52
  paddingOuter = _ref$config$paddingIn === void 0 ? 0 : _ref$config$paddingIn,
53
53
  _ref$config$showType = _ref$config.showType,
54
- seriesType = _ref$config$showType === void 0 ? 'bar' : _ref$config$showType,
54
+ seriesType = _ref$config$showType === void 0 ? "bar" : _ref$config$showType,
55
55
  _ref$config$highlight = _ref$config.highlight,
56
56
  _ref$config$highlight2 = _ref$config$highlight === void 0 ? {} : _ref$config$highlight,
57
57
  showHighlight = _ref$config$highlight2.show,
@@ -72,7 +72,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
72
72
  yScaler = _ref$yAxis.scaler,
73
73
  isClipAxis = _ref$yAxis.isClipAxis,
74
74
  clipValue = _ref$yAxis.clipValue,
75
- triggerClick = _ref.triggerClick;
75
+ triggerEvents = _ref.triggerEvents;
76
76
  var selectConfig = other;
77
77
  if (selectStyle) {
78
78
  var show = selectStyle.show,
@@ -183,7 +183,15 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
183
183
  return /*#__PURE__*/React.createElement("g", {
184
184
  key: i,
185
185
  onClick: function onClick(e) {
186
- return triggerClick(e, "setCurrent");
186
+ return triggerEvents(e, "setCurrent");
187
+ },
188
+ onMouseMove: function onMouseMove(e) {
189
+ console.log("mousemove", data, e);
190
+ triggerEvents(e, "mouseenter");
191
+ },
192
+ onMouseLeave: function onMouseLeave(e) {
193
+ console.log("mouseleave", e);
194
+ triggerEvents(e, "mouseleave");
187
195
  },
188
196
  style: {
189
197
  cursor: "pointer"
@@ -22,8 +22,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
22
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
24
  var defaultFont = {
25
- fontStyle: 'normal',
26
- fontWeight: 'normal'
25
+ fontStyle: "normal",
26
+ fontWeight: "normal"
27
27
  };
28
28
  var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref) {
29
29
  var _config$value, _config$percent, _config$value2, _config$value3, _config$name;
@@ -33,7 +33,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
33
33
  _ref$config = _ref.config,
34
34
  show = _ref$config.show,
35
35
  _ref$config$order = _ref$config.order,
36
- order = _ref$config$order === void 0 ? '' : _ref$config$order,
36
+ order = _ref$config$order === void 0 ? "" : _ref$config$order,
37
37
  interactive = _ref$config.interactive,
38
38
  LegendType = _ref$config.LegendType,
39
39
  maxWidth = _ref$config.maxWidth,
@@ -41,7 +41,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
41
41
  speed = _ref$config.speed,
42
42
  _ref$config$layout = _ref$config.layout,
43
43
  _ref$config$layout$al = _ref$config$layout.alignment,
44
- alignment = _ref$config$layout$al === void 0 ? 'right center' : _ref$config$layout$al,
44
+ alignment = _ref$config$layout$al === void 0 ? "right center" : _ref$config$layout$al,
45
45
  gridTemplateColumns = _ref$config$layout.gridTemplateColumns,
46
46
  _ref$config$layout$gr = _ref$config$layout.gridGap,
47
47
  gridColumnGap = _ref$config$layout$gr.gridColumnGap,
@@ -62,7 +62,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
62
62
  opacity = _ref$config$unselect3 === void 0 ? 1 : _ref$config$unselect3,
63
63
  filterData = _ref.filterData,
64
64
  formatter = _ref.formatter,
65
- judge = _ref.judge;
65
+ judge = _ref.judge,
66
+ pieClick = _ref.pieClick;
66
67
  if (!show) return null;
67
68
  var ref_container = (0, _react.useRef)(null); // 滚动容器
68
69
  var ref_scrollTop = (0, _react.useRef)(0); // 当前滚动距离
@@ -75,7 +76,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
75
76
  // 初始化行高
76
77
  (0, _react.useEffect)(function () {
77
78
  if (ref_container.current) {
78
- var rowHeight = ref_container.current.querySelector('li').clientHeight + gridRowGap;
79
+ var rowHeight = ref_container.current.querySelector("li").clientHeight + gridRowGap;
79
80
  setScrollStep(rowHeight);
80
81
  }
81
82
  }, [gridRowGap]);
@@ -106,11 +107,11 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
106
107
  }
107
108
  table.scrollTo({
108
109
  top: ref_scrollTop.current,
109
- behavior: 'smooth'
110
+ behavior: "smooth"
110
111
  });
111
112
  };
112
113
  var _series = (0, _utils.sortPie)(series, order);
113
- var _alignment$split = alignment.split(' '),
114
+ var _alignment$split = alignment.split(" "),
114
115
  _alignment$split2 = (0, _slicedToArray2["default"])(_alignment$split, 2),
115
116
  _alignment = _alignment$split2[0],
116
117
  position = _alignment$split2[1];
@@ -119,7 +120,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
119
120
  var dataset = e.currentTarget.dataset;
120
121
  var name = dataset.name;
121
122
  filterData && interactive && filterData(name);
122
- }, [interactive, filterData]);
123
+ pieClick && pieClick(e);
124
+ }, [interactive, filterData, pieClick]);
123
125
  if (judge == 0) {
124
126
  _series.forEach(function (d) {
125
127
  d.percent = 0;
@@ -129,75 +131,77 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
129
131
  // 计算最大宽度
130
132
  var valueFont = ((_config$value = config.value) === null || _config$value === void 0 ? void 0 : _config$value.font) || {};
131
133
  var percentFont = ((_config$percent = config.percent) === null || _config$percent === void 0 ? void 0 : _config$percent.font) || {};
132
- var valueSuffix = ((_config$value2 = config.value) === null || _config$value2 === void 0 || (_config$value2 = _config$value2.suffix) === null || _config$value2 === void 0 ? void 0 : _config$value2.text) || '';
134
+ var valueSuffix = ((_config$value2 = config.value) === null || _config$value2 === void 0 || (_config$value2 = _config$value2.suffix) === null || _config$value2 === void 0 ? void 0 : _config$value2.text) || "";
133
135
  var valueSplitConfig = ((_config$value3 = config.value) === null || _config$value3 === void 0 ? void 0 : _config$value3.splitConfig) || {};
134
136
  var getValueStr = function getValueStr(item) {
135
137
  var _ref2, _item$data$y, _item$data;
136
- var valueStr = ((_ref2 = (_item$data$y = (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.y) !== null && _item$data$y !== void 0 ? _item$data$y : item.value) !== null && _ref2 !== void 0 ? _ref2 : '') + (valueSuffix || '');
138
+ var valueStr = ((_ref2 = (_item$data$y = (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.y) !== null && _item$data$y !== void 0 ? _item$data$y : item.value) !== null && _ref2 !== void 0 ? _ref2 : "") + (valueSuffix || "");
137
139
  if (valueSplitConfig.show && valueSplitConfig.separator) {
138
140
  valueStr = valueStr.toString().replace(/\B(?=(\d{3})+(?!\d))/g, valueSplitConfig.separator);
139
141
  }
140
142
  return valueStr;
141
143
  };
142
144
  var valueMaxWidth = Math.max.apply(Math, (0, _toConsumableArray2["default"])(_series.map(function (item) {
143
- return parseFloat(getCanvasTextWidth(getValueStr(item), valueFont.letterSpacing || 0, "".concat(valueFont.fontSize || 12, "px ").concat(valueFont.fontFamily || 'Arial')));
145
+ return parseFloat(getCanvasTextWidth(getValueStr(item), valueFont.letterSpacing || 0, "".concat(valueFont.fontSize || 12, "px ").concat(valueFont.fontFamily || "Arial")));
144
146
  })));
145
147
  var percentMaxWidth = Math.max.apply(Math, (0, _toConsumableArray2["default"])(_series.map(function (item) {
146
148
  var _item$data2;
147
- var percentStr = (item.percent !== undefined ? item.percent : (_item$data2 = item.data) === null || _item$data2 === void 0 ? void 0 : _item$data2.percent) + '%';
148
- return parseFloat(getCanvasTextWidth(percentStr, percentFont.letterSpacing || 0, "".concat(percentFont.fontSize || 12, "px ").concat(percentFont.fontFamily || 'Arial')));
149
+ var percentStr = (item.percent !== undefined ? item.percent : (_item$data2 = item.data) === null || _item$data2 === void 0 ? void 0 : _item$data2.percent) + "%";
150
+ return parseFloat(getCanvasTextWidth(percentStr, percentFont.letterSpacing || 0, "".concat(percentFont.fontSize || 12, "px ").concat(percentFont.fontFamily || "Arial")));
149
151
  })));
150
152
  var nameMaxWidth = ((_config$name = config.name) === null || _config$name === void 0 ? void 0 : _config$name.maxWidth) || 80;
151
153
  var stylePieOrAxis = formatter ? _objectSpread(_objectSpread({
152
- display: 'flex',
154
+ display: "flex",
153
155
  alignContent: alignment.split(" ")[0] == "center" && (alignment.split(" ")[1] == "left" || alignment.split(" ")[1] == "right") ? alignment.split(" ")[1] == "left" ? "flex-start" : "flex-end" : alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end",
154
156
  flexDirection: "column",
155
- position: 'absolute'
157
+ position: "absolute"
156
158
  }, getPosition(position, _alignment, x, y)), {}, {
157
- height: loop.show ? height : 'auto',
158
- overflowY: loop.show ? 'scroll' : 'auto'
159
+ height: loop.show ? height : "auto",
160
+ overflowY: loop.show ? "scroll" : "auto"
159
161
  }) : _objectSpread(_objectSpread({
160
- display: 'flex',
162
+ display: "flex",
161
163
  flexWrap: "wrap",
162
164
  alignContent: alignment.split(" ")[0] == "center" && (alignment.split(" ")[1] == "left" || alignment.split(" ")[1] == "right") ? alignment.split(" ")[1] == "left" ? "flex-start" : "flex-end" : alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end",
163
165
  flexDirection: "column",
164
- position: 'absolute'
166
+ position: "absolute"
165
167
  }, getPosition(position, _alignment, x, y)), {}, {
166
- height: loop.show ? height : 'auto',
167
- overflowY: loop.show ? 'scroll' : 'auto'
168
+ height: loop.show ? height : "auto",
169
+ overflowY: loop.show ? "scroll" : "auto"
168
170
  });
169
171
  return LegendType == "FixedWidth" ? /*#__PURE__*/_react["default"].createElement("div", {
170
172
  className: "__easyv-legend-wrapper",
171
173
  style: _objectSpread(_objectSpread({
172
- position: 'absolute',
173
- display: 'flex'
174
+ position: "absolute",
175
+ display: "flex"
174
176
  }, getPosition(position, _alignment, x, y)), {}, {
175
- height: loop.show ? height : 'auto',
176
- overflowY: loop.show ? 'scroll' : 'auto'
177
+ height: loop.show ? height : "auto",
178
+ overflowY: loop.show ? "scroll" : "auto"
177
179
  }),
178
180
  ref: ref_container
179
181
  }, /*#__PURE__*/_react["default"].createElement("ul", {
180
182
  style: {
181
- display: 'grid',
182
- gridGap: gridRowGap + 'px ' + gridColumnGap + 'px',
183
- gridTemplateColumns: formatter ? "".concat(nameMaxWidth, "px ").concat(valueMaxWidth, "px ").concat(percentMaxWidth, "px") : 'repeat(' + Math.min(gridTemplateColumns, length) + ', 1fr)' //饼图或者柱状图配合不同的图例显示格式
183
+ display: "grid",
184
+ gridGap: gridRowGap + "px " + gridColumnGap + "px",
185
+ gridTemplateColumns: formatter ? "".concat(nameMaxWidth, "px ").concat(valueMaxWidth, "px ").concat(percentMaxWidth, "px") : "repeat(" + Math.min(gridTemplateColumns, length) + ", 1fr)" //饼图或者柱状图配合不同的图例显示格式
184
186
  }
185
- }, _series.map(function (series, index) {
187
+ }, _series.map(function (series, i) {
186
188
  var _series$config;
187
189
  var type = series.type,
188
190
  name = series.name,
189
191
  displayName = series.displayName,
190
192
  icon = series.icon,
191
- selected = series.selected;
193
+ selected = series.selected,
194
+ index = series.index;
192
195
  var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config = series.config) === null || _series$config === void 0 || (_series$config = _series$config.line) === null || _series$config === void 0 ? void 0 : _series$config.type);
193
196
  return /*#__PURE__*/_react["default"].createElement("li", {
194
- key: index,
197
+ key: i,
195
198
  onClick: onClick,
196
- "data-name": name,
199
+ "data-name": displayName || name,
200
+ "data-index": index,
197
201
  style: {
198
- display: 'flex',
202
+ display: "flex",
199
203
  opacity: selected === false ? opacity / 100 : 1,
200
- alignItems: 'center',
204
+ alignItems: "center",
201
205
  cursor: "pointer",
202
206
  gap: _icon.gap
203
207
  }
@@ -212,8 +216,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
212
216
  value: displayName || name,
213
217
  style: _objectSpread(_objectSpread({}, font), {}, {
214
218
  width: maxWidth,
215
- fontStyle: italic ? 'italic' : 'normal',
216
- fontWeight: bold ? 'bold' : 'normal'
219
+ fontStyle: italic ? "italic" : "normal",
220
+ fontWeight: bold ? "bold" : "normal"
217
221
  }),
218
222
  speed: speed
219
223
  })));
@@ -225,29 +229,31 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
225
229
  return /*#__PURE__*/_react["default"].createElement("ul", {
226
230
  key: indexs,
227
231
  style: (0, _defineProperty2["default"])({
228
- display: 'flex',
229
- width: 'fit-content',
232
+ display: "flex",
233
+ width: "fit-content",
230
234
  justifyContent: alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end",
231
235
  marginBottom: "0px",
232
236
  gap: "".concat(gridRowGap, "px ").concat(gridColumnGap, "px")
233
237
  }, "marginBottom", gridRowGap + "px")
234
- }, _series.map(function (series, index) {
235
- if (Math.floor(index / gridTemplateColumns) == indexs) {
238
+ }, _series.map(function (series, i) {
239
+ if (Math.floor(i / gridTemplateColumns) == indexs) {
236
240
  var _series$config2;
237
241
  var type = series.type,
238
242
  name = series.name,
239
243
  displayName = series.displayName,
240
244
  icon = series.icon,
241
- selected = series.selected;
245
+ selected = series.selected,
246
+ index = series.index;
242
247
  var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config2 = series.config) === null || _series$config2 === void 0 || (_series$config2 = _series$config2.line) === null || _series$config2 === void 0 ? void 0 : _series$config2.type);
243
248
  return /*#__PURE__*/_react["default"].createElement("li", {
244
- key: index,
249
+ key: i,
245
250
  onClick: onClick,
246
- "data-name": name,
251
+ "data-name": displayName || name,
252
+ "data-index": index,
247
253
  style: {
248
- display: 'flex',
254
+ display: "flex",
249
255
  opacity: selected === false ? opacity / 100 : 1,
250
- alignItems: 'center',
256
+ alignItems: "center",
251
257
  cursor: "pointer",
252
258
  gap: _icon.gap
253
259
  }
@@ -262,8 +268,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
262
268
  type: "ellipsis",
263
269
  value: displayName || name,
264
270
  style: _objectSpread(_objectSpread({}, font), {}, {
265
- fontStyle: italic ? 'italic' : 'normal',
266
- fontWeight: bold ? 'bold' : 'normal',
271
+ fontStyle: italic ? "italic" : "normal",
272
+ fontWeight: bold ? "bold" : "normal",
267
273
  minWidth: getCanvasTextWidth(displayName ? displayName.substring(0, 5) || name.substring(0, 5) : "", font.letterSpacing, "".concat(font.fontSize, "px ").concat(font.fontFamily))
268
274
  }),
269
275
  speed: speed
@@ -276,39 +282,39 @@ var getPosition = function getPosition(position, alignment) {
276
282
  var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
277
283
  var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
278
284
  switch (position) {
279
- case 'top':
285
+ case "top":
280
286
  return {
281
- left: alignment == 'left' ? 5 : alignment == 'center' ? '50%' : '',
282
- right: alignment == 'right' ? 10 : '',
287
+ left: alignment == "left" ? 5 : alignment == "center" ? "50%" : "",
288
+ right: alignment == "right" ? 10 : "",
283
289
  top: 5,
284
- transform: "translate3d(calc(".concat(alignment == 'center' ? '-50%' : '0px', " + ").concat(x, "px), ").concat(y, "px, 0px)")
290
+ transform: "translate3d(calc(".concat(alignment == "center" ? "-50%" : "0px", " + ").concat(x, "px), ").concat(y, "px, 0px)")
285
291
  };
286
- case 'right':
292
+ case "right":
287
293
  return {
288
- top: '50%',
294
+ top: "50%",
289
295
  right: 10,
290
296
  transform: "translate3d(".concat(x, "px, calc(-50% + ").concat(y, "px), 0px)")
291
297
  };
292
- case 'left':
298
+ case "left":
293
299
  return {
294
- top: '50%',
300
+ top: "50%",
295
301
  left: 5,
296
302
  transform: "translate3d(".concat(x, "px, calc(-50% + ").concat(y, "px), 0px)")
297
303
  };
298
304
  default:
299
305
  // bottom
300
306
  return {
301
- left: alignment == 'left' ? 5 : alignment == 'center' ? '50%' : '',
302
- right: alignment == 'right' ? 10 : '',
307
+ left: alignment == "left" ? 5 : alignment == "center" ? "50%" : "",
308
+ right: alignment == "right" ? 10 : "",
303
309
  bottom: 5,
304
- transform: "translate3d(calc(".concat(alignment == 'center' ? '-50%' : '0px', " + ").concat(x, "px), ").concat(y, "px, 0px)")
310
+ transform: "translate3d(calc(".concat(alignment == "center" ? "-50%" : "0px", " + ").concat(x, "px), ").concat(y, "px, 0px)")
305
311
  };
306
312
  }
307
313
  };
308
314
  var getCanvasTextWidth = function getCanvasTextWidth(text, letterSpacing) {
309
- var font = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '16px Arial';
310
- var canvas = document.createElement('canvas');
311
- var ctx = canvas.getContext('2d');
315
+ var font = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "16px Arial";
316
+ var canvas = document.createElement("canvas");
317
+ var ctx = canvas.getContext("2d");
312
318
  ctx.font = font;
313
319
  return ctx.measureText(text).width + text.length * letterSpacing + "px";
314
320
  // return ctx.measureText(text).width+(text.length-1)*letterSpacing+"px";//-1有bug
@@ -627,6 +627,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
627
627
  percent: arc.percent.toFixed(legendPrecision)
628
628
  });
629
629
  }),
630
+ pieClick: onClick,
630
631
  formatter: formatter,
631
632
  judge: judgeData
632
633
  }))) : /*#__PURE__*/_react["default"].createElement("div", {
@@ -795,6 +796,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
795
796
  percent: arc.percent.toFixed(legendPrecision)
796
797
  });
797
798
  }),
799
+ pieClick: onClick,
798
800
  formatter: formatter,
799
801
  judge: judgeData
800
802
  })));