@easyv/charts 1.4.34 → 1.4.36
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 +7 -7
- package/lib/components/Band.js +28 -26
- package/lib/components/CartesianChart.js +208 -175
- package/lib/components/Control.js +78 -30
- package/lib/components/Indicator.js +30 -34
- package/lib/components/Label.js +1 -41
- package/lib/hooks/useAxes.js +43 -12
- package/lib/hooks/useCarouselAxisX.js +15 -16
- package/lib/hooks/useFilterData.js +21 -1
- package/package.json +1 -1
- package/src/components/Axis.tsx +6 -7
- package/src/components/Band.tsx +27 -34
- package/src/components/CartesianChart.js +186 -196
- package/src/components/Control.jsx +87 -43
- package/src/components/Indicator.js +17 -20
- package/src/components/Label.js +1 -34
- package/src/components/Tooltip.js +0 -1
- package/src/hooks/useAxes.js +34 -16
- package/src/hooks/useCarouselAxisX.js +14 -18
- package/src/hooks/useFilterData.js +7 -1
|
@@ -13,8 +13,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
13
|
|
|
14
14
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
15
|
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
17
|
|
|
20
18
|
var _d3Scale = require("d3-scale");
|
|
@@ -25,32 +23,80 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
23
|
|
|
26
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
25
|
|
|
28
|
-
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; }
|
|
29
|
-
|
|
30
|
-
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; }
|
|
31
|
-
|
|
32
26
|
var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
33
|
-
var _props$
|
|
34
|
-
|
|
27
|
+
var _props$actions = props.actions,
|
|
28
|
+
setX = _props$actions.setX,
|
|
29
|
+
setWorking = _props$actions.setWorking,
|
|
30
|
+
setControlInfo = _props$actions.setControlInfo,
|
|
31
|
+
_props$props = props.props,
|
|
32
|
+
_props$props$control = _props$props.control,
|
|
33
|
+
height = _props$props$control.height,
|
|
34
|
+
color = _props$props$control.color,
|
|
35
|
+
_props$props$control$ = _props$props$control.drag,
|
|
36
|
+
dragColor = _props$props$control$.color,
|
|
37
|
+
dragWidth = _props$props$control$.width,
|
|
38
|
+
_props$props$control$2 = _props$props$control.margin,
|
|
39
|
+
left = _props$props$control$2.left,
|
|
40
|
+
right = _props$props$control$2.right,
|
|
35
41
|
axes = _props$props.axes,
|
|
36
42
|
series = _props$props.series,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
marginTop = _props$props.marginTop,
|
|
40
|
-
axisX = _props$props.axisX,
|
|
43
|
+
width = _props$props.width,
|
|
44
|
+
top = _props$props.top,
|
|
41
45
|
bandLength = _props$props.bandLength;
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
var barWidth = width - left - right;
|
|
47
|
+
var xAxis = axes.get("x");
|
|
48
|
+
var barRef = (0, _react.useRef)();
|
|
49
|
+
var barStyle = {
|
|
50
|
+
position: "absolute",
|
|
51
|
+
top: 0,
|
|
52
|
+
width: barWidth * dragWidth / 100,
|
|
53
|
+
display: "flex",
|
|
54
|
+
justifyContent: "space-between",
|
|
55
|
+
background: dragColor
|
|
56
|
+
};
|
|
57
|
+
var dragStyle = {
|
|
58
|
+
height: height,
|
|
59
|
+
flex: 1,
|
|
60
|
+
cursor: "move"
|
|
61
|
+
};
|
|
62
|
+
var controllerStyle = {
|
|
63
|
+
position: "relative",
|
|
64
|
+
width: 12,
|
|
65
|
+
height: height,
|
|
66
|
+
padding: "0 5px",
|
|
67
|
+
cursor: "col-resize",
|
|
68
|
+
background: "rgb(2, 176, 249)",
|
|
69
|
+
WebkitBackgroundClip: "content-box"
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var down = function down() {
|
|
73
|
+
var transform = ref.current.style.transform;
|
|
74
|
+
var movementX = 0;
|
|
75
|
+
var rawTranslateX = parseFloat(transform ? transform.match(/\d+\.*\d*/)[0] : 0);
|
|
76
|
+
|
|
77
|
+
var mouseMoveHandle = function mouseMoveHandle(e) {
|
|
78
|
+
//当前位移的距离
|
|
79
|
+
movementX += e.movementX;
|
|
80
|
+
setX(movementX + rawTranslateX, true);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var mouseUpHandle = function mouseUpHandle(e) {
|
|
84
|
+
setWorking(false);
|
|
85
|
+
document.removeEventListener("mousemove", mouseMoveHandle);
|
|
86
|
+
document.removeEventListener("mouseup", mouseUpHandle);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
document.addEventListener("mousemove", mouseMoveHandle);
|
|
90
|
+
document.addEventListener("mouseup", mouseUpHandle);
|
|
91
|
+
setWorking(true);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
48
95
|
style: {
|
|
49
|
-
width:
|
|
50
|
-
height:
|
|
51
|
-
backgroundColor:
|
|
52
|
-
|
|
53
|
-
transform: "translateY(".concat(yLineRange + marginTop, "px)")
|
|
96
|
+
width: barWidth,
|
|
97
|
+
height: height,
|
|
98
|
+
backgroundColor: color,
|
|
99
|
+
transform: "translate(".concat(left, "px,").concat(top, "px)")
|
|
54
100
|
}
|
|
55
101
|
}, /*#__PURE__*/_react["default"].createElement("svg", {
|
|
56
102
|
width: "100%",
|
|
@@ -62,20 +108,22 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
|
|
|
62
108
|
var yAxis = axes.get(yOrZ);
|
|
63
109
|
var cloneYAxis = JSON.parse(JSON.stringify(yAxis)); //todo range
|
|
64
110
|
|
|
65
|
-
cloneYAxis.scaler = (0, _d3Scale.scaleLinear)().domain(yAxis.domain).range([
|
|
111
|
+
cloneYAxis.scaler = (0, _d3Scale.scaleLinear)().domain(yAxis.domain).range([height, 0]);
|
|
66
112
|
return yAxis && Component && /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({
|
|
67
113
|
key: index
|
|
68
114
|
}, config, {
|
|
69
115
|
bandLength: bandLength,
|
|
70
|
-
xAxis:
|
|
116
|
+
xAxis: xAxis,
|
|
71
117
|
yAxis: cloneYAxis
|
|
72
118
|
}));
|
|
73
|
-
}), /*#__PURE__*/_react["default"].createElement("
|
|
119
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
74
120
|
ref: ref,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
121
|
+
style: barStyle
|
|
122
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
123
|
+
style: dragStyle,
|
|
124
|
+
onMouseDown: down,
|
|
125
|
+
ref: barRef
|
|
126
|
+
})));
|
|
79
127
|
}));
|
|
80
128
|
|
|
81
129
|
exports["default"] = _default;
|
|
@@ -27,20 +27,12 @@ var _default = function _default(_ref) {
|
|
|
27
27
|
isControlChart = _ref$isControlChart === void 0 ? false : _ref$isControlChart,
|
|
28
28
|
_ref$xName = _ref.xName,
|
|
29
29
|
xName = _ref$xName === void 0 ? null : _ref$xName,
|
|
30
|
-
|
|
31
|
-
|
|
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;
|
|
30
|
+
ctlIndicatorList = _ref.ctlIndicatorList,
|
|
31
|
+
setCtlTip = _ref.setCtlTip;
|
|
40
32
|
var isShow = true;
|
|
41
33
|
|
|
42
|
-
if (isControlChart &&
|
|
43
|
-
isShow =
|
|
34
|
+
if (isControlChart && ctlIndicatorList) {
|
|
35
|
+
isShow = ctlIndicatorList.find(function (item) {
|
|
44
36
|
return item.tick === xName;
|
|
45
37
|
}).isShow;
|
|
46
38
|
}
|
|
@@ -51,34 +43,38 @@ var _default = function _default(_ref) {
|
|
|
51
43
|
x: x,
|
|
52
44
|
onMouseEnter: function onMouseEnter() {
|
|
53
45
|
if (isControlChart) {
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
46
|
+
setCtlTip(function (pre) {
|
|
47
|
+
return {
|
|
48
|
+
show: true,
|
|
49
|
+
x: x + width / 2,
|
|
50
|
+
xName: xName,
|
|
51
|
+
indicatorList: pre.indicatorList.map(function (item) {
|
|
52
|
+
if (item.tick === xName) {
|
|
53
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
54
|
+
isShow: true
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
return item;
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
};
|
|
64
61
|
});
|
|
65
|
-
setControlChartTooltipShow(true);
|
|
66
|
-
setControlChartTooltipXName(xName);
|
|
67
|
-
setControlChartTooltipX(x);
|
|
68
62
|
}
|
|
69
63
|
},
|
|
70
64
|
onMouseLeave: function onMouseLeave() {
|
|
71
65
|
if (isControlChart) {
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
setCtlTip(function (pre) {
|
|
67
|
+
return {
|
|
68
|
+
show: false,
|
|
69
|
+
x: undefined,
|
|
70
|
+
xName: undefined,
|
|
71
|
+
indicatorList: pre.indicatorList.map(function (item) {
|
|
72
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
73
|
+
isShow: false
|
|
74
|
+
});
|
|
75
|
+
})
|
|
76
|
+
};
|
|
78
77
|
});
|
|
79
|
-
setControlChartTooltipShow(false);
|
|
80
|
-
setControlChartTooltipXName(undefined);
|
|
81
|
-
setControlChartTooltipX(undefined);
|
|
82
78
|
}
|
|
83
79
|
},
|
|
84
80
|
fill: isShow ? color : "transparent",
|
package/lib/components/Label.js
CHANGED
|
@@ -43,15 +43,7 @@ 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
|
|
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;
|
|
46
|
+
triggerClick = _ref.triggerClick;
|
|
55
47
|
var lineType = config.hasOwnProperty("line"); // 堆叠处理
|
|
56
48
|
|
|
57
49
|
var showIcon = icon && icon.show;
|
|
@@ -131,38 +123,6 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
131
123
|
return /*#__PURE__*/React.createElement("g", {
|
|
132
124
|
key: i,
|
|
133
125
|
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
|
-
},
|
|
166
126
|
style: {
|
|
167
127
|
cursor: "pointer"
|
|
168
128
|
},
|
package/lib/hooks/useAxes.js
CHANGED
|
@@ -87,10 +87,15 @@ var scales = {
|
|
|
87
87
|
var _default = function _default(_ref) {
|
|
88
88
|
var axes = _ref.axes,
|
|
89
89
|
_ref$context = _ref.context,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
chartWidth = _ref$context.width,
|
|
91
|
+
chartHeight = _ref$context.height,
|
|
92
|
+
controlInfo = _ref.controlInfo;
|
|
93
|
+
var isC = controlInfo.isC,
|
|
94
|
+
cHeight = controlInfo.cHeight,
|
|
95
|
+
cWidth = controlInfo.cWidth,
|
|
96
|
+
cPercent = controlInfo.cPercent;
|
|
97
|
+
var width = chartWidth;
|
|
98
|
+
var height = chartHeight - cHeight;
|
|
94
99
|
|
|
95
100
|
var _axes = (0, _react.useMemo)(function () {
|
|
96
101
|
var tmp = new Map();
|
|
@@ -122,9 +127,7 @@ var _default = function _default(_ref) {
|
|
|
122
127
|
bottomClipAxisStep = item.bottomClipAxisStep,
|
|
123
128
|
topClipAxisStep = item.topClipAxisStep,
|
|
124
129
|
clipValue = item.clipValue,
|
|
125
|
-
clipPosition = item.clipPosition
|
|
126
|
-
clipDifferenceValue = item.clipDifferenceValue,
|
|
127
|
-
clipAxisMode = item.clipAxisMode; //如果是断轴类型,输出一套完全不同的values
|
|
130
|
+
clipPosition = item.clipPosition; //如果是断轴类型,输出一套完全不同的values
|
|
128
131
|
|
|
129
132
|
/**
|
|
130
133
|
* 获取轴的:朝向direction,起点位置start,终点位置end
|
|
@@ -132,7 +135,7 @@ var _default = function _default(_ref) {
|
|
|
132
135
|
* @param {*} width
|
|
133
136
|
* @param {*} height
|
|
134
137
|
* @param {*} paddingOuter
|
|
135
|
-
* @returns {start,end,direction}
|
|
138
|
+
* @returns { start, end, direction }
|
|
136
139
|
*/
|
|
137
140
|
|
|
138
141
|
function getChartsConfig(orientation, width, height, paddingOuter) {
|
|
@@ -323,10 +326,10 @@ var _default = function _default(_ref) {
|
|
|
323
326
|
if (type !== "ordinal") scaler.clamp(true); //scaler.nice().clamp(true)
|
|
324
327
|
|
|
325
328
|
var allTicks = ticks ? ticks : scaler.ticks ? scaler.ticks(tickCount) : scaler.domain();
|
|
326
|
-
var _ticks = allTicks;
|
|
329
|
+
var _ticks = allTicks;
|
|
327
330
|
|
|
328
331
|
if (type === "ordinal") {
|
|
329
|
-
if (carousel === false) {
|
|
332
|
+
if (carousel === false || isC) {
|
|
330
333
|
_ticks = (0, _utils.getTicksOfAxis)(_ticks, +tickCount, showLast);
|
|
331
334
|
}
|
|
332
335
|
} else {
|
|
@@ -363,7 +366,33 @@ var _default = function _default(_ref) {
|
|
|
363
366
|
}
|
|
364
367
|
}
|
|
365
368
|
|
|
366
|
-
|
|
369
|
+
var _step2 = _lengthWithoutPaddingOuter / allTicks.length;
|
|
370
|
+
|
|
371
|
+
var controlCfg = {
|
|
372
|
+
controlStep: 0,
|
|
373
|
+
controlDragScaler: null
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
if (isC) {
|
|
377
|
+
controlCfg.controlStep = _step2 / cPercent;
|
|
378
|
+
controlCfg.controlDragScaler = scaler.copy().range([_start / cPercent, _end / cPercent]);
|
|
379
|
+
|
|
380
|
+
var _getChartsConfig3 = getChartsConfig(orientation, cWidth, height, paddingOuter),
|
|
381
|
+
start_ = _getChartsConfig3.start,
|
|
382
|
+
end_ = _getChartsConfig3.end,
|
|
383
|
+
direction_ = _getChartsConfig3.direction,
|
|
384
|
+
outer = _getChartsConfig3._paddingOuter,
|
|
385
|
+
len = _getChartsConfig3.length;
|
|
386
|
+
|
|
387
|
+
var _range = direction_ === "horizontal" ? [start_, end_] : direction_ === "vertical" ? [end_, start_] : [0, 0];
|
|
388
|
+
|
|
389
|
+
scaler = scales[type]().domain(newDomain).range(_range);
|
|
390
|
+
scaler.type = type;
|
|
391
|
+
var controlOuter = len - outer;
|
|
392
|
+
_step2 = controlOuter / allTicks.length;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
tmp.set(axisType, _objectSpread(_objectSpread(_objectSpread({}, item), {}, {
|
|
367
396
|
count: _count,
|
|
368
397
|
isClipAxis: _isClipAxis,
|
|
369
398
|
range: range,
|
|
@@ -374,8 +403,10 @@ var _default = function _default(_ref) {
|
|
|
374
403
|
start: _start,
|
|
375
404
|
end: _end,
|
|
376
405
|
lengthWithoutPaddingOuter: _lengthWithoutPaddingOuter,
|
|
377
|
-
step:
|
|
406
|
+
step: _step2
|
|
407
|
+
}, controlCfg), {}, {
|
|
378
408
|
allTicks: allTicks,
|
|
409
|
+
rawTicks: _ticks,
|
|
379
410
|
ticks: _ticks
|
|
380
411
|
}));
|
|
381
412
|
}
|
|
@@ -33,15 +33,15 @@ var initialState = {
|
|
|
33
33
|
* @returns {Map} 返回经过改变后的x轴,主要是ticks和scaler的range发生了改变
|
|
34
34
|
*/
|
|
35
35
|
|
|
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;
|
|
36
|
+
var _default = function _default(axis, config, isHover, controlInfo) {
|
|
39
37
|
var show = config.show,
|
|
40
38
|
interval = config.interval,
|
|
41
39
|
duration = config.duration,
|
|
42
40
|
hover = config.hover;
|
|
41
|
+
var isC = controlInfo.isC,
|
|
42
|
+
cPercent = controlInfo.cPercent;
|
|
43
43
|
var time = duration + interval;
|
|
44
|
-
var
|
|
44
|
+
var count = axis.tickCount,
|
|
45
45
|
allTicks = axis.allTicks,
|
|
46
46
|
scaler = axis.scaler,
|
|
47
47
|
start = axis.start,
|
|
@@ -50,10 +50,12 @@ var _default = function _default(axis, config, isHover) {
|
|
|
50
50
|
ticks = axis.ticks,
|
|
51
51
|
lengthWithoutPaddingOuter = axis.lengthWithoutPaddingOuter;
|
|
52
52
|
var tickLength = ticks.length;
|
|
53
|
+
var tickCount = isC ? allTicks.length : count;
|
|
54
|
+
var scale = isC ? cPercent : 1;
|
|
53
55
|
|
|
54
|
-
var
|
|
56
|
+
var _start = start / scale;
|
|
55
57
|
|
|
56
|
-
var
|
|
58
|
+
var _end = end / scale;
|
|
57
59
|
|
|
58
60
|
var _useState = (0, _react.useState)({
|
|
59
61
|
scaler: scaler,
|
|
@@ -113,7 +115,7 @@ var _default = function _default(axis, config, isHover) {
|
|
|
113
115
|
setState({
|
|
114
116
|
step: _step,
|
|
115
117
|
ticks: _ticks,
|
|
116
|
-
scaler: scaler.copy().domain(_ticks).range([
|
|
118
|
+
scaler: scaler.copy().domain(_ticks).range([_start, _end])
|
|
117
119
|
});
|
|
118
120
|
} else {
|
|
119
121
|
animation = (0, _popmotion.animate)({
|
|
@@ -133,7 +135,7 @@ var _default = function _default(axis, config, isHover) {
|
|
|
133
135
|
|
|
134
136
|
return _objectSpread(_objectSpread({}, axis), {}, {
|
|
135
137
|
ticks: _ticks,
|
|
136
|
-
scaler: scaler.copy().range([
|
|
138
|
+
scaler: scaler.copy().range([_start, _end + _step]).domain(_ticks)
|
|
137
139
|
});
|
|
138
140
|
});
|
|
139
141
|
},
|
|
@@ -142,7 +144,7 @@ var _default = function _default(axis, config, isHover) {
|
|
|
142
144
|
var scaler = axis.scaler,
|
|
143
145
|
step = axis.step;
|
|
144
146
|
return _objectSpread(_objectSpread({}, axis), {}, {
|
|
145
|
-
scaler: scaler.copy().range([
|
|
147
|
+
scaler: scaler.copy().range([_start + step * v, _end + step + step * v])
|
|
146
148
|
});
|
|
147
149
|
});
|
|
148
150
|
},
|
|
@@ -155,7 +157,7 @@ var _default = function _default(axis, config, isHover) {
|
|
|
155
157
|
|
|
156
158
|
return _objectSpread(_objectSpread({}, axis), {}, {
|
|
157
159
|
ticks: _ticks,
|
|
158
|
-
scaler: scaler.copy().range([
|
|
160
|
+
scaler: scaler.copy().range([_start, _end]).domain(_ticks)
|
|
159
161
|
});
|
|
160
162
|
});
|
|
161
163
|
}
|
|
@@ -166,7 +168,7 @@ var _default = function _default(axis, config, isHover) {
|
|
|
166
168
|
|
|
167
169
|
setState({
|
|
168
170
|
step: step,
|
|
169
|
-
scaler: scaler.copy().domain(_ticks3).range([
|
|
171
|
+
scaler: scaler.copy().domain(_ticks3).range([_start, _end]),
|
|
170
172
|
ticks: ticks
|
|
171
173
|
});
|
|
172
174
|
}
|
|
@@ -174,12 +176,9 @@ var _default = function _default(axis, config, isHover) {
|
|
|
174
176
|
return function () {
|
|
175
177
|
animation && animation.stop();
|
|
176
178
|
};
|
|
177
|
-
}, [tickCount, allTicks, scaler,
|
|
179
|
+
}, [tickCount, allTicks, scaler, _start, _end, step, ticks, lengthWithoutPaddingOuter, status, duration]);
|
|
178
180
|
return _objectSpread(_objectSpread(_objectSpread({}, axis), state), {}, {
|
|
179
|
-
|
|
180
|
-
controlDragScaler: controlDragScaler,
|
|
181
|
-
controlEnd: _end,
|
|
182
|
-
isControlChart: isControlChart
|
|
181
|
+
controlEnd: _end
|
|
183
182
|
});
|
|
184
183
|
};
|
|
185
184
|
|
|
@@ -97,7 +97,27 @@ var _default = function _default(_ref) {
|
|
|
97
97
|
});
|
|
98
98
|
}, []);
|
|
99
99
|
(0, _react.useEffect)(function () {
|
|
100
|
-
|
|
100
|
+
var map = getInitialSelected(series);
|
|
101
|
+
|
|
102
|
+
var _iterator2 = _createForOfIteratorHelper(map.entries()),
|
|
103
|
+
_step2;
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
107
|
+
var _step2$value = (0, _slicedToArray2["default"])(_step2.value, 1),
|
|
108
|
+
key = _step2$value[0];
|
|
109
|
+
|
|
110
|
+
if (selected.has(key)) {
|
|
111
|
+
map.set(key, selected.get(key));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
_iterator2.e(err);
|
|
116
|
+
} finally {
|
|
117
|
+
_iterator2.f();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
setSelected(map);
|
|
101
121
|
}, [series]);
|
|
102
122
|
return [{
|
|
103
123
|
series: _series,
|
package/package.json
CHANGED
package/src/components/Axis.tsx
CHANGED
|
@@ -273,17 +273,16 @@ export default memo(
|
|
|
273
273
|
yLineRange,
|
|
274
274
|
clipAxisRange,
|
|
275
275
|
//控制图相关
|
|
276
|
-
|
|
277
|
-
controlConfig,
|
|
278
|
-
controlEnd,
|
|
276
|
+
controlInfo,
|
|
279
277
|
rawTicks,
|
|
280
278
|
}: any,
|
|
281
279
|
ref
|
|
282
280
|
) => {
|
|
283
281
|
if (!(on && ticks.length > 0)) return null;
|
|
284
282
|
const { width, height } = useContext(chartContext);
|
|
283
|
+
const { cHeight, isC } = controlInfo;
|
|
285
284
|
const x = orientation == "right" ? width : 0;
|
|
286
|
-
const y = orientation == "bottom" ? height : 0;
|
|
285
|
+
const y = orientation == "bottom" ? height-cHeight : 0;
|
|
287
286
|
|
|
288
287
|
function drawAxisTickLine() {
|
|
289
288
|
const draw = (ticks: any, scaler: any) => {
|
|
@@ -358,7 +357,7 @@ export default memo(
|
|
|
358
357
|
y1 < 0 ||
|
|
359
358
|
y1 > yLineRange
|
|
360
359
|
) ||
|
|
361
|
-
|
|
360
|
+
isC) && (
|
|
362
361
|
<g key={index}>
|
|
363
362
|
{label && (
|
|
364
363
|
<Label
|
|
@@ -393,7 +392,7 @@ export default memo(
|
|
|
393
392
|
})}
|
|
394
393
|
</>
|
|
395
394
|
);
|
|
396
|
-
} else if (
|
|
395
|
+
} else if (isC && orientation == "bottom") {
|
|
397
396
|
return <>{draw(rawTicks, scaler)}</>;
|
|
398
397
|
} else {
|
|
399
398
|
return <>{draw(ticks, scaler)}</>;
|
|
@@ -472,7 +471,7 @@ export default memo(
|
|
|
472
471
|
width={width}
|
|
473
472
|
style={{
|
|
474
473
|
overflow:
|
|
475
|
-
axisType === "x" &&
|
|
474
|
+
axisType === "x" && isC ? "hidden":"visible",
|
|
476
475
|
}}
|
|
477
476
|
>
|
|
478
477
|
<g transform={"translate(" + x + ", " + y + ")"}>
|