@easyv/charts 1.4.22 → 1.4.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.
- package/lib/components/Axis.js +27 -12
- package/lib/components/Band.js +42 -2
- package/lib/components/CartesianChart.js +254 -27
- package/lib/components/ChartContainer.js +3 -2
- package/lib/components/Control.js +81 -0
- package/lib/components/Indicator.js +66 -5
- package/lib/components/Label.js +41 -1
- package/lib/components/Marquee.js +1 -1
- package/lib/components/index.js +8 -0
- package/lib/hooks/useAxes.js +5 -1
- package/lib/hooks/useCarouselAxisX.js +24 -12
- package/lib/hooks/useTooltip.js +1 -1
- package/package.json +1 -1
- package/src/components/Axis.tsx +223 -183
- package/src/components/Band.tsx +40 -5
- package/src/components/CartesianChart.js +319 -43
- package/src/components/ChartContainer.tsx +15 -8
- package/src/components/Control.jsx +51 -0
- package/src/components/Indicator.js +58 -10
- package/src/components/Label.js +33 -0
- package/src/components/Marquee.tsx +1 -1
- package/src/components/index.js +2 -0
- package/src/hooks/useAxes.js +9 -2
- package/src/hooks/useCarouselAxisX.js +35 -18
- package/src/hooks/useTooltip.ts +18 -18
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports["default"] = void 0;
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
11
18
|
var _default = function _default(_ref) {
|
|
12
19
|
var color = _ref.color,
|
|
13
20
|
height = _ref.height,
|
|
@@ -15,13 +22,67 @@ var _default = function _default(_ref) {
|
|
|
15
22
|
_ref$x = _ref.x,
|
|
16
23
|
x = _ref$x === void 0 ? 0 : _ref$x,
|
|
17
24
|
_ref$y = _ref.y,
|
|
18
|
-
y = _ref$y === void 0 ? 0 : _ref$y
|
|
25
|
+
y = _ref$y === void 0 ? 0 : _ref$y,
|
|
26
|
+
_ref$isControlChart = _ref.isControlChart,
|
|
27
|
+
isControlChart = _ref$isControlChart === void 0 ? false : _ref$isControlChart,
|
|
28
|
+
_ref$xName = _ref.xName,
|
|
29
|
+
xName = _ref$xName === void 0 ? null : _ref$xName,
|
|
30
|
+
_ref$setControlChartT = _ref.setControlChartTooltipShow,
|
|
31
|
+
setControlChartTooltipShow = _ref$setControlChartT === void 0 ? null : _ref$setControlChartT,
|
|
32
|
+
_ref$setControlChartT2 = _ref.setControlChartTooltipXName,
|
|
33
|
+
setControlChartTooltipXName = _ref$setControlChartT2 === void 0 ? null : _ref$setControlChartT2,
|
|
34
|
+
_ref$setControlChartT3 = _ref.setControlChartTooltipX,
|
|
35
|
+
setControlChartTooltipX = _ref$setControlChartT3 === void 0 ? null : _ref$setControlChartT3,
|
|
36
|
+
_ref$setControlChartI = _ref.setControlChartIndicatorList,
|
|
37
|
+
setControlChartIndicatorList = _ref$setControlChartI === void 0 ? null : _ref$setControlChartI,
|
|
38
|
+
_ref$controlChartIndi = _ref.controlChartIndicatorList,
|
|
39
|
+
controlChartIndicatorList = _ref$controlChartIndi === void 0 ? null : _ref$controlChartIndi;
|
|
40
|
+
var isShow = true;
|
|
41
|
+
|
|
42
|
+
if (isControlChart && controlChartIndicatorList) {
|
|
43
|
+
isShow = controlChartIndicatorList.find(function (item) {
|
|
44
|
+
return item.tick === xName;
|
|
45
|
+
}).isShow;
|
|
46
|
+
}
|
|
47
|
+
|
|
19
48
|
return /*#__PURE__*/React.createElement("rect", {
|
|
20
49
|
width: width,
|
|
21
50
|
height: height,
|
|
22
51
|
x: x,
|
|
52
|
+
onMouseEnter: function onMouseEnter() {
|
|
53
|
+
if (isControlChart) {
|
|
54
|
+
setControlChartIndicatorList(function (v) {
|
|
55
|
+
return v.map(function (item) {
|
|
56
|
+
if (item.tick === xName) {
|
|
57
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
58
|
+
isShow: true
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
return item;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
setControlChartTooltipShow(true);
|
|
66
|
+
setControlChartTooltipXName(xName);
|
|
67
|
+
setControlChartTooltipX(x);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
onMouseLeave: function onMouseLeave() {
|
|
71
|
+
if (isControlChart) {
|
|
72
|
+
setControlChartIndicatorList(function (v) {
|
|
73
|
+
return v.map(function (item) {
|
|
74
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
75
|
+
isShow: false
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
setControlChartTooltipShow(false);
|
|
80
|
+
setControlChartTooltipXName(undefined);
|
|
81
|
+
setControlChartTooltipX(undefined);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
fill: isShow ? color : "transparent",
|
|
23
85
|
y: y,
|
|
24
|
-
fill: color,
|
|
25
86
|
stroke: "none"
|
|
26
87
|
});
|
|
27
88
|
};
|
package/lib/components/Label.js
CHANGED
|
@@ -43,7 +43,15 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
43
43
|
yScaler = _ref$yAxis.scaler,
|
|
44
44
|
isClipAxis = _ref$yAxis.isClipAxis,
|
|
45
45
|
clipValue = _ref$yAxis.clipValue,
|
|
46
|
-
triggerClick = _ref.triggerClick
|
|
46
|
+
triggerClick = _ref.triggerClick,
|
|
47
|
+
indicatorWidth = _ref.indicatorWidth,
|
|
48
|
+
setControlChartTooltipShow = _ref.setControlChartTooltipShow,
|
|
49
|
+
setControlChartTooltipX = _ref.setControlChartTooltipX,
|
|
50
|
+
setControlChartTooltipXName = _ref.setControlChartTooltipXName,
|
|
51
|
+
_ref$isControlChart = _ref.isControlChart,
|
|
52
|
+
isControlChart = _ref$isControlChart === void 0 ? false : _ref$isControlChart,
|
|
53
|
+
_ref$setControlChartI = _ref.setControlChartIndicatorList,
|
|
54
|
+
setControlChartIndicatorList = _ref$setControlChartI === void 0 ? null : _ref$setControlChartI;
|
|
47
55
|
var lineType = config.hasOwnProperty("line"); // 堆叠处理
|
|
48
56
|
|
|
49
57
|
var showIcon = icon && icon.show;
|
|
@@ -123,6 +131,38 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
123
131
|
return /*#__PURE__*/React.createElement("g", {
|
|
124
132
|
key: i,
|
|
125
133
|
onClick: triggerClick,
|
|
134
|
+
onMouseEnter: function onMouseEnter() {
|
|
135
|
+
if (isControlChart) {
|
|
136
|
+
setControlChartIndicatorList(function (v) {
|
|
137
|
+
return v.map(function (item) {
|
|
138
|
+
if (item.tick === data.x) {
|
|
139
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
140
|
+
isShow: true
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
return item;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
setControlChartTooltipShow(true);
|
|
148
|
+
setControlChartTooltipX(xScaler(x) - indicatorWidth / 2);
|
|
149
|
+
setControlChartTooltipXName(data.x);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
onMouseLeave: function onMouseLeave() {
|
|
153
|
+
if (isControlChart) {
|
|
154
|
+
setControlChartIndicatorList(function (v) {
|
|
155
|
+
return v.map(function (item) {
|
|
156
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
157
|
+
isShow: false
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
setControlChartTooltipShow(false);
|
|
162
|
+
setControlChartTooltipXName(undefined);
|
|
163
|
+
setControlChartTooltipX(undefined);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
126
166
|
style: {
|
|
127
167
|
cursor: "pointer"
|
|
128
168
|
},
|
|
@@ -58,7 +58,7 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
|
|
|
58
58
|
observe.current = new IntersectionObserver(function (entries) {
|
|
59
59
|
var entrie = entries[0];
|
|
60
60
|
|
|
61
|
-
if (entrie.boundingClientRect.width
|
|
61
|
+
if (entrie.boundingClientRect.width <= entrie.rootBounds.width) {
|
|
62
62
|
//表示文字全部可视
|
|
63
63
|
cancelAnimationFrame(timer.current || 0);
|
|
64
64
|
target.current.style.transform = "translate(0px,0px)"; //重置偏移
|
package/lib/components/index.js
CHANGED
|
@@ -72,6 +72,12 @@ Object.defineProperty(exports, "ConicalGradient", {
|
|
|
72
72
|
return _ConicalGradient["default"];
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
+
Object.defineProperty(exports, "Control", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function get() {
|
|
78
|
+
return _Control["default"];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
75
81
|
Object.defineProperty(exports, "ExtentData", {
|
|
76
82
|
enumerable: true,
|
|
77
83
|
get: function get() {
|
|
@@ -207,5 +213,7 @@ var _TextOverflow = _interopRequireDefault(require("./TextOverflow"));
|
|
|
207
213
|
|
|
208
214
|
var _BaseLine = _interopRequireDefault(require("./BaseLine"));
|
|
209
215
|
|
|
216
|
+
var _Control = _interopRequireDefault(require("./Control"));
|
|
217
|
+
|
|
210
218
|
var Area = _Line["default"];
|
|
211
219
|
exports.Area = Area;
|
package/lib/hooks/useAxes.js
CHANGED
|
@@ -88,7 +88,9 @@ var _default = function _default(_ref) {
|
|
|
88
88
|
var axes = _ref.axes,
|
|
89
89
|
_ref$context = _ref.context,
|
|
90
90
|
width = _ref$context.width,
|
|
91
|
-
height = _ref$context.height
|
|
91
|
+
height = _ref$context.height,
|
|
92
|
+
isControlChart = _ref.isControlChart,
|
|
93
|
+
controlConfig = _ref.control;
|
|
92
94
|
|
|
93
95
|
var _axes = (0, _react.useMemo)(function () {
|
|
94
96
|
var tmp = new Map();
|
|
@@ -364,7 +366,9 @@ var _default = function _default(_ref) {
|
|
|
364
366
|
tmp.set(axisType, _objectSpread(_objectSpread({}, item), {}, {
|
|
365
367
|
count: _count,
|
|
366
368
|
isClipAxis: _isClipAxis,
|
|
369
|
+
range: range,
|
|
367
370
|
scaler: scaler,
|
|
371
|
+
domain: domain,
|
|
368
372
|
length: _length,
|
|
369
373
|
direction: _direction,
|
|
370
374
|
start: _start,
|
|
@@ -34,6 +34,8 @@ var initialState = {
|
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
var _default = function _default(axis, config, isHover) {
|
|
37
|
+
var isControlChart = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
38
|
+
var controlConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
37
39
|
var show = config.show,
|
|
38
40
|
interval = config.interval,
|
|
39
41
|
duration = config.duration,
|
|
@@ -49,6 +51,10 @@ var _default = function _default(axis, config, isHover) {
|
|
|
49
51
|
lengthWithoutPaddingOuter = axis.lengthWithoutPaddingOuter;
|
|
50
52
|
var tickLength = ticks.length;
|
|
51
53
|
|
|
54
|
+
var _end = isControlChart && controlConfig ? end * (1 / (controlConfig.drag.width / 100)) : end;
|
|
55
|
+
|
|
56
|
+
var controlDragScaler = scaler.copy().range([start, end]);
|
|
57
|
+
|
|
52
58
|
var _useState = (0, _react.useState)({
|
|
53
59
|
scaler: scaler,
|
|
54
60
|
step: step,
|
|
@@ -107,7 +113,7 @@ var _default = function _default(axis, config, isHover) {
|
|
|
107
113
|
setState({
|
|
108
114
|
step: _step,
|
|
109
115
|
ticks: _ticks,
|
|
110
|
-
scaler: scaler.copy().domain(_ticks).range([start,
|
|
116
|
+
scaler: scaler.copy().domain(_ticks).range([start, _end])
|
|
111
117
|
});
|
|
112
118
|
} else {
|
|
113
119
|
animation = (0, _popmotion.animate)({
|
|
@@ -127,7 +133,7 @@ var _default = function _default(axis, config, isHover) {
|
|
|
127
133
|
|
|
128
134
|
return _objectSpread(_objectSpread({}, axis), {}, {
|
|
129
135
|
ticks: _ticks,
|
|
130
|
-
scaler: scaler.copy().range([start,
|
|
136
|
+
scaler: scaler.copy().range([start, _end + _step]).domain(_ticks)
|
|
131
137
|
});
|
|
132
138
|
});
|
|
133
139
|
},
|
|
@@ -136,7 +142,7 @@ var _default = function _default(axis, config, isHover) {
|
|
|
136
142
|
var scaler = axis.scaler,
|
|
137
143
|
step = axis.step;
|
|
138
144
|
return _objectSpread(_objectSpread({}, axis), {}, {
|
|
139
|
-
scaler: scaler.copy().range([start + step * v,
|
|
145
|
+
scaler: scaler.copy().range([start + step * v, _end + step + step * v])
|
|
140
146
|
});
|
|
141
147
|
});
|
|
142
148
|
},
|
|
@@ -149,18 +155,18 @@ var _default = function _default(axis, config, isHover) {
|
|
|
149
155
|
|
|
150
156
|
return _objectSpread(_objectSpread({}, axis), {}, {
|
|
151
157
|
ticks: _ticks,
|
|
152
|
-
scaler: scaler.copy().range([start,
|
|
158
|
+
scaler: scaler.copy().range([start, _end]).domain(_ticks)
|
|
153
159
|
});
|
|
154
160
|
});
|
|
155
161
|
}
|
|
156
162
|
});
|
|
157
163
|
}
|
|
158
164
|
} else {
|
|
159
|
-
var _ticks3 = scaler.type ==
|
|
165
|
+
var _ticks3 = scaler.type == "linear" ? scaler.domain() : allTicks;
|
|
160
166
|
|
|
161
167
|
setState({
|
|
162
168
|
step: step,
|
|
163
|
-
scaler: scaler.copy().domain(_ticks3).range([start,
|
|
169
|
+
scaler: scaler.copy().domain(_ticks3).range([start, _end]),
|
|
164
170
|
ticks: ticks
|
|
165
171
|
});
|
|
166
172
|
}
|
|
@@ -168,8 +174,13 @@ var _default = function _default(axis, config, isHover) {
|
|
|
168
174
|
return function () {
|
|
169
175
|
animation && animation.stop();
|
|
170
176
|
};
|
|
171
|
-
}, [tickCount, allTicks, scaler, start,
|
|
172
|
-
return _objectSpread(_objectSpread({}, axis), state)
|
|
177
|
+
}, [tickCount, allTicks, scaler, start, _end, step, ticks, lengthWithoutPaddingOuter, status, duration]);
|
|
178
|
+
return _objectSpread(_objectSpread(_objectSpread({}, axis), state), {}, {
|
|
179
|
+
rawTicks: axis.ticks,
|
|
180
|
+
controlDragScaler: controlDragScaler,
|
|
181
|
+
controlEnd: _end,
|
|
182
|
+
isControlChart: isControlChart
|
|
183
|
+
});
|
|
173
184
|
};
|
|
174
185
|
|
|
175
186
|
exports["default"] = _default;
|
|
@@ -179,13 +190,14 @@ var getTicks = function getTicks(ticks, currentIndex, length) {
|
|
|
179
190
|
|
|
180
191
|
var ticksLength = ticks.length;
|
|
181
192
|
if (ticksLength <= length) return ticks;
|
|
182
|
-
var end = _currentIndex + length;
|
|
183
193
|
|
|
184
|
-
|
|
194
|
+
var _end = _currentIndex + length;
|
|
195
|
+
|
|
196
|
+
if (ticksLength < _end) {
|
|
185
197
|
var prev = ticks.slice(_currentIndex, ticksLength);
|
|
186
|
-
var next = ticks.slice(0,
|
|
198
|
+
var next = ticks.slice(0, _end - ticksLength);
|
|
187
199
|
return [].concat((0, _toConsumableArray2["default"])(prev), (0, _toConsumableArray2["default"])(next));
|
|
188
200
|
}
|
|
189
201
|
|
|
190
|
-
return ticks.slice(_currentIndex,
|
|
202
|
+
return ticks.slice(_currentIndex, _end);
|
|
191
203
|
};
|
package/lib/hooks/useTooltip.js
CHANGED
|
@@ -72,7 +72,7 @@ var _default = function _default(_ref) {
|
|
|
72
72
|
var y = resetY - marginTop;
|
|
73
73
|
|
|
74
74
|
if (x > 0 && x < width && y > 0 && y < height && _ticks.length) {
|
|
75
|
-
var position = direction ===
|
|
75
|
+
var position = direction === "vertical" ? y : x;
|
|
76
76
|
|
|
77
77
|
var _name = _ticks.reduce(function (prev, current) {
|
|
78
78
|
return Math.abs(scaler(prev) - position) > Math.abs(scaler(current) - position) ? current : prev;
|