@easyv/charts 1.4.35 → 1.4.37
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 +47 -15
- package/lib/hooks/useCarouselAxisX.js +15 -16
- 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 +39 -21
- package/src/hooks/useCarouselAxisX.js +14 -18
|
@@ -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,16 +87,22 @@ 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();
|
|
97
102
|
var xAxisPositions = [];
|
|
98
103
|
axes.forEach(function (item) {
|
|
99
104
|
var _item$config$label = item.config.label,
|
|
105
|
+
extent = _item$config$label.extent,
|
|
100
106
|
_item$config$label$sh = _item$config$label.showLast,
|
|
101
107
|
showLast = _item$config$label$sh === void 0 ? false : _item$config$label$sh,
|
|
102
108
|
_item$config$label$de = _item$config$label.decimal,
|
|
@@ -122,9 +128,7 @@ var _default = function _default(_ref) {
|
|
|
122
128
|
bottomClipAxisStep = item.bottomClipAxisStep,
|
|
123
129
|
topClipAxisStep = item.topClipAxisStep,
|
|
124
130
|
clipValue = item.clipValue,
|
|
125
|
-
clipPosition = item.clipPosition
|
|
126
|
-
clipDifferenceValue = item.clipDifferenceValue,
|
|
127
|
-
clipAxisMode = item.clipAxisMode; //如果是断轴类型,输出一套完全不同的values
|
|
131
|
+
clipPosition = item.clipPosition; //如果是断轴类型,输出一套完全不同的values
|
|
128
132
|
|
|
129
133
|
/**
|
|
130
134
|
* 获取轴的:朝向direction,起点位置start,终点位置end
|
|
@@ -132,7 +136,7 @@ var _default = function _default(_ref) {
|
|
|
132
136
|
* @param {*} width
|
|
133
137
|
* @param {*} height
|
|
134
138
|
* @param {*} paddingOuter
|
|
135
|
-
* @returns {start,end,direction}
|
|
139
|
+
* @returns { start, end, direction }
|
|
136
140
|
*/
|
|
137
141
|
|
|
138
142
|
function getChartsConfig(orientation, width, height, paddingOuter) {
|
|
@@ -313,20 +317,20 @@ var _default = function _default(_ref) {
|
|
|
313
317
|
|
|
314
318
|
var range = _direction === "horizontal" ? [_start, _end] : _direction === "vertical" ? [_end, _start] : [0, 0];
|
|
315
319
|
var newDomain = domain;
|
|
320
|
+
var fixedDomain = extent && extent.min != "" && extent.max != ""; //判断配置项中是否强制了最大最小值,如果已经被强制了,就不计算newDomain
|
|
316
321
|
|
|
317
|
-
if (type !== "ordinal" && !isNaN(domain[1]) && !auto) {
|
|
322
|
+
if (type !== "ordinal" && !isNaN(domain[1]) && !auto && !fixedDomain) {
|
|
318
323
|
newDomain = getNewDomain(domain, mode, _step);
|
|
319
324
|
}
|
|
320
325
|
|
|
321
326
|
var scaler = scales[type]().domain(newDomain).range(range);
|
|
322
327
|
scaler.type = type;
|
|
323
|
-
if (type !== "ordinal") scaler.clamp(true);
|
|
324
|
-
|
|
328
|
+
if (type !== "ordinal") scaler.clamp(true);
|
|
325
329
|
var allTicks = ticks ? ticks : scaler.ticks ? scaler.ticks(tickCount) : scaler.domain();
|
|
326
|
-
var _ticks = allTicks;
|
|
330
|
+
var _ticks = allTicks;
|
|
327
331
|
|
|
328
332
|
if (type === "ordinal") {
|
|
329
|
-
if (carousel === false) {
|
|
333
|
+
if (carousel === false || isC) {
|
|
330
334
|
_ticks = (0, _utils.getTicksOfAxis)(_ticks, +tickCount, showLast);
|
|
331
335
|
}
|
|
332
336
|
} else {
|
|
@@ -363,7 +367,33 @@ var _default = function _default(_ref) {
|
|
|
363
367
|
}
|
|
364
368
|
}
|
|
365
369
|
|
|
366
|
-
|
|
370
|
+
var _step2 = _lengthWithoutPaddingOuter / allTicks.length;
|
|
371
|
+
|
|
372
|
+
var controlCfg = {
|
|
373
|
+
controlStep: 0,
|
|
374
|
+
controlDragScaler: null
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
if (isC) {
|
|
378
|
+
controlCfg.controlStep = _step2 / cPercent;
|
|
379
|
+
controlCfg.controlDragScaler = scaler.copy().range([_start / cPercent, _end / cPercent]);
|
|
380
|
+
|
|
381
|
+
var _getChartsConfig3 = getChartsConfig(orientation, cWidth, height, paddingOuter),
|
|
382
|
+
start_ = _getChartsConfig3.start,
|
|
383
|
+
end_ = _getChartsConfig3.end,
|
|
384
|
+
direction_ = _getChartsConfig3.direction,
|
|
385
|
+
outer = _getChartsConfig3._paddingOuter,
|
|
386
|
+
len = _getChartsConfig3.length;
|
|
387
|
+
|
|
388
|
+
var _range = direction_ === "horizontal" ? [start_, end_] : direction_ === "vertical" ? [end_, start_] : [0, 0];
|
|
389
|
+
|
|
390
|
+
scaler = scales[type]().domain(newDomain).range(_range);
|
|
391
|
+
scaler.type = type;
|
|
392
|
+
var controlOuter = len - outer;
|
|
393
|
+
_step2 = controlOuter / allTicks.length;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
tmp.set(axisType, _objectSpread(_objectSpread(_objectSpread({}, item), {}, {
|
|
367
397
|
count: _count,
|
|
368
398
|
isClipAxis: _isClipAxis,
|
|
369
399
|
range: range,
|
|
@@ -374,8 +404,10 @@ var _default = function _default(_ref) {
|
|
|
374
404
|
start: _start,
|
|
375
405
|
end: _end,
|
|
376
406
|
lengthWithoutPaddingOuter: _lengthWithoutPaddingOuter,
|
|
377
|
-
step:
|
|
407
|
+
step: _step2
|
|
408
|
+
}, controlCfg), {}, {
|
|
378
409
|
allTicks: allTicks,
|
|
410
|
+
rawTicks: _ticks,
|
|
379
411
|
ticks: _ticks
|
|
380
412
|
}));
|
|
381
413
|
}
|
|
@@ -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
|
|
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 + ")"}>
|
package/src/components/Band.tsx
CHANGED
|
@@ -69,12 +69,8 @@ export default memo(
|
|
|
69
69
|
//控制图部分,主要是为了控制图的指示器,在悬浮的时候显示
|
|
70
70
|
triggerClick,
|
|
71
71
|
indicatorWidth,
|
|
72
|
-
setControlChartTooltipShow,
|
|
73
|
-
setControlChartTooltipX,
|
|
74
|
-
setControlChartTooltipXName,
|
|
75
72
|
isControlChart = false,
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
setCtlTip,
|
|
78
74
|
config: {
|
|
79
75
|
pattern = {},
|
|
80
76
|
seriesIntervalWidth: paddingInner = 0,
|
|
@@ -91,12 +87,12 @@ export default memo(
|
|
|
91
87
|
},
|
|
92
88
|
bandLength = 0,
|
|
93
89
|
data,
|
|
94
|
-
xAxis: { scaler:
|
|
95
|
-
xAxis,
|
|
90
|
+
xAxis: { scaler: normalScaler, step:normalStep, controlStep, direction, controlDragScaler },
|
|
96
91
|
yAxis: { scaler: yScaler, isClipAxis, clipValue },
|
|
97
92
|
}: any) => {
|
|
98
93
|
if (!data.length) return null;
|
|
99
|
-
|
|
94
|
+
const step = isControlChart?controlStep:normalStep;
|
|
95
|
+
const xScaler = isControlChart?controlDragScaler:normalScaler;
|
|
100
96
|
const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
|
|
101
97
|
step,
|
|
102
98
|
bandLength,
|
|
@@ -105,7 +101,6 @@ export default memo(
|
|
|
105
101
|
});
|
|
106
102
|
|
|
107
103
|
const _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
108
|
-
|
|
109
104
|
const isVertical = direction === "vertical";
|
|
110
105
|
const borderStr = `${border.borderColor} solid ${border.borderWidth}px`;
|
|
111
106
|
return (
|
|
@@ -135,9 +130,7 @@ export default memo(
|
|
|
135
130
|
y1 = yScaler(isVertical ? end : start);
|
|
136
131
|
y2 = yScaler(isVertical ? start : end);
|
|
137
132
|
}
|
|
138
|
-
|
|
139
|
-
const positionX =
|
|
140
|
-
xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
133
|
+
const positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
141
134
|
|
|
142
135
|
let showHead, headUrl, headWidth, headHeight, headTranslate;
|
|
143
136
|
if (headDecorate) {
|
|
@@ -176,36 +169,35 @@ export default memo(
|
|
|
176
169
|
style={{
|
|
177
170
|
overflow: "visible",
|
|
178
171
|
position: "relative",
|
|
172
|
+
pointerEvents:isControlChart?"auto":"none",
|
|
179
173
|
cursor: "pointer",
|
|
180
174
|
}}
|
|
181
175
|
{...attr}
|
|
182
176
|
onClick={triggerClick}
|
|
183
177
|
//enter和leave事件,用于控制图的提示框
|
|
184
178
|
onMouseEnter={() => {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
setControlChartTooltipXName(data.x);
|
|
198
|
-
}
|
|
179
|
+
setCtlTip((pre:any)=>({
|
|
180
|
+
show:true,
|
|
181
|
+
x:xScaler(x),
|
|
182
|
+
xName:data.x,
|
|
183
|
+
indicatorList:pre.indicatorList.map((item:any)=>{
|
|
184
|
+
if (item.tick === data.x) {
|
|
185
|
+
return { ...item, isShow: true };
|
|
186
|
+
} else {
|
|
187
|
+
return item;
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
}))
|
|
199
191
|
}}
|
|
200
192
|
onMouseLeave={() => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
193
|
+
setCtlTip((pre:any)=>({
|
|
194
|
+
show:false,
|
|
195
|
+
x:undefined,
|
|
196
|
+
xName:undefined,
|
|
197
|
+
indicatorList:pre.indicatorList.map((item:any)=>{
|
|
198
|
+
return { ...item, isShow:false }
|
|
199
|
+
})
|
|
200
|
+
}))
|
|
209
201
|
}}
|
|
210
202
|
data-data={JSON.stringify(data)}
|
|
211
203
|
>
|
|
@@ -214,6 +206,7 @@ export default memo(
|
|
|
214
206
|
style={{
|
|
215
207
|
position: "absolute",
|
|
216
208
|
background: `url(${
|
|
209
|
+
//@ts-ignore
|
|
217
210
|
window.appConfig.ASSETS_URL + headUrl
|
|
218
211
|
}) 0 0/100% 100%`,
|
|
219
212
|
width: headWidth,
|