@easyv/charts 1.6.16 → 1.6.18
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/Band.js +35 -12
- package/lib/components/CartesianChart.js +37 -9
- package/lib/components/Label.js +103 -71
- package/package.json +1 -1
- package/src/components/Band.tsx +27 -12
- package/src/components/CartesianChart.js +26 -1
- package/src/components/Label.js +24 -9
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
170
|
var showHead, headType, headUrl, headVideo, headWidth, headHeight, headTranslate;
|
|
153
171
|
if (headDecorate) {
|
|
154
|
-
showHead = headDecorate.show, headType = headDecorate.
|
|
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() {
|
|
@@ -245,6 +265,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
245
265
|
src: window.appConfig.ASSETS_URL + headVideo
|
|
246
266
|
// controls={true}
|
|
247
267
|
,
|
|
268
|
+
loop: true,
|
|
248
269
|
muted: true,
|
|
249
270
|
autoPlay: true,
|
|
250
271
|
style: {
|
|
@@ -262,7 +283,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
262
283
|
// position: "fixed",
|
|
263
284
|
clipPath: setClipPath(),
|
|
264
285
|
opacity: fillType == "pattern" ? opacity : 1,
|
|
265
|
-
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),
|
|
266
289
|
borderRadius: style == "square" ? "0 0 0 0" : getBorderRadius({
|
|
267
290
|
isVertical: isVertical,
|
|
268
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,15 @@ 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(function (pre) {
|
|
211
|
+
return pre == _data.x ? "" : _data.x;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
190
214
|
triggerOnRelative('click', _data);
|
|
191
215
|
onEmit("click", _data);
|
|
192
216
|
}, [triggerOnRelative, onEmit]);
|
|
@@ -347,10 +371,10 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
347
371
|
})
|
|
348
372
|
};
|
|
349
373
|
};
|
|
350
|
-
var
|
|
351
|
-
|
|
352
|
-
ctlTip =
|
|
353
|
-
setCtlTip =
|
|
374
|
+
var _useState7 = (0, _react.useState)(initCtlTip),
|
|
375
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
376
|
+
ctlTip = _useState8[0],
|
|
377
|
+
setCtlTip = _useState8[1];
|
|
354
378
|
var showCtl = ctlTip.show,
|
|
355
379
|
ctlXName = ctlTip.xName,
|
|
356
380
|
ctlX = ctlTip.x,
|
|
@@ -454,6 +478,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
454
478
|
key: index
|
|
455
479
|
}, config, {
|
|
456
480
|
bandLength: bandLength,
|
|
481
|
+
curXLabel: curXLabel,
|
|
482
|
+
selectStyle: selectStyle,
|
|
457
483
|
xAxis: axisX,
|
|
458
484
|
yAxis: yAxis
|
|
459
485
|
// 控制图部分,主要是为了,当鼠标悬浮在指示器上时,显示对应的tooltip
|
|
@@ -471,6 +497,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
471
497
|
return yAxis && /*#__PURE__*/_react["default"].createElement(_.Label, (0, _extends2["default"])({
|
|
472
498
|
key: index
|
|
473
499
|
}, config, {
|
|
500
|
+
curXLabel: curXLabel,
|
|
501
|
+
selectStyle: selectStyle,
|
|
474
502
|
bandLength: bandLength,
|
|
475
503
|
xAxis: axisX,
|
|
476
504
|
yAxis: yAxis,
|
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: _objectSpread({}, 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":
|
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,12 +131,23 @@ 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
147
|
let showHead, headType, headUrl, headVideo, headWidth, headHeight, headTranslate;
|
|
135
148
|
if (headDecorate) {
|
|
136
149
|
(showHead = headDecorate.show),
|
|
137
|
-
(headType = headDecorate.
|
|
150
|
+
(headType = headDecorate.type),
|
|
138
151
|
(headUrl = headDecorate.url),
|
|
139
152
|
(headVideo = headDecorate.video),
|
|
140
153
|
(headWidth = headDecorate.size.width),
|
|
@@ -175,7 +188,7 @@ export default memo(
|
|
|
175
188
|
cursor: "pointer",
|
|
176
189
|
}}
|
|
177
190
|
{...attr}
|
|
178
|
-
onClick={triggerClick}
|
|
191
|
+
onClick={e=>triggerClick(e,"setCurrent")}
|
|
179
192
|
//enter和leave事件,用于控制图的提示框
|
|
180
193
|
onMouseEnter={() => {
|
|
181
194
|
if(isControlChart){
|
|
@@ -227,6 +240,7 @@ export default memo(
|
|
|
227
240
|
//@ts-ignore
|
|
228
241
|
src={window.appConfig.ASSETS_URL + headVideo}
|
|
229
242
|
// controls={true}
|
|
243
|
+
loop={true}
|
|
230
244
|
muted={true}
|
|
231
245
|
autoPlay={true}
|
|
232
246
|
style={{
|
|
@@ -250,7 +264,8 @@ export default memo(
|
|
|
250
264
|
fillType == "pattern"
|
|
251
265
|
? `50% 50% / ${size.width}px ${size.height}px repeat ` +
|
|
252
266
|
"url(" +
|
|
253
|
-
|
|
267
|
+
//@ts-ignore
|
|
268
|
+
window.appConfig.ASSETS_URL + url +
|
|
254
269
|
")"
|
|
255
270
|
: getBandBackground(
|
|
256
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,15 @@ 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(pre=>{
|
|
202
|
+
return pre==_data.x?"":_data.x;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
184
205
|
triggerOnRelative('click',_data);
|
|
185
206
|
onEmit("click", _data);
|
|
186
207
|
},
|
|
@@ -461,6 +482,8 @@ const Chart = memo(
|
|
|
461
482
|
key={index}
|
|
462
483
|
{...config}
|
|
463
484
|
bandLength={bandLength}
|
|
485
|
+
curXLabel={curXLabel}
|
|
486
|
+
selectStyle={selectStyle}
|
|
464
487
|
xAxis={axisX}
|
|
465
488
|
yAxis={yAxis}
|
|
466
489
|
// 控制图部分,主要是为了,当鼠标悬浮在指示器上时,显示对应的tooltip
|
|
@@ -480,6 +503,8 @@ const Chart = memo(
|
|
|
480
503
|
<Label
|
|
481
504
|
key={index}
|
|
482
505
|
{...config}
|
|
506
|
+
curXLabel={curXLabel}
|
|
507
|
+
selectStyle={selectStyle}
|
|
483
508
|
bandLength={bandLength}
|
|
484
509
|
xAxis={axisX}
|
|
485
510
|
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
|
-
{...font}
|
|
158
|
+
style={{...font}}
|
|
144
159
|
>
|
|
145
160
|
<tspan>{value}</tspan>
|
|
146
161
|
<tspan dx={suffixX} dy={suffixY} style={{
|