@easyv/charts 1.6.15 → 1.6.17
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/lib/components/Axis.js +1 -1
- package/lib/components/Band.js +55 -15
- package/lib/components/CartesianChart.js +35 -9
- package/lib/components/ChartContainer.js +1 -1
- package/lib/components/Control.js +1 -1
- package/lib/components/Label.js +103 -71
- package/lib/components/Marquee.js +1 -1
- package/lib/components/TextOverflow.js +1 -1
- package/lib/utils/index.js +3 -3
- package/package.json +1 -1
- package/src/components/Band.tsx +50 -19
- package/src/components/CartesianChart.js +24 -1
- package/src/components/Label.js +24 -9
- package/.husky/commit-msg +0 -4
package/lib/components/Axis.js
CHANGED
|
@@ -228,7 +228,7 @@ var Label = function Label(_ref5) {
|
|
|
228
228
|
}
|
|
229
229
|
})));
|
|
230
230
|
};
|
|
231
|
-
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(
|
|
231
|
+
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(0, _react.forwardRef)(function (_ref6, ref) {
|
|
232
232
|
var orientation = _ref6.orientation,
|
|
233
233
|
scaler = _ref6.scaler,
|
|
234
234
|
_ref6$tickSize = _ref6.tickSize,
|
package/lib/components/Band.js
CHANGED
|
@@ -8,10 +8,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
14
|
var _d3v = require("d3v7");
|
|
14
15
|
var _utils = require("../utils");
|
|
16
|
+
var _excluded = ["pattern", "seriesIntervalWidth", "paddingInner", "highlight"];
|
|
15
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
17
19
|
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; }
|
|
@@ -80,18 +82,13 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
80
82
|
paddingInner = _ref3$config$seriesIn === void 0 ? 0 : _ref3$config$seriesIn,
|
|
81
83
|
_ref3$config$paddingI = _ref3$config.paddingInner,
|
|
82
84
|
paddingOuter = _ref3$config$paddingI === void 0 ? 0 : _ref3$config$paddingI,
|
|
83
|
-
style = _ref3$config.style,
|
|
84
|
-
fillType = _ref3$config.fillType,
|
|
85
|
-
url = _ref3$config.url,
|
|
86
|
-
size = _ref3$config.size,
|
|
87
|
-
fill = _ref3$config.fill,
|
|
88
|
-
border = _ref3$config.border,
|
|
89
|
-
opacity = _ref3$config.opacity,
|
|
90
85
|
_ref3$config$highligh = _ref3$config.highlight,
|
|
91
86
|
showHighlight = _ref3$config$highligh.show,
|
|
92
87
|
extent = _ref3$config$highligh.extent,
|
|
93
88
|
highlightFill = _ref3$config$highligh.fill,
|
|
94
|
-
|
|
89
|
+
other = (0, _objectWithoutProperties2["default"])(_ref3$config, _excluded),
|
|
90
|
+
curXLabel = _ref3.curXLabel,
|
|
91
|
+
selectStyle = _ref3.selectStyle,
|
|
95
92
|
_ref3$bandLength = _ref3.bandLength,
|
|
96
93
|
bandLength = _ref3$bandLength === void 0 ? 0 : _ref3$bandLength,
|
|
97
94
|
data = _ref3.data,
|
|
@@ -107,6 +104,18 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
107
104
|
clipValue = _ref3$yAxis.clipValue,
|
|
108
105
|
reverse = _ref3$yAxis.reverse;
|
|
109
106
|
if (!data.length) return null;
|
|
107
|
+
var selectConfig = other;
|
|
108
|
+
if (selectStyle) {
|
|
109
|
+
var show = selectStyle.show,
|
|
110
|
+
showType = selectStyle.showType,
|
|
111
|
+
barStyle = selectStyle.barStyle,
|
|
112
|
+
headDecorate = selectStyle.headDecorate;
|
|
113
|
+
if (show && showType == "bar") {
|
|
114
|
+
selectConfig = _objectSpread(_objectSpread({}, barStyle), {}, {
|
|
115
|
+
headDecorate: headDecorate
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
110
119
|
var step = isControlChart ? controlStep : normalStep;
|
|
111
120
|
var xScaler = isControlChart ? controlDragScaler : normalScaler;
|
|
112
121
|
var _getSeriesInfo = (0, _utils.getSeriesInfo)({
|
|
@@ -120,7 +129,6 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
120
129
|
seriesStart = _getSeriesInfo.seriesStart;
|
|
121
130
|
var _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
122
131
|
var isVertical = direction === "vertical";
|
|
123
|
-
var borderStr = "".concat(border.borderColor, " solid ").concat(border.borderWidth, "px");
|
|
124
132
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
125
133
|
className: "__easyv-band"
|
|
126
134
|
}, _data.map(function (_ref4, i) {
|
|
@@ -148,10 +156,20 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
148
156
|
y1 = yScaler(isVertical ? end : start);
|
|
149
157
|
y2 = yScaler(isVertical ? start : end);
|
|
150
158
|
}
|
|
159
|
+
var _ref5 = x == curXLabel ? selectConfig : other,
|
|
160
|
+
style = _ref5.style,
|
|
161
|
+
fillType = _ref5.fillType,
|
|
162
|
+
url = _ref5.url,
|
|
163
|
+
size = _ref5.size,
|
|
164
|
+
fill = _ref5.fill,
|
|
165
|
+
border = _ref5.border,
|
|
166
|
+
opacity = _ref5.opacity,
|
|
167
|
+
headDecorate = _ref5.headDecorate;
|
|
168
|
+
var borderStr = "".concat(border.borderColor, " solid ").concat(border.borderWidth, "px");
|
|
151
169
|
var positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
152
|
-
var showHead, headUrl, headWidth, headHeight, headTranslate;
|
|
170
|
+
var showHead, headType, headUrl, headVideo, headWidth, headHeight, headTranslate;
|
|
153
171
|
if (headDecorate) {
|
|
154
|
-
showHead = headDecorate.show, headUrl = headDecorate.url, headWidth = headDecorate.size.width, headHeight = headDecorate.size.height, headTranslate = headDecorate.translate;
|
|
172
|
+
showHead = headDecorate.show, headType = headDecorate.type, headUrl = headDecorate.url, headVideo = headDecorate.video, headWidth = headDecorate.size.width, headHeight = headDecorate.size.height, headTranslate = headDecorate.translate;
|
|
155
173
|
}
|
|
156
174
|
//断轴图相关,将柱形在断轴处切开
|
|
157
175
|
var setClipPath = function setClipPath() {
|
|
@@ -184,7 +202,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
184
202
|
cursor: "pointer"
|
|
185
203
|
}
|
|
186
204
|
}, attr, {
|
|
187
|
-
onClick:
|
|
205
|
+
onClick: function onClick(e) {
|
|
206
|
+
return triggerClick(e, "setCurrent");
|
|
207
|
+
}
|
|
188
208
|
//enter和leave事件,用于控制图的提示框
|
|
189
209
|
,
|
|
190
210
|
onMouseEnter: function onMouseEnter() {
|
|
@@ -224,7 +244,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
224
244
|
}
|
|
225
245
|
},
|
|
226
246
|
"data-data": JSON.stringify(data)
|
|
227
|
-
}), headUrl && showHead && /*#__PURE__*/_react["default"].createElement("div", {
|
|
247
|
+
}), (headUrl || headVideo) && showHead && (headType == "image" ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
228
248
|
style: {
|
|
229
249
|
position: "absolute",
|
|
230
250
|
background: "url(".concat(
|
|
@@ -237,7 +257,25 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
237
257
|
zIndex: 1,
|
|
238
258
|
transform: "translate(calc(-50% + ".concat(headTranslate.x, "px), calc(-50% + ").concat(headTranslate.y, "px))")
|
|
239
259
|
}
|
|
240
|
-
})
|
|
260
|
+
}) : /*#__PURE__*/_react["default"].createElement("video", {
|
|
261
|
+
width: headWidth,
|
|
262
|
+
height: headHeight
|
|
263
|
+
//@ts-ignore
|
|
264
|
+
,
|
|
265
|
+
src: window.appConfig.ASSETS_URL + headVideo
|
|
266
|
+
// controls={true}
|
|
267
|
+
,
|
|
268
|
+
loop: true,
|
|
269
|
+
muted: true,
|
|
270
|
+
autoPlay: true,
|
|
271
|
+
style: {
|
|
272
|
+
position: "absolute",
|
|
273
|
+
left: isVertical ? "100%" : "50%",
|
|
274
|
+
top: isVertical ? "50%" : "0",
|
|
275
|
+
zIndex: 1,
|
|
276
|
+
transform: "translate(calc(-50% + ".concat(headTranslate.x, "px), calc(-50% + ").concat(headTranslate.y, "px))")
|
|
277
|
+
}
|
|
278
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
241
279
|
style: _objectSpread({
|
|
242
280
|
width: "100%",
|
|
243
281
|
height: "100%",
|
|
@@ -245,7 +283,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
245
283
|
// position: "fixed",
|
|
246
284
|
clipPath: setClipPath(),
|
|
247
285
|
opacity: fillType == "pattern" ? opacity : 1,
|
|
248
|
-
background: fillType == "pattern" ? "50% 50% / ".concat(size.width, "px ").concat(size.height, "px repeat ") + "url(" +
|
|
286
|
+
background: fillType == "pattern" ? "50% 50% / ".concat(size.width, "px ").concat(size.height, "px repeat ") + "url(" +
|
|
287
|
+
//@ts-ignore
|
|
288
|
+
window.appConfig.ASSETS_URL + url + ")" : (0, _utils.getBandBackground)(pattern, extent === flag ? highlightFill : fill),
|
|
249
289
|
borderRadius: style == "square" ? "0 0 0 0" : getBorderRadius({
|
|
250
290
|
isVertical: isVertical,
|
|
251
291
|
positive: y > 0,
|
|
@@ -38,6 +38,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
38
38
|
marginBottom = _ref$config$chart$mar.marginBottom,
|
|
39
39
|
animation = _ref$config$chart.animation,
|
|
40
40
|
legend = _ref$config$chart.legend,
|
|
41
|
+
selectStyle = _ref$config$chart.selectStyle,
|
|
41
42
|
series = _ref$config.series,
|
|
42
43
|
bandLength = _ref$config.bandLength,
|
|
43
44
|
tooltip = _ref$config.tooltip,
|
|
@@ -72,11 +73,16 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
72
73
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
73
74
|
isHover = _useState2[0],
|
|
74
75
|
setIsHover = _useState2[1];
|
|
76
|
+
var _useState3 = (0, _react.useState)(""),
|
|
77
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
78
|
+
curXLabel = _useState4[0],
|
|
79
|
+
setCurXLabel = _useState4[1];
|
|
75
80
|
var isIOS = context.isIOS,
|
|
76
81
|
chartWidth = context.width,
|
|
77
82
|
chartHeight = context.height,
|
|
78
83
|
triggerOnRelative = context.triggerOnRelative,
|
|
79
84
|
onEmit = context.onEmit;
|
|
85
|
+
var defaultSelected = selectStyle ? selectStyle.defaultSelected : "";
|
|
80
86
|
var xLineRange = chartWidth;
|
|
81
87
|
var yLineRange = chartHeight;
|
|
82
88
|
//获取控制条相关的参数
|
|
@@ -101,7 +107,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
101
107
|
controlBarWidth = controlWidth * dragPercent;
|
|
102
108
|
controlX = (controlWidth - controlBarWidth) * start / 100;
|
|
103
109
|
}
|
|
104
|
-
var
|
|
110
|
+
var _useState5 = (0, _react.useState)({
|
|
105
111
|
isC: isControl,
|
|
106
112
|
cWidth: controlWidth,
|
|
107
113
|
cHeight: controlHeight,
|
|
@@ -109,9 +115,9 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
109
115
|
cPercent: dragPercent,
|
|
110
116
|
cBarX: controlX
|
|
111
117
|
}),
|
|
112
|
-
|
|
113
|
-
controlInfo =
|
|
114
|
-
setControlInfo =
|
|
118
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
119
|
+
controlInfo = _useState6[0],
|
|
120
|
+
setControlInfo = _useState6[1];
|
|
115
121
|
var cWidth = controlInfo.cWidth,
|
|
116
122
|
cHeight = controlInfo.cHeight,
|
|
117
123
|
cBarWidth = controlInfo.cBarWidth,
|
|
@@ -136,6 +142,19 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
136
142
|
});
|
|
137
143
|
var aiData = aiFormatter ? aiFormatter(originData, axes, series) : (0, _hooks.useAiData)(originData, axes, series);
|
|
138
144
|
var axisX = (0, _hooks.useCarouselAxisX)(axes.get("x"), animation, isHover, controlInfo, active);
|
|
145
|
+
(0, _react.useEffect)(function () {
|
|
146
|
+
var handleAction = function handleAction(e) {
|
|
147
|
+
var dynamicData = e.dynamicData;
|
|
148
|
+
setCurXLabel(dynamicData);
|
|
149
|
+
};
|
|
150
|
+
document.addEventListener("setCurrent_".concat(id), handleAction, false);
|
|
151
|
+
return function () {
|
|
152
|
+
document.removeEventListener("setCurent_".concat(id), handleAction);
|
|
153
|
+
};
|
|
154
|
+
}, []);
|
|
155
|
+
(0, _react.useEffect)(function () {
|
|
156
|
+
setCurXLabel(defaultSelected);
|
|
157
|
+
}, [defaultSelected]);
|
|
139
158
|
(0, _react.useEffect)(function () {
|
|
140
159
|
if (aiData.length) {
|
|
141
160
|
if (!window.aiData) {
|
|
@@ -183,10 +202,13 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
183
202
|
width: indicatorWidth,
|
|
184
203
|
x: position
|
|
185
204
|
};
|
|
186
|
-
var onInteraction = (0, _react.useCallback)(function (e) {
|
|
205
|
+
var onInteraction = (0, _react.useCallback)(function (e, type) {
|
|
187
206
|
e.stopPropagation();
|
|
188
207
|
var data = e.currentTarget.dataset.data;
|
|
189
208
|
var _data = JSON.parse(data);
|
|
209
|
+
if (type == "setCurrent") {
|
|
210
|
+
setCurXLabel(_data.x);
|
|
211
|
+
}
|
|
190
212
|
triggerOnRelative('click', _data);
|
|
191
213
|
onEmit("click", _data);
|
|
192
214
|
}, [triggerOnRelative, onEmit]);
|
|
@@ -347,10 +369,10 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
347
369
|
})
|
|
348
370
|
};
|
|
349
371
|
};
|
|
350
|
-
var
|
|
351
|
-
|
|
352
|
-
ctlTip =
|
|
353
|
-
setCtlTip =
|
|
372
|
+
var _useState7 = (0, _react.useState)(initCtlTip),
|
|
373
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
374
|
+
ctlTip = _useState8[0],
|
|
375
|
+
setCtlTip = _useState8[1];
|
|
354
376
|
var showCtl = ctlTip.show,
|
|
355
377
|
ctlXName = ctlTip.xName,
|
|
356
378
|
ctlX = ctlTip.x,
|
|
@@ -454,6 +476,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
454
476
|
key: index
|
|
455
477
|
}, config, {
|
|
456
478
|
bandLength: bandLength,
|
|
479
|
+
curXLabel: curXLabel,
|
|
480
|
+
selectStyle: selectStyle,
|
|
457
481
|
xAxis: axisX,
|
|
458
482
|
yAxis: yAxis
|
|
459
483
|
// 控制图部分,主要是为了,当鼠标悬浮在指示器上时,显示对应的tooltip
|
|
@@ -471,6 +495,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
471
495
|
return yAxis && /*#__PURE__*/_react["default"].createElement(_.Label, (0, _extends2["default"])({
|
|
472
496
|
key: index
|
|
473
497
|
}, config, {
|
|
498
|
+
curXLabel: curXLabel,
|
|
499
|
+
selectStyle: selectStyle,
|
|
474
500
|
bandLength: bandLength,
|
|
475
501
|
xAxis: axisX,
|
|
476
502
|
yAxis: yAxis,
|
|
@@ -15,7 +15,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
15
15
|
* svg外框
|
|
16
16
|
*/
|
|
17
17
|
var event = function event() {};
|
|
18
|
-
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(
|
|
18
|
+
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
19
19
|
var width = _ref.width,
|
|
20
20
|
height = _ref.height,
|
|
21
21
|
marginLeft = _ref.marginLeft,
|
|
@@ -18,7 +18,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
19
19
|
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; }
|
|
20
20
|
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; }
|
|
21
|
-
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(
|
|
21
|
+
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
22
22
|
var _props$actions = props.actions,
|
|
23
23
|
setX = _props$actions.setX,
|
|
24
24
|
setWorking = _props$actions.setWorking,
|
package/lib/components/Label.js
CHANGED
|
@@ -8,22 +8,28 @@ exports["default"] = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
12
|
var _react = require("react");
|
|
12
13
|
var _utils = require("../utils");
|
|
13
14
|
var _context = require("../context");
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
var _excluded = ["seriesIntervalWidth", "paddingInner", "showType"];
|
|
16
|
+
/**
|
|
16
17
|
* 轴类图表标签
|
|
17
18
|
*/
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
18
21
|
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
19
22
|
var _ref$config = _ref.config,
|
|
20
23
|
_ref$config$seriesInt = _ref$config.seriesIntervalWidth,
|
|
21
24
|
paddingInner = _ref$config$seriesInt === void 0 ? 0 : _ref$config$seriesInt,
|
|
22
25
|
_ref$config$paddingIn = _ref$config.paddingInner,
|
|
23
26
|
paddingOuter = _ref$config$paddingIn === void 0 ? 0 : _ref$config$paddingIn,
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
_ref$config$showType = _ref$config.showType,
|
|
28
|
+
seriesType = _ref$config$showType === void 0 ? 'bar' : _ref$config$showType,
|
|
29
|
+
other = (0, _objectWithoutProperties2["default"])(_ref$config, _excluded),
|
|
26
30
|
config = _ref.config,
|
|
31
|
+
curXLabel = _ref.curXLabel,
|
|
32
|
+
selectStyle = _ref.selectStyle,
|
|
27
33
|
_ref$bandLength = _ref.bandLength,
|
|
28
34
|
bandLength = _ref$bandLength === void 0 ? 0 : _ref$bandLength,
|
|
29
35
|
data = _ref.data,
|
|
@@ -36,10 +42,28 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
36
42
|
isClipAxis = _ref$yAxis.isClipAxis,
|
|
37
43
|
clipValue = _ref$yAxis.clipValue,
|
|
38
44
|
triggerClick = _ref.triggerClick;
|
|
45
|
+
var selectConfig = other;
|
|
46
|
+
if (selectStyle) {
|
|
47
|
+
var show = selectStyle.show,
|
|
48
|
+
showType = selectStyle.showType,
|
|
49
|
+
icon = selectStyle.icon,
|
|
50
|
+
label = selectStyle.numlabel;
|
|
51
|
+
if (show && seriesType == showType) {
|
|
52
|
+
if (showType == "bar") {
|
|
53
|
+
selectConfig = {
|
|
54
|
+
label: label
|
|
55
|
+
};
|
|
56
|
+
} else {
|
|
57
|
+
selectConfig = {
|
|
58
|
+
icon: icon,
|
|
59
|
+
label: label
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
39
64
|
var lineType = config.hasOwnProperty("line"); // 堆叠处理
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!(data.length && (showIcon || showLabel))) return null;
|
|
65
|
+
|
|
66
|
+
if (!data.length) return null;
|
|
43
67
|
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
44
68
|
width = _useContext.width,
|
|
45
69
|
height = _useContext.height;
|
|
@@ -53,8 +77,6 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
53
77
|
seriesWidth = _getSeriesInfo.seriesWidth,
|
|
54
78
|
seriesStart = _getSeriesInfo.seriesStart;
|
|
55
79
|
var isVertical = direction === "vertical";
|
|
56
|
-
var _position = label.position,
|
|
57
|
-
reverse = label.reverse;
|
|
58
80
|
return /*#__PURE__*/React.createElement("g", {
|
|
59
81
|
className: "__easyv-label"
|
|
60
82
|
}, data.map(function (_ref2, i) {
|
|
@@ -69,6 +91,13 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
69
91
|
showY = _ref2$data.showY,
|
|
70
92
|
s = _ref2$data.s;
|
|
71
93
|
var y1, y2;
|
|
94
|
+
var _ref3 = x == curXLabel ? selectConfig : other,
|
|
95
|
+
icon = _ref3.icon,
|
|
96
|
+
label = _ref3.label;
|
|
97
|
+
var showIcon = icon && icon.show;
|
|
98
|
+
var showLabel = label && label.show;
|
|
99
|
+
var _position = label.position,
|
|
100
|
+
reverse = label.reverse;
|
|
72
101
|
if (isClipAxis) {
|
|
73
102
|
if (end > +clipValue) {
|
|
74
103
|
y1 = yScaler[1](start);
|
|
@@ -111,7 +140,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
111
140
|
});
|
|
112
141
|
return /*#__PURE__*/React.createElement("g", {
|
|
113
142
|
key: i,
|
|
114
|
-
onClick:
|
|
143
|
+
onClick: function onClick(e) {
|
|
144
|
+
return triggerClick(e, "setCurrent");
|
|
145
|
+
},
|
|
115
146
|
style: {
|
|
116
147
|
cursor: "pointer"
|
|
117
148
|
},
|
|
@@ -127,29 +158,29 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
127
158
|
}, attr)));
|
|
128
159
|
}));
|
|
129
160
|
});
|
|
130
|
-
var Label = function Label(
|
|
131
|
-
var x =
|
|
132
|
-
y =
|
|
133
|
-
value =
|
|
134
|
-
|
|
135
|
-
font =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
translateX =
|
|
139
|
-
|
|
140
|
-
translateY =
|
|
141
|
-
|
|
142
|
-
content =
|
|
143
|
-
suffixFont =
|
|
144
|
-
|
|
145
|
-
suffixX =
|
|
146
|
-
suffixY =
|
|
147
|
-
|
|
148
|
-
textAnchor =
|
|
149
|
-
|
|
150
|
-
dominantBaseline =
|
|
151
|
-
reverse =
|
|
152
|
-
return /*#__PURE__*/React.createElement("text",
|
|
161
|
+
var Label = function Label(_ref4) {
|
|
162
|
+
var x = _ref4.x,
|
|
163
|
+
y = _ref4.y,
|
|
164
|
+
value = _ref4.value,
|
|
165
|
+
_ref4$config = _ref4.config,
|
|
166
|
+
font = _ref4$config.font,
|
|
167
|
+
_ref4$config$translat = _ref4$config.translate,
|
|
168
|
+
_ref4$config$translat2 = _ref4$config$translat.x,
|
|
169
|
+
translateX = _ref4$config$translat2 === void 0 ? 0 : _ref4$config$translat2,
|
|
170
|
+
_ref4$config$translat3 = _ref4$config$translat.y,
|
|
171
|
+
translateY = _ref4$config$translat3 === void 0 ? 0 : _ref4$config$translat3,
|
|
172
|
+
_ref4$config$suffix = _ref4$config.suffix,
|
|
173
|
+
content = _ref4$config$suffix.content,
|
|
174
|
+
suffixFont = _ref4$config$suffix.font,
|
|
175
|
+
_ref4$config$suffix$t = _ref4$config$suffix.translate,
|
|
176
|
+
suffixX = _ref4$config$suffix$t.x,
|
|
177
|
+
suffixY = _ref4$config$suffix$t.y,
|
|
178
|
+
_ref4$textAnchor = _ref4.textAnchor,
|
|
179
|
+
textAnchor = _ref4$textAnchor === void 0 ? "middle" : _ref4$textAnchor,
|
|
180
|
+
_ref4$dominantBaselin = _ref4.dominantBaseline,
|
|
181
|
+
dominantBaseline = _ref4$dominantBaselin === void 0 ? "middle" : _ref4$dominantBaselin,
|
|
182
|
+
reverse = _ref4.reverse;
|
|
183
|
+
return /*#__PURE__*/React.createElement("text", {
|
|
153
184
|
x: x,
|
|
154
185
|
y: y,
|
|
155
186
|
transform: (0, _utils.getTranslate2d)({
|
|
@@ -157,26 +188,27 @@ var Label = function Label(_ref3) {
|
|
|
157
188
|
y: translateY * (value < 0 && reverse ? -1 : 1)
|
|
158
189
|
}),
|
|
159
190
|
textAnchor: textAnchor,
|
|
160
|
-
dominantBaseline: dominantBaseline
|
|
161
|
-
|
|
191
|
+
dominantBaseline: dominantBaseline,
|
|
192
|
+
style: (0, _utils.getFontStyle)(font)
|
|
193
|
+
}, /*#__PURE__*/React.createElement("tspan", null, value), /*#__PURE__*/React.createElement("tspan", {
|
|
162
194
|
dx: suffixX,
|
|
163
195
|
dy: suffixY,
|
|
164
196
|
style: _objectSpread({}, (0, _utils.getFontStyle)(suffixFont, "svg"))
|
|
165
197
|
}, content));
|
|
166
198
|
};
|
|
167
|
-
var Icon = function Icon(
|
|
168
|
-
var cx =
|
|
169
|
-
cy =
|
|
170
|
-
|
|
171
|
-
mode =
|
|
172
|
-
inner =
|
|
173
|
-
outer =
|
|
174
|
-
color =
|
|
175
|
-
radius =
|
|
176
|
-
image =
|
|
177
|
-
|
|
178
|
-
width =
|
|
179
|
-
height =
|
|
199
|
+
var Icon = function Icon(_ref5) {
|
|
200
|
+
var cx = _ref5.cx,
|
|
201
|
+
cy = _ref5.cy,
|
|
202
|
+
_ref5$config = _ref5.config,
|
|
203
|
+
mode = _ref5$config.mode,
|
|
204
|
+
inner = _ref5$config.inner,
|
|
205
|
+
outer = _ref5$config.outer,
|
|
206
|
+
color = _ref5$config.color,
|
|
207
|
+
radius = _ref5$config.radius,
|
|
208
|
+
image = _ref5$config.image,
|
|
209
|
+
_ref5$config$size = _ref5$config.size,
|
|
210
|
+
width = _ref5$config$size.width,
|
|
211
|
+
height = _ref5$config$size.height;
|
|
180
212
|
return mode == "single" ? /*#__PURE__*/React.createElement(Circle, {
|
|
181
213
|
cx: cx,
|
|
182
214
|
cy: cy,
|
|
@@ -196,11 +228,11 @@ var Icon = function Icon(_ref4) {
|
|
|
196
228
|
xlinkHref: window.appConfig.ASSETS_URL + image
|
|
197
229
|
}));
|
|
198
230
|
};
|
|
199
|
-
var Circle = function Circle(
|
|
200
|
-
var cx =
|
|
201
|
-
cy =
|
|
202
|
-
color =
|
|
203
|
-
radius =
|
|
231
|
+
var Circle = function Circle(_ref6) {
|
|
232
|
+
var cx = _ref6.cx,
|
|
233
|
+
cy = _ref6.cy,
|
|
234
|
+
color = _ref6.color,
|
|
235
|
+
radius = _ref6.radius;
|
|
204
236
|
return /*#__PURE__*/React.createElement("circle", {
|
|
205
237
|
cx: cx,
|
|
206
238
|
cy: cy,
|
|
@@ -209,15 +241,15 @@ var Circle = function Circle(_ref5) {
|
|
|
209
241
|
stroke: "none"
|
|
210
242
|
});
|
|
211
243
|
};
|
|
212
|
-
var getVerticalLabel = function getVerticalLabel(
|
|
213
|
-
var
|
|
214
|
-
position =
|
|
215
|
-
width =
|
|
216
|
-
y =
|
|
217
|
-
y1 =
|
|
218
|
-
y2 =
|
|
219
|
-
|
|
220
|
-
reverse =
|
|
244
|
+
var getVerticalLabel = function getVerticalLabel(_ref7) {
|
|
245
|
+
var _ref7$position = _ref7.position,
|
|
246
|
+
position = _ref7$position === void 0 ? "outerStart" : _ref7$position,
|
|
247
|
+
width = _ref7.width,
|
|
248
|
+
y = _ref7.y,
|
|
249
|
+
y1 = _ref7.y1,
|
|
250
|
+
y2 = _ref7.y2,
|
|
251
|
+
_ref7$reverse = _ref7.reverse,
|
|
252
|
+
reverse = _ref7$reverse === void 0 ? true : _ref7$reverse;
|
|
221
253
|
var needReverse = reverse && y < 0;
|
|
222
254
|
switch (position) {
|
|
223
255
|
case "start":
|
|
@@ -247,15 +279,15 @@ var getVerticalLabel = function getVerticalLabel(_ref6) {
|
|
|
247
279
|
};
|
|
248
280
|
}
|
|
249
281
|
};
|
|
250
|
-
var getHorizontalLabel = function getHorizontalLabel(
|
|
251
|
-
var
|
|
252
|
-
position =
|
|
253
|
-
height =
|
|
254
|
-
y =
|
|
255
|
-
y1 =
|
|
256
|
-
y2 =
|
|
257
|
-
|
|
258
|
-
reverse =
|
|
282
|
+
var getHorizontalLabel = function getHorizontalLabel(_ref8) {
|
|
283
|
+
var _ref8$position = _ref8.position,
|
|
284
|
+
position = _ref8$position === void 0 ? "outerStart" : _ref8$position,
|
|
285
|
+
height = _ref8.height,
|
|
286
|
+
y = _ref8.y,
|
|
287
|
+
y1 = _ref8.y1,
|
|
288
|
+
y2 = _ref8.y2,
|
|
289
|
+
_ref8$reverse = _ref8.reverse,
|
|
290
|
+
reverse = _ref8$reverse === void 0 ? true : _ref8$reverse;
|
|
259
291
|
var needReverse = reverse && y < 0;
|
|
260
292
|
switch (position) {
|
|
261
293
|
case "start":
|
|
@@ -17,7 +17,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
17
17
|
* 文字跑马灯组件
|
|
18
18
|
* eg: <Marquee value={文本内容} speed={跑马灯速度} style={额外样式}></Marquee>
|
|
19
19
|
*/
|
|
20
|
-
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(
|
|
20
|
+
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
21
21
|
var value = props.value,
|
|
22
22
|
style = props.style,
|
|
23
23
|
_props$speed = props.speed,
|
|
@@ -17,7 +17,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
17
17
|
* 文本溢出组件
|
|
18
18
|
* eg: <TextOverflow type={溢出形式} value={文本内容} speed={跑马灯速度} style={额外样式}></Marquee>
|
|
19
19
|
*/
|
|
20
|
-
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(
|
|
20
|
+
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
21
21
|
var type = props.type,
|
|
22
22
|
value = props.value,
|
|
23
23
|
style = props.style,
|
package/lib/utils/index.js
CHANGED
|
@@ -354,11 +354,11 @@ function band() {
|
|
|
354
354
|
};
|
|
355
355
|
scale.range = function (_) {
|
|
356
356
|
var _ref11;
|
|
357
|
-
return arguments.length ? (
|
|
357
|
+
return arguments.length ? (_ref11 = (0, _slicedToArray2["default"])(_, 2), r0 = _ref11[0], r1 = _ref11[1], r0 = +r0, r1 = +r1, rescale()) : [r0, r1];
|
|
358
358
|
};
|
|
359
359
|
scale.rangeRound = function (_) {
|
|
360
360
|
var _ref12;
|
|
361
|
-
return
|
|
361
|
+
return _ref12 = (0, _slicedToArray2["default"])(_, 2), r0 = _ref12[0], r1 = _ref12[1], r0 = +r0, r1 = +r1, round = true, rescale();
|
|
362
362
|
};
|
|
363
363
|
scale.bandwidth = function () {
|
|
364
364
|
return bandwidth;
|
|
@@ -499,7 +499,7 @@ var getBandBackground = exports.getBandBackground = function getBandBackground(p
|
|
|
499
499
|
var _pattern$backgroundSi = pattern.backgroundSize,
|
|
500
500
|
backgroundSize = _pattern$backgroundSi === void 0 ? '100% 100%' : _pattern$backgroundSi,
|
|
501
501
|
_pattern = (0, _objectWithoutProperties2["default"])(pattern, _excluded);
|
|
502
|
-
return 'center top / ' + backgroundSize + ' url("data:image/svg+xml,' + encodeURIComponent((0, _server.renderToStaticMarkup)(
|
|
502
|
+
return 'center top / ' + backgroundSize + ' url("data:image/svg+xml,' + encodeURIComponent((0, _server.renderToStaticMarkup)(/*#__PURE__*/React.createElement(SvgBackground, {
|
|
503
503
|
fill: fill,
|
|
504
504
|
pattern: _pattern
|
|
505
505
|
}))) + '")';
|
package/package.json
CHANGED
package/src/components/Band.tsx
CHANGED
|
@@ -75,22 +75,24 @@ export default memo(
|
|
|
75
75
|
pattern = {},
|
|
76
76
|
seriesIntervalWidth: paddingInner = 0,
|
|
77
77
|
paddingInner: paddingOuter = 0,
|
|
78
|
-
style,
|
|
79
|
-
fillType,
|
|
80
|
-
url,
|
|
81
|
-
size,
|
|
82
|
-
fill,
|
|
83
|
-
border,
|
|
84
|
-
opacity,
|
|
85
78
|
highlight: { show: showHighlight, extent, fill: highlightFill },
|
|
86
|
-
|
|
79
|
+
...other
|
|
87
80
|
},
|
|
81
|
+
curXLabel,
|
|
82
|
+
selectStyle,
|
|
88
83
|
bandLength = 0,
|
|
89
84
|
data,
|
|
90
85
|
xAxis: { scaler: normalScaler, step:normalStep, controlStep, direction, controlDragScaler },
|
|
91
86
|
yAxis: { scaler: yScaler, isClipAxis, clipValue, reverse },
|
|
92
87
|
}: any) => {
|
|
93
88
|
if (!data.length) return null;
|
|
89
|
+
let selectConfig = other;
|
|
90
|
+
if(selectStyle){
|
|
91
|
+
const { show, showType, barStyle, headDecorate } = selectStyle;
|
|
92
|
+
if(show && showType=="bar"){
|
|
93
|
+
selectConfig = { ...barStyle, headDecorate };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
94
96
|
const step = isControlChart?controlStep:normalStep;
|
|
95
97
|
const xScaler = isControlChart?controlDragScaler:normalScaler;
|
|
96
98
|
const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
|
|
@@ -101,7 +103,7 @@ export default memo(
|
|
|
101
103
|
});
|
|
102
104
|
const _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
103
105
|
const isVertical = direction === "vertical";
|
|
104
|
-
|
|
106
|
+
|
|
105
107
|
return (
|
|
106
108
|
<g className="__easyv-band">
|
|
107
109
|
{_data.map(
|
|
@@ -129,15 +131,28 @@ export default memo(
|
|
|
129
131
|
y1 = yScaler(isVertical ? end : start);
|
|
130
132
|
y2 = yScaler(isVertical ? start : end);
|
|
131
133
|
}
|
|
134
|
+
const {
|
|
135
|
+
style,
|
|
136
|
+
fillType,
|
|
137
|
+
url,
|
|
138
|
+
size,
|
|
139
|
+
fill,
|
|
140
|
+
border,
|
|
141
|
+
opacity,
|
|
142
|
+
headDecorate
|
|
143
|
+
} = x==curXLabel?selectConfig:other;
|
|
144
|
+
const borderStr = `${border.borderColor} solid ${border.borderWidth}px`;
|
|
132
145
|
const positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
133
146
|
|
|
134
|
-
let showHead, headUrl, headWidth, headHeight, headTranslate;
|
|
147
|
+
let showHead, headType, headUrl, headVideo, headWidth, headHeight, headTranslate;
|
|
135
148
|
if (headDecorate) {
|
|
136
149
|
(showHead = headDecorate.show),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
(headType = headDecorate.type),
|
|
151
|
+
(headUrl = headDecorate.url),
|
|
152
|
+
(headVideo = headDecorate.video),
|
|
153
|
+
(headWidth = headDecorate.size.width),
|
|
154
|
+
(headHeight = headDecorate.size.height),
|
|
155
|
+
(headTranslate = headDecorate.translate);
|
|
141
156
|
}
|
|
142
157
|
//断轴图相关,将柱形在断轴处切开
|
|
143
158
|
const setClipPath = () => {
|
|
@@ -173,7 +188,7 @@ export default memo(
|
|
|
173
188
|
cursor: "pointer",
|
|
174
189
|
}}
|
|
175
190
|
{...attr}
|
|
176
|
-
onClick={triggerClick}
|
|
191
|
+
onClick={e=>triggerClick(e,"setCurrent")}
|
|
177
192
|
//enter和leave事件,用于控制图的提示框
|
|
178
193
|
onMouseEnter={() => {
|
|
179
194
|
if(isControlChart){
|
|
@@ -205,8 +220,8 @@ export default memo(
|
|
|
205
220
|
}}
|
|
206
221
|
data-data={JSON.stringify(data)}
|
|
207
222
|
>
|
|
208
|
-
{headUrl && showHead && (
|
|
209
|
-
|
|
223
|
+
{(headUrl || headVideo) && showHead && (
|
|
224
|
+
headType=="image"?<div
|
|
210
225
|
style={{
|
|
211
226
|
position: "absolute",
|
|
212
227
|
background: `url(${
|
|
@@ -220,7 +235,22 @@ export default memo(
|
|
|
220
235
|
zIndex: 1,
|
|
221
236
|
transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
|
|
222
237
|
}}
|
|
223
|
-
></div
|
|
238
|
+
></div>:<video
|
|
239
|
+
width={headWidth} height={headHeight}
|
|
240
|
+
//@ts-ignore
|
|
241
|
+
src={window.appConfig.ASSETS_URL + headVideo}
|
|
242
|
+
// controls={true}
|
|
243
|
+
loop={true}
|
|
244
|
+
muted={true}
|
|
245
|
+
autoPlay={true}
|
|
246
|
+
style={{
|
|
247
|
+
position: "absolute",
|
|
248
|
+
left: isVertical ? "100%" : "50%",
|
|
249
|
+
top: isVertical ? "50%" : "0",
|
|
250
|
+
zIndex: 1,
|
|
251
|
+
transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
|
|
252
|
+
}}
|
|
253
|
+
></video>
|
|
224
254
|
)}
|
|
225
255
|
<div
|
|
226
256
|
style={{
|
|
@@ -234,7 +264,8 @@ export default memo(
|
|
|
234
264
|
fillType == "pattern"
|
|
235
265
|
? `50% 50% / ${size.width}px ${size.height}px repeat ` +
|
|
236
266
|
"url(" +
|
|
237
|
-
|
|
267
|
+
//@ts-ignore
|
|
268
|
+
window.appConfig.ASSETS_URL + url +
|
|
238
269
|
")"
|
|
239
270
|
: getBandBackground(
|
|
240
271
|
pattern,
|
|
@@ -43,6 +43,7 @@ const Chart = memo(
|
|
|
43
43
|
margin: { marginLeft, marginTop, marginRight, marginBottom },
|
|
44
44
|
animation,
|
|
45
45
|
legend,
|
|
46
|
+
selectStyle
|
|
46
47
|
},
|
|
47
48
|
series,
|
|
48
49
|
bandLength,
|
|
@@ -68,6 +69,7 @@ const Chart = memo(
|
|
|
68
69
|
}) => {
|
|
69
70
|
const context = useContext(chartContext);
|
|
70
71
|
const [isHover, setIsHover] = useState(false);
|
|
72
|
+
const [curXLabel, setCurXLabel] = useState("");
|
|
71
73
|
const {
|
|
72
74
|
isIOS,
|
|
73
75
|
width: chartWidth,
|
|
@@ -75,6 +77,7 @@ const Chart = memo(
|
|
|
75
77
|
triggerOnRelative,
|
|
76
78
|
onEmit,
|
|
77
79
|
} = context;
|
|
80
|
+
const defaultSelected = selectStyle?selectStyle.defaultSelected:"";
|
|
78
81
|
const xLineRange = chartWidth;
|
|
79
82
|
let yLineRange = chartHeight;
|
|
80
83
|
//获取控制条相关的参数
|
|
@@ -121,6 +124,19 @@ const Chart = memo(
|
|
|
121
124
|
controlInfo,
|
|
122
125
|
active
|
|
123
126
|
);
|
|
127
|
+
useEffect(()=>{
|
|
128
|
+
const handleAction=(e)=>{
|
|
129
|
+
const { dynamicData } = e;
|
|
130
|
+
setCurXLabel(dynamicData);
|
|
131
|
+
}
|
|
132
|
+
document.addEventListener(`setCurrent_${id}`,handleAction,false);
|
|
133
|
+
return ()=>{
|
|
134
|
+
document.removeEventListener(`setCurent_${id}`,handleAction);
|
|
135
|
+
}
|
|
136
|
+
},[]);
|
|
137
|
+
useEffect(()=>{
|
|
138
|
+
setCurXLabel(defaultSelected);
|
|
139
|
+
},[defaultSelected]);
|
|
124
140
|
useEffect(()=>{
|
|
125
141
|
if(aiData.length){
|
|
126
142
|
if(!window.aiData){
|
|
@@ -177,10 +193,13 @@ const Chart = memo(
|
|
|
177
193
|
};
|
|
178
194
|
|
|
179
195
|
const onInteraction = useCallback(
|
|
180
|
-
(e) => {
|
|
196
|
+
(e,type) => {
|
|
181
197
|
e.stopPropagation();
|
|
182
198
|
const { data } = e.currentTarget.dataset;
|
|
183
199
|
const _data = JSON.parse(data);
|
|
200
|
+
if(type=="setCurrent"){
|
|
201
|
+
setCurXLabel(_data.x);
|
|
202
|
+
}
|
|
184
203
|
triggerOnRelative('click',_data);
|
|
185
204
|
onEmit("click", _data);
|
|
186
205
|
},
|
|
@@ -461,6 +480,8 @@ const Chart = memo(
|
|
|
461
480
|
key={index}
|
|
462
481
|
{...config}
|
|
463
482
|
bandLength={bandLength}
|
|
483
|
+
curXLabel={curXLabel}
|
|
484
|
+
selectStyle={selectStyle}
|
|
464
485
|
xAxis={axisX}
|
|
465
486
|
yAxis={yAxis}
|
|
466
487
|
// 控制图部分,主要是为了,当鼠标悬浮在指示器上时,显示对应的tooltip
|
|
@@ -480,6 +501,8 @@ const Chart = memo(
|
|
|
480
501
|
<Label
|
|
481
502
|
key={index}
|
|
482
503
|
{...config}
|
|
504
|
+
curXLabel={curXLabel}
|
|
505
|
+
selectStyle={selectStyle}
|
|
483
506
|
bandLength={bandLength}
|
|
484
507
|
xAxis={axisX}
|
|
485
508
|
yAxis={yAxis}
|
package/src/components/Label.js
CHANGED
|
@@ -10,21 +10,32 @@ export default memo(
|
|
|
10
10
|
config: {
|
|
11
11
|
seriesIntervalWidth: paddingInner = 0,
|
|
12
12
|
paddingInner: paddingOuter = 0,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
showType:seriesType = 'bar',
|
|
14
|
+
...other
|
|
15
15
|
},
|
|
16
16
|
config,
|
|
17
|
+
curXLabel,
|
|
18
|
+
selectStyle,
|
|
17
19
|
bandLength = 0,
|
|
18
20
|
data,
|
|
19
21
|
xAxis: { scaler: xScaler, step, direction },
|
|
20
22
|
yAxis: { scaler: yScaler, isClipAxis, clipValue },
|
|
21
23
|
triggerClick
|
|
22
24
|
}) => {
|
|
25
|
+
let selectConfig = other;
|
|
26
|
+
if(selectStyle){
|
|
27
|
+
const { show, showType, icon, numlabel:label } = selectStyle;
|
|
28
|
+
if(show && seriesType==showType){
|
|
29
|
+
if(showType=="bar"){
|
|
30
|
+
selectConfig = { label };
|
|
31
|
+
}else{
|
|
32
|
+
selectConfig = { icon, label };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
23
36
|
const lineType = config.hasOwnProperty("line"); // 堆叠处理
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (!(data.length && (showIcon || showLabel))) return null;
|
|
37
|
+
|
|
38
|
+
if (!data.length) return null;
|
|
28
39
|
const { width, height } = useContext(chartContext);
|
|
29
40
|
|
|
30
41
|
const { seriesStep, seriesWidth, seriesStart } = getSeriesInfo({
|
|
@@ -34,7 +45,7 @@ export default memo(
|
|
|
34
45
|
paddingOuter,
|
|
35
46
|
});
|
|
36
47
|
const isVertical = direction === "vertical";
|
|
37
|
-
|
|
48
|
+
|
|
38
49
|
return (
|
|
39
50
|
<g className="__easyv-label">
|
|
40
51
|
{data.map(
|
|
@@ -43,6 +54,10 @@ export default memo(
|
|
|
43
54
|
i
|
|
44
55
|
) => {
|
|
45
56
|
let y1, y2;
|
|
57
|
+
const { icon, label } = x==curXLabel?selectConfig:other;
|
|
58
|
+
const showIcon = icon && icon.show;
|
|
59
|
+
const showLabel = label && label.show;
|
|
60
|
+
const { position:_position, reverse } = label;
|
|
46
61
|
if (isClipAxis) {
|
|
47
62
|
if (end > +clipValue) {
|
|
48
63
|
y1 = yScaler[1](start);
|
|
@@ -98,7 +113,7 @@ export default memo(
|
|
|
98
113
|
return (
|
|
99
114
|
<g
|
|
100
115
|
key={i}
|
|
101
|
-
onClick={triggerClick}
|
|
116
|
+
onClick={e=>triggerClick(e,"setCurrent")}
|
|
102
117
|
style={{ cursor: "pointer" }}
|
|
103
118
|
data-data={JSON.stringify(data)}
|
|
104
119
|
>
|
|
@@ -140,7 +155,7 @@ const Label = ({
|
|
|
140
155
|
})}
|
|
141
156
|
textAnchor={textAnchor}
|
|
142
157
|
dominantBaseline={dominantBaseline}
|
|
143
|
-
{
|
|
158
|
+
style={getFontStyle(font)}
|
|
144
159
|
>
|
|
145
160
|
<tspan>{value}</tspan>
|
|
146
161
|
<tspan dx={suffixX} dy={suffixY} style={{
|
package/.husky/commit-msg
DELETED