@easyv/charts 1.4.15 → 1.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/commit-msg +1 -1
- package/lib/components/Axis.js +139 -85
- package/lib/components/Band.js +50 -16
- package/lib/components/BaseLine.js +16 -5
- package/lib/components/CartesianChart.js +13 -13
- package/lib/components/Label.js +49 -33
- package/lib/components/TextOverflow.js +4 -1
- package/lib/hooks/useAxes.js +250 -61
- package/lib/hooks/useExtentData.js +44 -9
- package/package.json +55 -54
- package/src/components/Axis.tsx +246 -157
- package/src/components/Band.tsx +91 -56
- package/src/components/BaseLine.js +22 -5
- package/src/components/CartesianChart.js +7 -6
- package/src/components/Label.js +56 -46
- package/src/components/TextOverflow.tsx +4 -1
- package/src/hooks/useAxes.js +336 -117
- package/src/hooks/useExtentData.js +37 -10
package/.husky/commit-msg
CHANGED
package/lib/components/Axis.js
CHANGED
|
@@ -43,10 +43,10 @@ var defaultAppearance = {
|
|
|
43
43
|
textOverflow: "ellipsis"
|
|
44
44
|
};
|
|
45
45
|
var defaultAlign = {
|
|
46
|
-
textAnchor:
|
|
47
|
-
dominantBaseline:
|
|
46
|
+
textAnchor: "middle",
|
|
47
|
+
dominantBaseline: "middle"
|
|
48
48
|
};
|
|
49
|
-
var defaultOrientation =
|
|
49
|
+
var defaultOrientation = "bottom";
|
|
50
50
|
var defaultTickSize = 6;
|
|
51
51
|
|
|
52
52
|
var defaultFormatter = function defaultFormatter(d, _ref) {
|
|
@@ -59,13 +59,13 @@ var getAxesPath = function getAxesPath(orientation, _ref2) {
|
|
|
59
59
|
height = _ref2.height;
|
|
60
60
|
|
|
61
61
|
switch (orientation) {
|
|
62
|
-
case
|
|
63
|
-
case
|
|
64
|
-
return
|
|
62
|
+
case "top":
|
|
63
|
+
case "bottom":
|
|
64
|
+
return "M-0.5, 0H" + width;
|
|
65
65
|
|
|
66
|
-
case
|
|
67
|
-
case
|
|
68
|
-
return
|
|
66
|
+
case "left":
|
|
67
|
+
case "right":
|
|
68
|
+
return "M0, -0.5V" + (height + 0.5);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
/**
|
|
@@ -82,28 +82,28 @@ var getAxesPath = function getAxesPath(orientation, _ref2) {
|
|
|
82
82
|
|
|
83
83
|
var getLayout = function getLayout(orientation, rotate) {
|
|
84
84
|
switch (orientation) {
|
|
85
|
-
case
|
|
85
|
+
case "top":
|
|
86
86
|
return {
|
|
87
87
|
transform: "translate(-50%,-100%) rotate(".concat(rotate, "deg)"),
|
|
88
88
|
directionX: 1,
|
|
89
89
|
directionY: -1
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
case
|
|
92
|
+
case "bottom":
|
|
93
93
|
return {
|
|
94
94
|
transform: "translate(-50%,0) rotate(".concat(rotate, "deg)"),
|
|
95
95
|
directionX: 1,
|
|
96
96
|
directionY: 1
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
case
|
|
99
|
+
case "left":
|
|
100
100
|
return {
|
|
101
101
|
transform: "translate(-100%,-50%) rotate(".concat(rotate, "deg)"),
|
|
102
102
|
directionX: -1,
|
|
103
103
|
directionY: 1
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
case
|
|
106
|
+
case "right":
|
|
107
107
|
return {
|
|
108
108
|
transform: "translate(0,-50%) rotate(".concat(rotate, "deg)"),
|
|
109
109
|
directionX: 1,
|
|
@@ -118,14 +118,32 @@ var AxisLine = function AxisLine(_ref3) {
|
|
|
118
118
|
_ref3$config = _ref3.config,
|
|
119
119
|
show = _ref3$config.show,
|
|
120
120
|
color = _ref3$config.color,
|
|
121
|
-
lineWidth = _ref3$config.lineWidth
|
|
121
|
+
lineWidth = _ref3$config.lineWidth,
|
|
122
|
+
_ref3$isClipAxis = _ref3.isClipAxis,
|
|
123
|
+
isClipAxis = _ref3$isClipAxis === void 0 ? false : _ref3$isClipAxis,
|
|
124
|
+
_ref3$clipAxisRange = _ref3.clipAxisRange,
|
|
125
|
+
clipAxisRange = _ref3$clipAxisRange === void 0 ? [] : _ref3$clipAxisRange;
|
|
122
126
|
if (!show) return null;
|
|
123
127
|
var context = (0, _react.useContext)(_context.chartContext);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
var width = context.width,
|
|
129
|
+
height = context.height;
|
|
130
|
+
|
|
131
|
+
if (isClipAxis) {
|
|
132
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, clipAxisRange.map(function (range, index) {
|
|
133
|
+
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
134
|
+
key: index,
|
|
135
|
+
d: "M 0.5,".concat(range[0], " L 0.5,").concat(range[1]),
|
|
136
|
+
stroke: color,
|
|
137
|
+
strokeWidth: lineWidth
|
|
138
|
+
});
|
|
139
|
+
}));
|
|
140
|
+
} else {
|
|
141
|
+
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
142
|
+
d: getAxesPath(orientation, context),
|
|
143
|
+
stroke: color,
|
|
144
|
+
strokeWidth: lineWidth
|
|
145
|
+
});
|
|
146
|
+
}
|
|
129
147
|
};
|
|
130
148
|
|
|
131
149
|
var Unit = function Unit(_ref4) {
|
|
@@ -148,12 +166,12 @@ var Unit = function Unit(_ref4) {
|
|
|
148
166
|
if (!show) return null;
|
|
149
167
|
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
150
168
|
className: "__easyv-unit",
|
|
151
|
-
transform:
|
|
169
|
+
transform: "translate(" + translateX + ", " + translateY + ")",
|
|
152
170
|
fontFamily: fontFamily,
|
|
153
171
|
fontSize: fontSize,
|
|
154
172
|
fill: color,
|
|
155
|
-
fontWeight: bold ?
|
|
156
|
-
fontStyle: italic ?
|
|
173
|
+
fontWeight: bold ? "bold" : "normal",
|
|
174
|
+
fontStyle: italic ? "italic" : "normal",
|
|
157
175
|
letterSpacing: letterSpacing,
|
|
158
176
|
textAnchor: textAnchor
|
|
159
177
|
}, text);
|
|
@@ -194,11 +212,11 @@ var Label = function Label(_ref5) {
|
|
|
194
212
|
directionX = _getLayout.directionX,
|
|
195
213
|
directionY = _getLayout.directionY;
|
|
196
214
|
|
|
197
|
-
var isVertical = orientation ==
|
|
215
|
+
var isVertical = orientation == "left" || orientation == "right";
|
|
198
216
|
var x = (isVertical ? tickSize * directionX : coordinate) + translateX * directionX;
|
|
199
217
|
var y = (isVertical ? coordinate : tickSize * directionY) + translateY * directionY;
|
|
200
218
|
|
|
201
|
-
var _style = style && ((0, _typeof2["default"])(style) ==
|
|
219
|
+
var _style = style && ((0, _typeof2["default"])(style) == "object" ? style : style(_label));
|
|
202
220
|
|
|
203
221
|
return /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
204
222
|
width: "1",
|
|
@@ -244,23 +262,108 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
244
262
|
tickLine = _ref6$config.tickLine,
|
|
245
263
|
gridLine = _ref6$config.gridLine,
|
|
246
264
|
unit = _ref6$config.unit,
|
|
265
|
+
config = _ref6.config,
|
|
247
266
|
positions = _ref6.positions,
|
|
248
267
|
xLineRange = _ref6.xLineRange,
|
|
249
|
-
|
|
268
|
+
_ref6$isClipAxis = _ref6.isClipAxis,
|
|
269
|
+
isClipAxis = _ref6$isClipAxis === void 0 ? false : _ref6$isClipAxis,
|
|
270
|
+
yLineRange = _ref6.yLineRange,
|
|
271
|
+
clipAxisRange = _ref6.clipAxisRange;
|
|
250
272
|
if (!(on && ticks.length > 0)) return null;
|
|
251
273
|
|
|
252
274
|
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
253
275
|
width = _useContext.width,
|
|
254
276
|
height = _useContext.height;
|
|
255
277
|
|
|
256
|
-
var x = orientation ==
|
|
257
|
-
var y = orientation ==
|
|
258
|
-
|
|
278
|
+
var x = orientation == "right" ? width : 0;
|
|
279
|
+
var y = orientation == "bottom" ? height : 0;
|
|
280
|
+
|
|
281
|
+
function drawYAxisTickLine() {
|
|
282
|
+
var draw = function draw(ticks, scaler) {
|
|
283
|
+
return ticks.map(function (tick, index) {
|
|
284
|
+
var coordinate = scaler(tick);
|
|
285
|
+
if (isNaN(coordinate)) return null;
|
|
286
|
+
|
|
287
|
+
var _tickSize = tickLine.tickSize || tickSize;
|
|
288
|
+
|
|
289
|
+
var gridCoord = (0, _utils.getGridCoord)({
|
|
290
|
+
orientation: orientation,
|
|
291
|
+
coordinate: coordinate,
|
|
292
|
+
end: orientation == "left" || orientation == "right" ? width : height
|
|
293
|
+
});
|
|
294
|
+
var x1 = gridCoord.x1;
|
|
295
|
+
var y1 = gridCoord.y1;
|
|
296
|
+
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
297
|
+
className: "__easyv-tickLine",
|
|
298
|
+
key: index,
|
|
299
|
+
config: tickLine
|
|
300
|
+
}, (0, _utils.getTickCoord)({
|
|
301
|
+
orientation: orientation,
|
|
302
|
+
coordinate: coordinate,
|
|
303
|
+
tickSize: _tickSize
|
|
304
|
+
})));
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
if (isClipAxis) {
|
|
309
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, ticks.map(function (ticks, index) {
|
|
310
|
+
return draw(ticks, scaler[index]);
|
|
311
|
+
}));
|
|
312
|
+
} else {
|
|
313
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, draw(ticks, scaler));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function drawLabel() {
|
|
318
|
+
var draw = function draw(ticks, scaler) {
|
|
319
|
+
return ticks.map(function (tick, index) {
|
|
320
|
+
var coordinate = scaler(tick);
|
|
321
|
+
if (isNaN(coordinate)) return null;
|
|
322
|
+
|
|
323
|
+
var _tickSize = tickLine.tickSize || tickSize;
|
|
324
|
+
|
|
325
|
+
var gridCoord = (0, _utils.getGridCoord)({
|
|
326
|
+
orientation: orientation,
|
|
327
|
+
coordinate: coordinate,
|
|
328
|
+
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
329
|
+
});
|
|
330
|
+
var x1 = gridCoord.x1;
|
|
331
|
+
var y1 = gridCoord.y1;
|
|
332
|
+
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
333
|
+
key: index
|
|
334
|
+
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
335
|
+
className: "__easyv-label",
|
|
336
|
+
orientation: orientation,
|
|
337
|
+
coordinate: coordinate,
|
|
338
|
+
config: label,
|
|
339
|
+
label: tick,
|
|
340
|
+
tickSize: _tickSize,
|
|
341
|
+
formatter: formatter,
|
|
342
|
+
rotate: rotate,
|
|
343
|
+
onClick: triggerClick
|
|
344
|
+
}), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
345
|
+
className: "__easyv-gridLine",
|
|
346
|
+
config: gridLine
|
|
347
|
+
}, gridCoord)));
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
if (isClipAxis) {
|
|
352
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, ticks.map(function (ticks, index) {
|
|
353
|
+
return draw(ticks, scaler[index]);
|
|
354
|
+
}));
|
|
355
|
+
} else {
|
|
356
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, draw(ticks, scaler));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, axisLine && tickLine && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, axisLine && ( // 依据positions来区分x轴y轴,有position为x轴
|
|
361
|
+
positions && positions.length ? positions.map(function (_ref7, index) {
|
|
259
362
|
var x = _ref7.x,
|
|
260
363
|
y = _ref7.y;
|
|
261
364
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
262
365
|
key: index,
|
|
263
|
-
transform:
|
|
366
|
+
transform: "translate(" + x + ", " + y + ")"
|
|
264
367
|
}, /*#__PURE__*/_react["default"].createElement(AxisLine, {
|
|
265
368
|
orientation: orientation,
|
|
266
369
|
config: axisLine
|
|
@@ -273,7 +376,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
273
376
|
var gridCoord = (0, _utils.getGridCoord)({
|
|
274
377
|
orientation: orientation,
|
|
275
378
|
coordinate: coordinate,
|
|
276
|
-
end: orientation ==
|
|
379
|
+
end: orientation == "left" || orientation == "right" ? width : height
|
|
277
380
|
});
|
|
278
381
|
var x1 = gridCoord.x1;
|
|
279
382
|
var y1 = gridCoord.y1;
|
|
@@ -288,64 +391,15 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
288
391
|
})));
|
|
289
392
|
}));
|
|
290
393
|
}) : /*#__PURE__*/_react["default"].createElement("g", {
|
|
291
|
-
transform:
|
|
394
|
+
transform: "translate(" + x + ", " + y + ")"
|
|
292
395
|
}, /*#__PURE__*/_react["default"].createElement(AxisLine, {
|
|
293
396
|
orientation: orientation,
|
|
294
|
-
config: axisLine
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
var _tickSize = tickLine.tickSize || tickSize;
|
|
300
|
-
|
|
301
|
-
var gridCoord = (0, _utils.getGridCoord)({
|
|
302
|
-
orientation: orientation,
|
|
303
|
-
coordinate: coordinate,
|
|
304
|
-
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
305
|
-
});
|
|
306
|
-
var x1 = gridCoord.x1;
|
|
307
|
-
var y1 = gridCoord.y1;
|
|
308
|
-
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
309
|
-
className: "__easyv-tickLine",
|
|
310
|
-
key: index,
|
|
311
|
-
config: tickLine
|
|
312
|
-
}, (0, _utils.getTickCoord)({
|
|
313
|
-
orientation: orientation,
|
|
314
|
-
coordinate: coordinate,
|
|
315
|
-
tickSize: _tickSize
|
|
316
|
-
})));
|
|
317
|
-
})))), /*#__PURE__*/_react["default"].createElement("g", {
|
|
397
|
+
config: axisLine,
|
|
398
|
+
isClipAxis: isClipAxis,
|
|
399
|
+
clipAxisRange: clipAxisRange
|
|
400
|
+
}), tickLine && drawYAxisTickLine()))), /*#__PURE__*/_react["default"].createElement("g", {
|
|
318
401
|
transform: 'translate(' + x + ', ' + y + ')'
|
|
319
|
-
}, label && gridLine &&
|
|
320
|
-
var coordinate = scaler(tick);
|
|
321
|
-
if (isNaN(coordinate)) return null;
|
|
322
|
-
|
|
323
|
-
var _tickSize = tickLine.tickSize || tickSize;
|
|
324
|
-
|
|
325
|
-
var gridCoord = (0, _utils.getGridCoord)({
|
|
326
|
-
orientation: orientation,
|
|
327
|
-
coordinate: coordinate,
|
|
328
|
-
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
329
|
-
});
|
|
330
|
-
var x1 = gridCoord.x1;
|
|
331
|
-
var y1 = gridCoord.y1;
|
|
332
|
-
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
333
|
-
key: index
|
|
334
|
-
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
335
|
-
className: "__easyv-label",
|
|
336
|
-
orientation: orientation,
|
|
337
|
-
coordinate: coordinate,
|
|
338
|
-
config: label,
|
|
339
|
-
label: tick,
|
|
340
|
-
tickSize: _tickSize,
|
|
341
|
-
formatter: formatter,
|
|
342
|
-
rotate: rotate,
|
|
343
|
-
onClick: triggerClick
|
|
344
|
-
}), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
345
|
-
className: "__easyv-gridLine",
|
|
346
|
-
config: gridLine
|
|
347
|
-
}, gridCoord)));
|
|
348
|
-
}), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
|
|
402
|
+
}, label && gridLine && drawLabel(), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
|
|
349
403
|
config: unit
|
|
350
404
|
})));
|
|
351
405
|
});
|
package/lib/components/Band.js
CHANGED
|
@@ -31,23 +31,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
31
31
|
|
|
32
32
|
var getHighlightData = function getHighlightData(data, extent) {
|
|
33
33
|
switch (extent) {
|
|
34
|
-
case
|
|
34
|
+
case "min":
|
|
35
35
|
var minData = (0, _d3v.min)(data, function (d) {
|
|
36
36
|
return d.data.y;
|
|
37
37
|
});
|
|
38
38
|
return data.map(function (item) {
|
|
39
39
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
40
|
-
flag: minData == item.data.y ?
|
|
40
|
+
flag: minData == item.data.y ? "min" : ""
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
case
|
|
44
|
+
case "max":
|
|
45
45
|
var maxData = (0, _d3v.max)(data, function (d) {
|
|
46
46
|
return d.data.y;
|
|
47
47
|
});
|
|
48
48
|
return data.map(function (item) {
|
|
49
49
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
50
|
-
flag: maxData == item.data.y ?
|
|
50
|
+
flag: maxData == item.data.y ? "max" : ""
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
|
|
@@ -80,7 +80,7 @@ var getBorderRadius = function getBorderRadius(_ref2) {
|
|
|
80
80
|
var isVertical = _ref2.isVertical,
|
|
81
81
|
positive = _ref2.positive,
|
|
82
82
|
seriesWidth = _ref2.seriesWidth;
|
|
83
|
-
return isVertical ? positive ?
|
|
83
|
+
return isVertical ? positive ? "0px " + seriesWidth + "px " + seriesWidth + "px 0" : seriesWidth + "px 0 0 " + seriesWidth + "px" : positive ? seriesWidth / 2 + "px " + seriesWidth / 2 + "px 0 0" : "0 0 " + seriesWidth / 2 + "px " + seriesWidth / 2 + "px";
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
@@ -111,7 +111,10 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
111
111
|
xScaler = _ref3$xAxis.scaler,
|
|
112
112
|
step = _ref3$xAxis.step,
|
|
113
113
|
direction = _ref3$xAxis.direction,
|
|
114
|
-
|
|
114
|
+
_ref3$yAxis = _ref3.yAxis,
|
|
115
|
+
yScaler = _ref3$yAxis.scaler,
|
|
116
|
+
isClipAxis = _ref3$yAxis.isClipAxis,
|
|
117
|
+
clipValue = _ref3$yAxis.clipValue;
|
|
115
118
|
if (!data.length) return null;
|
|
116
119
|
|
|
117
120
|
var _getSeriesInfo = (0, _utils.getSeriesInfo)({
|
|
@@ -126,7 +129,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
126
129
|
|
|
127
130
|
var _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
128
131
|
|
|
129
|
-
var isVertical = direction ===
|
|
132
|
+
var isVertical = direction === "vertical";
|
|
130
133
|
var borderStr = "".concat(border.borderColor, " solid ").concat(border.borderWidth, "px");
|
|
131
134
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
132
135
|
className: "__easyv-band"
|
|
@@ -142,14 +145,44 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
142
145
|
y = _ref4$data.y,
|
|
143
146
|
s = _ref4$data.s;
|
|
144
147
|
|
|
145
|
-
|
|
146
|
-
var y2
|
|
148
|
+
//todo 柱状中空设置
|
|
149
|
+
var y1, y2; //断轴图相关,断轴图的scaler是一个数组,内含上断轴下断轴的scaler
|
|
150
|
+
|
|
151
|
+
if (isClipAxis) {
|
|
152
|
+
if (end > +clipValue) {
|
|
153
|
+
y1 = yScaler[1](start);
|
|
154
|
+
y2 = yScaler[0](end);
|
|
155
|
+
} else {
|
|
156
|
+
y1 = yScaler[1](start);
|
|
157
|
+
y2 = yScaler[1](end);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
y1 = yScaler(isVertical ? end : start);
|
|
161
|
+
y2 = yScaler(isVertical ? start : end);
|
|
162
|
+
}
|
|
163
|
+
|
|
147
164
|
var positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
148
165
|
var showHead, headUrl, headWidth, headHeight, headTranslate;
|
|
149
166
|
|
|
150
167
|
if (headDecorate) {
|
|
151
168
|
showHead = headDecorate.show, headUrl = headDecorate.url, headWidth = headDecorate.size.width, headHeight = headDecorate.size.height, headTranslate = headDecorate.translate;
|
|
152
|
-
}
|
|
169
|
+
} //断轴图相关,将柱形在断轴处切开
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
var setClipPath = function setClipPath() {
|
|
173
|
+
if (isClipAxis && end > +clipValue) {
|
|
174
|
+
var clipValueY2 = yScaler[0](clipValue); //上方
|
|
175
|
+
|
|
176
|
+
var clipValueY1 = yScaler[1](clipValue); //下方
|
|
177
|
+
|
|
178
|
+
var top = Math.abs((y2 - clipValueY2) / (y1 - y2)) * 100;
|
|
179
|
+
var bottom = Math.abs((y2 - clipValueY1) / (y1 - y2)) * 100; //clip path属性
|
|
180
|
+
|
|
181
|
+
return "polygon(0% 0%, 0% 100%, 0 100%, 0 ".concat(top, "%, 100% ").concat(top, "%, 100% ").concat(bottom, "%, 0 ").concat(bottom, "%, 0 100%, 100% 100%, 100% 0%)");
|
|
182
|
+
} else {
|
|
183
|
+
return "none";
|
|
184
|
+
}
|
|
185
|
+
};
|
|
153
186
|
|
|
154
187
|
if (isNaN(positionX)) return null;
|
|
155
188
|
var positionY = y < 0 ? y1 : y2;
|
|
@@ -183,14 +216,15 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
183
216
|
}
|
|
184
217
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
185
218
|
style: _objectSpread({
|
|
186
|
-
width:
|
|
187
|
-
height:
|
|
219
|
+
width: "100%",
|
|
220
|
+
height: "100%",
|
|
188
221
|
|
|
189
222
|
/** Safari Bug **/
|
|
190
|
-
position:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
223
|
+
position: "fixed",
|
|
224
|
+
clipPath: setClipPath(),
|
|
225
|
+
opacity: fillType == "pattern" ? opacity : 1,
|
|
226
|
+
background: fillType == "pattern" ? "50% 50% / ".concat(size.width, "px ").concat(size.height, "px repeat ") + "url(" + url + ")" : (0, _utils.getBandBackground)(pattern, extent === flag ? highlightFill : fill),
|
|
227
|
+
borderRadius: style == "square" ? "0 0 0 0" : getBorderRadius({
|
|
194
228
|
isVertical: isVertical,
|
|
195
229
|
positive: y > 0,
|
|
196
230
|
seriesWidth: seriesWidth
|
|
@@ -46,14 +46,25 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
46
46
|
marginLeft = _ref$config$line$marg.marginLeft,
|
|
47
47
|
marginRight = _ref$config$line$marg.marginRight,
|
|
48
48
|
strokeDasharray = _ref$config$line.strokeDasharray,
|
|
49
|
-
|
|
49
|
+
_ref$yAxis = _ref.yAxis,
|
|
50
|
+
yScaler = _ref$yAxis.scaler,
|
|
51
|
+
clipValue = _ref$yAxis.clipValue,
|
|
52
|
+
isClipAxis = _ref$yAxis.isClipAxis,
|
|
50
53
|
data = _ref.data;
|
|
51
54
|
|
|
52
55
|
try {
|
|
53
|
-
var x1
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
var x1, x2, y1, y2;
|
|
57
|
+
|
|
58
|
+
if (isClipAxis) {
|
|
59
|
+
if (data.value > +clipValue) {
|
|
60
|
+
x1 = orientation == 'left' ? yScaler[0](data.value) : marginLeft, x2 = orientation == 'left' ? yScaler[0](data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler[0](data.value), y2 = orientation == 'left' ? height - marginRight : yScaler[0](data.value);
|
|
61
|
+
} else {
|
|
62
|
+
x1 = orientation == 'left' ? yScaler[1](data.value) : marginLeft, x2 = orientation == 'left' ? yScaler[1](data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler[1](data.value), y2 = orientation == 'left' ? height - marginRight : yScaler[1](data.value);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
x1 = orientation == 'left' ? yScaler(data.value) : marginLeft, x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler(data.value), y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("g", {
|
|
58
69
|
className: "__easyv-baseLine"
|
|
59
70
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
12
14
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
15
|
|
|
14
16
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
17
|
|
|
16
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
-
|
|
18
18
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
19
|
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -162,16 +162,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
162
162
|
axis: axisX,
|
|
163
163
|
config: background,
|
|
164
164
|
bandLength: bandLength
|
|
165
|
-
}))), (0,
|
|
166
|
-
var config = item.axisType == 'x' ? axisX : item;
|
|
167
|
-
return /*#__PURE__*/_react["default"].createElement(_.Axis, (0, _extends2["default"])({
|
|
168
|
-
triggerClick: onInteraction,
|
|
169
|
-
xLineRange: xLineRange,
|
|
170
|
-
yLineRange: yLineRange
|
|
171
|
-
}, config, {
|
|
172
|
-
key: index
|
|
173
|
-
}));
|
|
174
|
-
}), showTooltip && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
165
|
+
}))), showTooltip && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
175
166
|
style: isVertical ? {
|
|
176
167
|
width: xLineRange + marginRight + marginLeft,
|
|
177
168
|
height: yLineRange,
|
|
@@ -216,7 +207,16 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
216
207
|
yAxis: yAxis,
|
|
217
208
|
triggerClick: onInteraction
|
|
218
209
|
}));
|
|
219
|
-
}))),
|
|
210
|
+
}))), (0, _toConsumableArray2["default"])(axes.values()).reverse().map(function (item, index) {
|
|
211
|
+
var config = item.axisType == 'x' ? axisX : item;
|
|
212
|
+
return /*#__PURE__*/_react["default"].createElement(_.Axis, (0, _extends2["default"])({
|
|
213
|
+
triggerClick: onInteraction,
|
|
214
|
+
xLineRange: xLineRange,
|
|
215
|
+
yLineRange: yLineRange
|
|
216
|
+
}, config, {
|
|
217
|
+
key: index
|
|
218
|
+
}));
|
|
219
|
+
}), baseLineData && baseLineData.length > 0 && baseLineData.map(function (item, index) {
|
|
220
220
|
var yOrZ = baseLineConfig[index].line.yOrZ;
|
|
221
221
|
var yAxis = axes.get(yOrZ);
|
|
222
222
|
return yAxis && /*#__PURE__*/_react["default"].createElement(_.BaseLine, {
|