@easyv/charts 1.8.24 → 1.8.26
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 +8 -5
- package/lib/components/Band.js +7 -3
- package/lib/components/CartesianChart.js +25 -6
- package/lib/components/Chart.js +17 -7
- package/lib/components/Label.js +16 -5
- package/lib/components/Line.js +9 -4
- package/package.json +1 -1
- package/src/components/Axis.tsx +72 -63
- package/src/components/Band.tsx +153 -113
- package/src/components/CartesianChart.js +288 -211
- package/src/components/Chart.js +94 -60
- package/src/components/Label.js +90 -42
- package/src/components/Line.js +6 -1
package/lib/components/Axis.js
CHANGED
|
@@ -168,8 +168,8 @@ var Label = function Label(_ref5) {
|
|
|
168
168
|
_ref5$rotate = _ref5.rotate,
|
|
169
169
|
rotate = _ref5$rotate === void 0 ? 0 : _ref5$rotate,
|
|
170
170
|
config = _ref5.config,
|
|
171
|
-
_ref5$
|
|
172
|
-
|
|
171
|
+
_ref5$events = _ref5.events,
|
|
172
|
+
events = _ref5$events === void 0 ? defaultEvent : _ref5$events,
|
|
173
173
|
_ref5$config = _ref5.config,
|
|
174
174
|
show = _ref5$config.show,
|
|
175
175
|
style = _ref5$config.style,
|
|
@@ -205,7 +205,9 @@ var Label = function Label(_ref5) {
|
|
|
205
205
|
}
|
|
206
206
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
207
207
|
className: className,
|
|
208
|
-
onClick: onClick
|
|
208
|
+
onClick: function onClick(e) {
|
|
209
|
+
return events(e, "click");
|
|
210
|
+
},
|
|
209
211
|
"data-data": JSON.stringify({
|
|
210
212
|
x: label
|
|
211
213
|
}),
|
|
@@ -217,6 +219,7 @@ var Label = function Label(_ref5) {
|
|
|
217
219
|
top: y + (isIOS ? iosY : 0)
|
|
218
220
|
})
|
|
219
221
|
}, /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
222
|
+
ShowType: "normal",
|
|
220
223
|
type: textOverflow,
|
|
221
224
|
speed: speed,
|
|
222
225
|
value: _label,
|
|
@@ -236,7 +239,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
236
239
|
ticks = _ref6.ticks,
|
|
237
240
|
formatter = _ref6.formatter,
|
|
238
241
|
rotate = _ref6.rotate,
|
|
239
|
-
|
|
242
|
+
triggerEvents = _ref6.triggerEvents,
|
|
240
243
|
_ref6$config = _ref6.config,
|
|
241
244
|
on = _ref6$config.on,
|
|
242
245
|
label = _ref6$config.label,
|
|
@@ -331,7 +334,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
331
334
|
tickSize: _tickSize,
|
|
332
335
|
formatter: formatter,
|
|
333
336
|
rotate: rotate,
|
|
334
|
-
|
|
337
|
+
events: triggerEvents
|
|
335
338
|
}), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
336
339
|
className: "__easyv-gridLine",
|
|
337
340
|
config: gridLine
|
package/lib/components/Band.js
CHANGED
|
@@ -88,7 +88,7 @@ var getBorderRadius = function getBorderRadius(_ref2) {
|
|
|
88
88
|
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";
|
|
89
89
|
};
|
|
90
90
|
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
91
|
-
var
|
|
91
|
+
var triggerEvents = _ref3.triggerEvents,
|
|
92
92
|
indicatorWidth = _ref3.indicatorWidth,
|
|
93
93
|
_ref3$isControlChart = _ref3.isControlChart,
|
|
94
94
|
isControlChart = _ref3$isControlChart === void 0 ? false : _ref3$isControlChart,
|
|
@@ -243,7 +243,10 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
243
243
|
}
|
|
244
244
|
}, bgAttr, {
|
|
245
245
|
onClick: function onClick(e) {
|
|
246
|
-
return
|
|
246
|
+
return triggerEvents ? triggerEvents(e, "setCurrent") : "";
|
|
247
|
+
},
|
|
248
|
+
onMouseMove: function onMouseMove(e) {
|
|
249
|
+
return triggerEvents ? triggerEvents(e, "mouseenter") : "";
|
|
247
250
|
},
|
|
248
251
|
onMouseEnter: function onMouseEnter() {
|
|
249
252
|
if (isControlChart) {
|
|
@@ -265,7 +268,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
265
268
|
});
|
|
266
269
|
}
|
|
267
270
|
},
|
|
268
|
-
onMouseLeave: function onMouseLeave() {
|
|
271
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
272
|
+
triggerEvents ? triggerEvents(e, "mouseleave") : "";
|
|
269
273
|
if (isControlChart && !auto) {
|
|
270
274
|
setCtlTip(function (pre) {
|
|
271
275
|
return {
|
|
@@ -81,6 +81,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
81
81
|
curXLabel = _useState4[0],
|
|
82
82
|
setCurXLabel = _useState4[1];
|
|
83
83
|
var isIOS = context.isIOS,
|
|
84
|
+
scale = context.scale,
|
|
85
|
+
screenPos = context.screenPos,
|
|
84
86
|
chartWidth = context.width,
|
|
85
87
|
chartHeight = context.height,
|
|
86
88
|
triggerOnRelative = context.triggerOnRelative,
|
|
@@ -265,16 +267,32 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
265
267
|
};
|
|
266
268
|
var onInteraction = (0, _react.useCallback)(function (e, type) {
|
|
267
269
|
e.stopPropagation();
|
|
270
|
+
var _e$nativeEvent = e.nativeEvent,
|
|
271
|
+
pageX = _e$nativeEvent.pageX,
|
|
272
|
+
pageY = _e$nativeEvent.pageY;
|
|
268
273
|
var data = e.currentTarget.dataset.data;
|
|
269
274
|
var _data = JSON.parse(data);
|
|
275
|
+
var _scale$current = (0, _slicedToArray2["default"])(scale.current, 2),
|
|
276
|
+
scaleX = _scale$current[0],
|
|
277
|
+
scaleY = _scale$current[1];
|
|
278
|
+
var _screenPos$current = screenPos.current,
|
|
279
|
+
left = _screenPos$current.left,
|
|
280
|
+
top = _screenPos$current.top;
|
|
281
|
+
var eventData = _objectSpread(_objectSpread({}, _data), {}, {
|
|
282
|
+
xPos: (pageX - left) * scaleX,
|
|
283
|
+
yPos: (pageY - top) * scaleY
|
|
284
|
+
});
|
|
270
285
|
if (type == "setCurrent") {
|
|
271
286
|
setCurXLabel(function (pre) {
|
|
272
287
|
return pre == _data.x ? "" : _data.x;
|
|
273
288
|
});
|
|
289
|
+
triggerOnRelative("click", eventData);
|
|
290
|
+
onEmit("click", eventData);
|
|
291
|
+
} else {
|
|
292
|
+
triggerOnRelative(type, eventData);
|
|
293
|
+
onEmit(type, eventData);
|
|
274
294
|
}
|
|
275
|
-
|
|
276
|
-
onEmit("click", _data);
|
|
277
|
-
}, [triggerOnRelative, onEmit]);
|
|
295
|
+
}, [triggerOnRelative, onEmit, scale]);
|
|
278
296
|
|
|
279
297
|
/**
|
|
280
298
|
* 控制图相关
|
|
@@ -538,7 +556,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
538
556
|
ref: function ref(d) {
|
|
539
557
|
axisElList.current[index] = d;
|
|
540
558
|
},
|
|
541
|
-
|
|
559
|
+
triggerEvents: onInteraction,
|
|
542
560
|
xLineRange: xLineRange,
|
|
543
561
|
yLineRange: yLineRange,
|
|
544
562
|
controlInfo: controlInfo,
|
|
@@ -601,7 +619,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
601
619
|
,
|
|
602
620
|
isControlChart: !!control,
|
|
603
621
|
indicatorWidth: indicatorWidth,
|
|
604
|
-
|
|
622
|
+
triggerEvents: onInteraction,
|
|
605
623
|
setCtlTip: setCtlTip,
|
|
606
624
|
isXRepeat: isXRepeat
|
|
607
625
|
}));
|
|
@@ -620,7 +638,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
620
638
|
bandLength: bandLength,
|
|
621
639
|
xAxis: axisX,
|
|
622
640
|
yAxis: yAxis,
|
|
623
|
-
|
|
641
|
+
triggerEvents: onInteraction,
|
|
642
|
+
isControlChart: !!control
|
|
624
643
|
}));
|
|
625
644
|
}), /*#__PURE__*/_react["default"].createElement("g", null, control && zIndex != "bottom" && ctlIndicatorList.map(function (item, index) {
|
|
626
645
|
var x = axisX.scaler(item.tick);
|
package/lib/components/Chart.js
CHANGED
|
@@ -30,7 +30,7 @@ var getCallbackData = function getCallbackData(action, callbacks, data) {
|
|
|
30
30
|
target = _ref.target,
|
|
31
31
|
_action = _ref.actions;
|
|
32
32
|
if (action === _action) {
|
|
33
|
-
callbackData[target] = data[origin];
|
|
33
|
+
callbackData[target] = origin ? data[origin] : data;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -64,19 +64,23 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
64
64
|
active = _useState2[0],
|
|
65
65
|
setActive = _useState2[1];
|
|
66
66
|
var scaleRef = (0, _react.useRef)([1, 1]);
|
|
67
|
+
var screenPosRef = (0, _react.useRef)({
|
|
68
|
+
left: 0,
|
|
69
|
+
top: 0
|
|
70
|
+
});
|
|
67
71
|
var triggerOnRelative = (0, _react.useCallback)(function (action, data) {
|
|
68
72
|
if (!interaction) return;
|
|
69
73
|
var callbacks = interaction.callbacks,
|
|
70
74
|
remoteControls = interaction.remoteControls;
|
|
71
75
|
var callbackData = getCallbackData(action, callbacks, data);
|
|
72
|
-
if (
|
|
76
|
+
if (Object.keys(callbackData).length > 0) {
|
|
73
77
|
onRelative && onRelative(id, callbackData);
|
|
74
78
|
remoteControls && emitEvent && remoteControls.forEach(function (o) {
|
|
75
79
|
var control = JSON.parse(o.control);
|
|
76
|
-
if (control.screen && control.type && control.type ===
|
|
80
|
+
if (control.screen && control.type && control.type === "callback") {
|
|
77
81
|
emitEvent({
|
|
78
82
|
screen: control.screen,
|
|
79
|
-
type:
|
|
83
|
+
type: "callback",
|
|
80
84
|
callbackData: callbackData
|
|
81
85
|
});
|
|
82
86
|
}
|
|
@@ -84,7 +88,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
84
88
|
}
|
|
85
89
|
}, [JSON.stringify(interaction)]);
|
|
86
90
|
var onEmit = (0, _react.useCallback)(function () {
|
|
87
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
91
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "click";
|
|
88
92
|
var data = arguments.length > 1 ? arguments[1] : undefined;
|
|
89
93
|
return emit && emit(type, data);
|
|
90
94
|
}, [emit]);
|
|
@@ -95,6 +99,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
95
99
|
//是否为IOS设备
|
|
96
100
|
scale: scaleRef,
|
|
97
101
|
//大屏的缩放比
|
|
102
|
+
screenPos: screenPosRef,
|
|
103
|
+
//大屏的偏移位置
|
|
98
104
|
width: chartWidth,
|
|
99
105
|
height: chartHeight,
|
|
100
106
|
triggerOnRelative: triggerOnRelative,
|
|
@@ -121,7 +127,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
121
127
|
var data = checkData(originData);
|
|
122
128
|
return /*#__PURE__*/_react["default"].createElement(_context.chartContext.Provider, {
|
|
123
129
|
value: context
|
|
124
|
-
}, type ==
|
|
130
|
+
}, type == "pie" ? /*#__PURE__*/_react["default"].createElement(_.PieChart, (0, _extends2["default"])({
|
|
125
131
|
id: id,
|
|
126
132
|
config: config,
|
|
127
133
|
data: data,
|
|
@@ -142,8 +148,12 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
142
148
|
var scale = transform ? transform.match(/^scale\((.+)\)$/)[1] : "1,1";
|
|
143
149
|
var arr = scale.split(",");
|
|
144
150
|
scaleRef.current = [1 / arr[0], 1 / (arr.length === 1 ? arr[0] : arr[1])]; //这里做一次除法,后面就可以用乘法计算值了
|
|
151
|
+
screenPosRef.current = {
|
|
152
|
+
left: parseFloat(dom.style.left),
|
|
153
|
+
top: parseFloat(dom.style.top)
|
|
154
|
+
};
|
|
145
155
|
}
|
|
146
|
-
},
|
|
156
|
+
}, 100);
|
|
147
157
|
}
|
|
148
158
|
//预检数据格式是否规范
|
|
149
159
|
function checkData(data) {
|
package/lib/components/Label.js
CHANGED
|
@@ -51,7 +51,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
51
51
|
_ref$config$paddingIn = _ref$config.paddingInner,
|
|
52
52
|
paddingOuter = _ref$config$paddingIn === void 0 ? 0 : _ref$config$paddingIn,
|
|
53
53
|
_ref$config$showType = _ref$config.showType,
|
|
54
|
-
seriesType = _ref$config$showType === void 0 ?
|
|
54
|
+
seriesType = _ref$config$showType === void 0 ? "bar" : _ref$config$showType,
|
|
55
55
|
_ref$config$highlight = _ref$config.highlight,
|
|
56
56
|
_ref$config$highlight2 = _ref$config$highlight === void 0 ? {} : _ref$config$highlight,
|
|
57
57
|
showHighlight = _ref$config$highlight2.show,
|
|
@@ -65,14 +65,19 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
65
65
|
bandLength = _ref$bandLength === void 0 ? 0 : _ref$bandLength,
|
|
66
66
|
data = _ref.data,
|
|
67
67
|
_ref$xAxis = _ref.xAxis,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
normalScaler = _ref$xAxis.scaler,
|
|
69
|
+
normalStep = _ref$xAxis.step,
|
|
70
70
|
direction = _ref$xAxis.direction,
|
|
71
|
+
controlStep = _ref$xAxis.controlStep,
|
|
72
|
+
controlDragScaler = _ref$xAxis.controlDragScaler,
|
|
71
73
|
_ref$yAxis = _ref.yAxis,
|
|
72
74
|
yScaler = _ref$yAxis.scaler,
|
|
73
75
|
isClipAxis = _ref$yAxis.isClipAxis,
|
|
74
76
|
clipValue = _ref$yAxis.clipValue,
|
|
75
|
-
|
|
77
|
+
triggerEvents = _ref.triggerEvents,
|
|
78
|
+
isControlChart = _ref.isControlChart;
|
|
79
|
+
var step = isControlChart ? controlStep : normalStep;
|
|
80
|
+
var xScaler = isControlChart ? controlDragScaler : normalScaler;
|
|
76
81
|
var selectConfig = other;
|
|
77
82
|
if (selectStyle) {
|
|
78
83
|
var show = selectStyle.show,
|
|
@@ -183,7 +188,13 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
183
188
|
return /*#__PURE__*/React.createElement("g", {
|
|
184
189
|
key: i,
|
|
185
190
|
onClick: function onClick(e) {
|
|
186
|
-
return
|
|
191
|
+
return triggerEvents(e, "setCurrent");
|
|
192
|
+
},
|
|
193
|
+
onMouseMove: function onMouseMove(e) {
|
|
194
|
+
return triggerEvents(e, "mouseenter");
|
|
195
|
+
},
|
|
196
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
197
|
+
return triggerEvents(e, "mouseleave");
|
|
187
198
|
},
|
|
188
199
|
style: {
|
|
189
200
|
cursor: "pointer"
|
package/lib/components/Line.js
CHANGED
|
@@ -47,7 +47,8 @@ var Area = function Area(_ref) {
|
|
|
47
47
|
curve = _ref$config.curve,
|
|
48
48
|
tension = _ref$config.tension,
|
|
49
49
|
xScaler = _ref.xScaler,
|
|
50
|
-
yScaler = _ref.yScaler
|
|
50
|
+
yScaler = _ref.yScaler,
|
|
51
|
+
Areaopacity = _ref.opacity;
|
|
51
52
|
var _yScaler$range = yScaler.range(),
|
|
52
53
|
_yScaler$range2 = (0, _slicedToArray2["default"])(_yScaler$range, 1),
|
|
53
54
|
height = _yScaler$range2[0];
|
|
@@ -72,7 +73,8 @@ var Area = function Area(_ref) {
|
|
|
72
73
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
73
74
|
d: areaGen(data),
|
|
74
75
|
style: {
|
|
75
|
-
pointerEvents: "none"
|
|
76
|
+
pointerEvents: "none",
|
|
77
|
+
opacity: Areaopacity
|
|
76
78
|
},
|
|
77
79
|
stroke: "none",
|
|
78
80
|
fill: 'url(#' + id + ')'
|
|
@@ -94,7 +96,9 @@ var Area = function Area(_ref) {
|
|
|
94
96
|
};
|
|
95
97
|
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
96
98
|
var type = _ref5.type,
|
|
97
|
-
_ref5$config
|
|
99
|
+
_ref5$config = _ref5.config,
|
|
100
|
+
opacity = _ref5$config.areaColor.linear.opacity,
|
|
101
|
+
_ref5$config$line = _ref5$config.line,
|
|
98
102
|
lineType = _ref5$config$line.type,
|
|
99
103
|
lineWidth = _ref5$config$line.lineWidth,
|
|
100
104
|
curve = _ref5$config$line.curve,
|
|
@@ -169,7 +173,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
169
173
|
tension: tension
|
|
170
174
|
}),
|
|
171
175
|
xScaler: xScaler,
|
|
172
|
-
yScaler: yScaler
|
|
176
|
+
yScaler: yScaler,
|
|
177
|
+
opacity: opacity
|
|
173
178
|
}), showLighter && /*#__PURE__*/_react["default"].createElement(_.Lighter, {
|
|
174
179
|
path: path,
|
|
175
180
|
config: lighter
|
package/package.json
CHANGED
package/src/components/Axis.tsx
CHANGED
|
@@ -37,13 +37,13 @@ const defaultFormatter: (
|
|
|
37
37
|
const getAxesPath: (
|
|
38
38
|
orientation: Orientation,
|
|
39
39
|
{ width, height }: Context,
|
|
40
|
-
cHeight:number,
|
|
41
|
-
cPercent:number
|
|
40
|
+
cHeight: number,
|
|
41
|
+
cPercent: number
|
|
42
42
|
) => string = (orientation, { width, height }, cHeight, cPercent) => {
|
|
43
43
|
switch (orientation) {
|
|
44
44
|
case "top":
|
|
45
45
|
case "bottom":
|
|
46
|
-
return "M-0.5, 0H" + width/cPercent;
|
|
46
|
+
return "M-0.5, 0H" + width / cPercent;
|
|
47
47
|
case "left":
|
|
48
48
|
case "right":
|
|
49
49
|
return "M0, -0.5V" + (height + 0.5 - cHeight);
|
|
@@ -99,13 +99,13 @@ const AxisLine: ({
|
|
|
99
99
|
config,
|
|
100
100
|
isClipAxis,
|
|
101
101
|
clipAxisRange,
|
|
102
|
-
cPercent
|
|
102
|
+
cPercent,
|
|
103
103
|
}: any) => ReactComponentElement<ComponentType> | null = ({
|
|
104
104
|
orientation = defaultOrientation,
|
|
105
105
|
config: { show, color, lineWidth, cHeight },
|
|
106
106
|
isClipAxis = false,
|
|
107
107
|
clipAxisRange = [],
|
|
108
|
-
cPercent = 1
|
|
108
|
+
cPercent = 1,
|
|
109
109
|
}) => {
|
|
110
110
|
if (!show) return null;
|
|
111
111
|
const context: Context = useContext(chartContext);
|
|
@@ -137,7 +137,7 @@ const AxisLine: ({
|
|
|
137
137
|
|
|
138
138
|
const Unit: ({
|
|
139
139
|
config: { show, text, font, translate, align },
|
|
140
|
-
dataUnit
|
|
140
|
+
dataUnit,
|
|
141
141
|
}: any) => ReactComponentElement<ComponentType> | null = ({
|
|
142
142
|
config: {
|
|
143
143
|
show,
|
|
@@ -146,7 +146,7 @@ const Unit: ({
|
|
|
146
146
|
translate: { x: translateX, y: translateY },
|
|
147
147
|
align: { textAnchor } = defaultAlign,
|
|
148
148
|
},
|
|
149
|
-
dataUnit
|
|
149
|
+
dataUnit,
|
|
150
150
|
}) => {
|
|
151
151
|
if (!show) return null;
|
|
152
152
|
return (
|
|
@@ -182,7 +182,7 @@ type LabelType = {
|
|
|
182
182
|
formatter: Function;
|
|
183
183
|
tickSize: number;
|
|
184
184
|
rotate: number;
|
|
185
|
-
|
|
185
|
+
events?: Function;
|
|
186
186
|
config: {
|
|
187
187
|
show: boolean;
|
|
188
188
|
translate: Translate;
|
|
@@ -199,13 +199,13 @@ const Label: (
|
|
|
199
199
|
className,
|
|
200
200
|
orientation = defaultOrientation,
|
|
201
201
|
label,
|
|
202
|
-
iosTrans:{ isIOS, x:iosX, y:iosY },
|
|
202
|
+
iosTrans: { isIOS, x: iosX, y: iosY },
|
|
203
203
|
coordinate,
|
|
204
204
|
formatter = defaultFormatter,
|
|
205
205
|
tickSize,
|
|
206
206
|
rotate = 0,
|
|
207
207
|
config,
|
|
208
|
-
|
|
208
|
+
events = defaultEvent,
|
|
209
209
|
config: {
|
|
210
210
|
show,
|
|
211
211
|
style,
|
|
@@ -226,42 +226,48 @@ const Label: (
|
|
|
226
226
|
(isVertical ? coordinate : tickSize * directionY) + translateY * directionY;
|
|
227
227
|
|
|
228
228
|
const _style = style && (typeof style == "object" ? style : style(_label));
|
|
229
|
-
|
|
229
|
+
|
|
230
230
|
return (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
<foreignObject
|
|
232
|
+
width="1"
|
|
233
|
+
height="1"
|
|
234
|
+
// x={x}
|
|
235
|
+
// y={y}
|
|
236
|
+
style={{ overflow: "visible" }}
|
|
237
|
+
>
|
|
238
|
+
<div
|
|
239
|
+
className={className}
|
|
240
|
+
onClick={(e) => events(e, "click")}
|
|
241
|
+
data-data={JSON.stringify({ x: label })}
|
|
242
|
+
style={{
|
|
243
|
+
..._style,
|
|
244
|
+
...getFontStyle(font),
|
|
245
|
+
/** Safari Bug **/
|
|
246
|
+
position: "absolute",
|
|
247
|
+
cursor: "pointer",
|
|
248
|
+
left: x + (isIOS ? iosX : 0),
|
|
249
|
+
top: y + (isIOS ? iosY : 0),
|
|
250
|
+
}}
|
|
237
251
|
>
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
252
|
+
<TextOverflow
|
|
253
|
+
ShowType="normal"
|
|
254
|
+
type={textOverflow}
|
|
255
|
+
speed={speed}
|
|
256
|
+
value={_label}
|
|
242
257
|
style={{
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
258
|
+
width,
|
|
259
|
+
transform,
|
|
260
|
+
textAlign,
|
|
261
|
+
justifyContent:
|
|
262
|
+
textAlign == "left"
|
|
263
|
+
? "flex-start"
|
|
264
|
+
: textAlign == "right"
|
|
265
|
+
? "flex-end"
|
|
266
|
+
: "center",
|
|
250
267
|
}}
|
|
251
|
-
>
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
speed={speed}
|
|
255
|
-
value={_label}
|
|
256
|
-
style={{
|
|
257
|
-
width,
|
|
258
|
-
transform,
|
|
259
|
-
textAlign,
|
|
260
|
-
justifyContent: textAlign=="left"?"flex-start":textAlign=="right"?"flex-end":"center",
|
|
261
|
-
}}
|
|
262
|
-
></TextOverflow>
|
|
263
|
-
</div>
|
|
264
|
-
</foreignObject>
|
|
268
|
+
></TextOverflow>
|
|
269
|
+
</div>
|
|
270
|
+
</foreignObject>
|
|
265
271
|
);
|
|
266
272
|
};
|
|
267
273
|
|
|
@@ -275,9 +281,9 @@ export default memo(
|
|
|
275
281
|
ticks,
|
|
276
282
|
formatter,
|
|
277
283
|
rotate,
|
|
278
|
-
|
|
284
|
+
triggerEvents,
|
|
279
285
|
config: { on, label, axisLine, tickLine, gridLine, unit },
|
|
280
|
-
margin:{ marginLeft, marginTop },
|
|
286
|
+
margin: { marginLeft, marginTop },
|
|
281
287
|
positions,
|
|
282
288
|
xLineRange,
|
|
283
289
|
dataUnit,
|
|
@@ -297,8 +303,8 @@ export default memo(
|
|
|
297
303
|
const { width, height, isIOS } = useContext(chartContext);
|
|
298
304
|
const { cHeight, isC, cPercent } = controlInfo;
|
|
299
305
|
const x = orientation == "right" ? width : 0;
|
|
300
|
-
const y = orientation == "bottom" ? height-cHeight : 0;
|
|
301
|
-
|
|
306
|
+
const y = orientation == "bottom" ? height - cHeight : 0;
|
|
307
|
+
|
|
302
308
|
function drawAxisTickLine() {
|
|
303
309
|
const draw = (ticks: any, scaler: any) => {
|
|
304
310
|
return ticks.map((tick: string, index: number) => {
|
|
@@ -318,7 +324,9 @@ export default memo(
|
|
|
318
324
|
const y1 = gridCoord.y1;
|
|
319
325
|
return (
|
|
320
326
|
!(
|
|
321
|
-
(orientation == "bottom" &&
|
|
327
|
+
(orientation == "bottom" &&
|
|
328
|
+
!isC &&
|
|
329
|
+
(x1 < 0 || x1 > xLineRange)) ||
|
|
322
330
|
y1 < 0 ||
|
|
323
331
|
y1 > yLineRange
|
|
324
332
|
) && (
|
|
@@ -336,7 +344,7 @@ export default memo(
|
|
|
336
344
|
);
|
|
337
345
|
});
|
|
338
346
|
};
|
|
339
|
-
|
|
347
|
+
|
|
340
348
|
if (isClipAxis) {
|
|
341
349
|
return (
|
|
342
350
|
<>
|
|
@@ -347,7 +355,7 @@ export default memo(
|
|
|
347
355
|
);
|
|
348
356
|
} else if (isC && orientation == "bottom") {
|
|
349
357
|
return <>{draw(rawTicks, scaler)}</>;
|
|
350
|
-
}else {
|
|
358
|
+
} else {
|
|
351
359
|
return <>{draw(ticks, scaler)}</>;
|
|
352
360
|
}
|
|
353
361
|
}
|
|
@@ -380,13 +388,13 @@ export default memo(
|
|
|
380
388
|
className="__easyv-label"
|
|
381
389
|
orientation={orientation}
|
|
382
390
|
coordinate={coordinate}
|
|
383
|
-
iosTrans
|
|
391
|
+
iosTrans={{ isIOS, x: marginLeft + x, y: marginTop + y }}
|
|
384
392
|
config={label}
|
|
385
393
|
label={tick}
|
|
386
394
|
tickSize={_tickSize}
|
|
387
395
|
formatter={formatter}
|
|
388
396
|
rotate={rotate}
|
|
389
|
-
|
|
397
|
+
events={triggerEvents}
|
|
390
398
|
/>
|
|
391
399
|
)}
|
|
392
400
|
{gridLine && (
|
|
@@ -429,7 +437,7 @@ export default memo(
|
|
|
429
437
|
>
|
|
430
438
|
<AxisLine
|
|
431
439
|
orientation={orientation}
|
|
432
|
-
config={{...axisLine,cHeight}}
|
|
440
|
+
config={{ ...axisLine, cHeight }}
|
|
433
441
|
range={range}
|
|
434
442
|
/>
|
|
435
443
|
{tickLine &&
|
|
@@ -473,7 +481,7 @@ export default memo(
|
|
|
473
481
|
<g transform={"translate(" + x + ", " + y + ")"}>
|
|
474
482
|
<AxisLine
|
|
475
483
|
orientation={orientation}
|
|
476
|
-
config={{...axisLine,cHeight}}
|
|
484
|
+
config={{ ...axisLine, cHeight }}
|
|
477
485
|
isClipAxis={isClipAxis}
|
|
478
486
|
clipAxisRange={clipAxisRange}
|
|
479
487
|
cPercent={cPercent}
|
|
@@ -487,23 +495,24 @@ export default memo(
|
|
|
487
495
|
<svg
|
|
488
496
|
width={width}
|
|
489
497
|
style={{
|
|
490
|
-
overflow:
|
|
491
|
-
axisType === "x" && isC ? "hidden":"visible",
|
|
498
|
+
overflow: axisType === "x" && isC ? "hidden" : "visible",
|
|
492
499
|
}}
|
|
493
500
|
>
|
|
494
501
|
<g transform={"translate(" + x + ", " + y + ")"}>
|
|
495
502
|
{/* 用于控制图 */}
|
|
496
503
|
<g ref={ref as any}>
|
|
497
504
|
{label && gridLine && drawLabel()}
|
|
498
|
-
{isC &&
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
+
{isC && (
|
|
506
|
+
<AxisLine
|
|
507
|
+
orientation={orientation}
|
|
508
|
+
config={{ ...axisLine, cHeight }}
|
|
509
|
+
isClipAxis={isClipAxis}
|
|
510
|
+
clipAxisRange={clipAxisRange}
|
|
511
|
+
cPercent={cPercent}
|
|
512
|
+
/>
|
|
513
|
+
)}
|
|
505
514
|
{isC && tickLine && drawAxisTickLine()}
|
|
506
|
-
{unit && <Unit config={unit} dataUnit={dataUnit}/>}
|
|
515
|
+
{unit && <Unit config={unit} dataUnit={dataUnit} />}
|
|
507
516
|
</g>
|
|
508
517
|
</g>
|
|
509
518
|
</svg>
|