@easyv/charts 1.4.28 → 1.4.29
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/CartesianChart.js +1 -1
- package/lib/components/Chart.js +9 -6
- package/lib/components/PieChart.js +7 -7
- package/lib/components/pieTooltip.js +37 -7
- package/package.json +1 -1
- package/src/components/CartesianChart.js +1 -1
- package/src/components/Chart.js +8 -6
- package/src/components/PieChart.js +19 -12
- package/src/components/PieTooltip.jsx +149 -122
|
@@ -138,7 +138,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
138
138
|
e.stopPropagation();
|
|
139
139
|
var data = e.currentTarget.dataset.data;
|
|
140
140
|
var _data = JSON.parse(data);
|
|
141
|
-
triggerOnRelative(_data);
|
|
141
|
+
triggerOnRelative('click', _data);
|
|
142
142
|
onEmit("click", _data);
|
|
143
143
|
}, [triggerOnRelative, onEmit]);
|
|
144
144
|
|
package/lib/components/Chart.js
CHANGED
|
@@ -17,14 +17,17 @@ var _excluded = ["id", "type", "config", "config", "data", "onRelative", "emit",
|
|
|
17
17
|
*/
|
|
18
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
19
|
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; }
|
|
20
|
-
var getCallbackData = function getCallbackData(callbacks, data) {
|
|
20
|
+
var getCallbackData = function getCallbackData(action, callbacks, data) {
|
|
21
21
|
var callbackData;
|
|
22
22
|
if (callbacks && Array.isArray(callbacks) && callbacks.length && data) {
|
|
23
|
-
callbackData = {};
|
|
24
23
|
callbacks.forEach(function (_ref) {
|
|
25
24
|
var origin = _ref.origin,
|
|
26
|
-
target = _ref.target
|
|
27
|
-
|
|
25
|
+
target = _ref.target,
|
|
26
|
+
_action = _ref.actions;
|
|
27
|
+
if (action === _action) {
|
|
28
|
+
callbackData = {};
|
|
29
|
+
callbackData[target] = data[origin];
|
|
30
|
+
}
|
|
28
31
|
});
|
|
29
32
|
}
|
|
30
33
|
return callbackData;
|
|
@@ -52,11 +55,11 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
52
55
|
var svg = /*#__PURE__*/(0, _react.createRef)();
|
|
53
56
|
var chartWidth = width - marginLeft - marginRight;
|
|
54
57
|
var chartHeight = height - marginTop - marginBottom;
|
|
55
|
-
var triggerOnRelative = (0, _react.useCallback)(function (data) {
|
|
58
|
+
var triggerOnRelative = (0, _react.useCallback)(function (action, data) {
|
|
56
59
|
if (!interaction) return;
|
|
57
60
|
var callbacks = interaction.callbacks,
|
|
58
61
|
remoteControls = interaction.remoteControls;
|
|
59
|
-
var callbackData = getCallbackData(callbacks, data);
|
|
62
|
+
var callbackData = getCallbackData(action, callbacks, data);
|
|
60
63
|
if (callbackData) {
|
|
61
64
|
onRelative && onRelative(id, callbackData);
|
|
62
65
|
remoteControls && emitEvent && remoteControls.forEach(function (o) {
|
|
@@ -418,15 +418,15 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
418
418
|
});
|
|
419
419
|
}, [series, arcs, radius]);
|
|
420
420
|
var onClick = (0, _react.useCallback)(function (e) {
|
|
421
|
-
|
|
421
|
+
onEvent({
|
|
422
422
|
currentIndex: +e.currentTarget.dataset.index,
|
|
423
423
|
type: "onClick"
|
|
424
424
|
});
|
|
425
425
|
}, [onEvent]);
|
|
426
426
|
var onMouseEnter = (0, _react.useCallback)(function (e) {
|
|
427
|
-
var _data = arcs[+
|
|
428
|
-
triggerOnRelative(_data);
|
|
429
|
-
onEmit("
|
|
427
|
+
var _data = arcs[+e.currentTarget.dataset.index].data;
|
|
428
|
+
triggerOnRelative('mousehover', _data);
|
|
429
|
+
onEmit("mousehover", _data);
|
|
430
430
|
onEvent({
|
|
431
431
|
currentIndex: +e.currentTarget.dataset.index,
|
|
432
432
|
type: "onMouseEnter"
|
|
@@ -456,15 +456,15 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
456
456
|
},
|
|
457
457
|
onComplete: function onComplete() {
|
|
458
458
|
var _data = arcs[+currentIndex].data;
|
|
459
|
-
triggerOnRelative(_data);
|
|
459
|
+
triggerOnRelative("carousel", _data);
|
|
460
460
|
onEmit("carousel", _data);
|
|
461
461
|
}
|
|
462
462
|
});
|
|
463
463
|
} else {
|
|
464
464
|
if (currentIndex !== null && trigger === "onClick") {
|
|
465
465
|
var _data = arcs[+currentIndex].data;
|
|
466
|
-
triggerOnRelative(_data);
|
|
467
|
-
onEmit(
|
|
466
|
+
triggerOnRelative('click', _data);
|
|
467
|
+
onEmit('click', _data);
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
return function () {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.PieTooltip = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -95,17 +96,46 @@ var PieTooltip = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
95
96
|
var centerX = pieCenter.x,
|
|
96
97
|
centerY = pieCenter.y;
|
|
97
98
|
var getTipPos = function getTipPos() {
|
|
99
|
+
var getBigscreenScale = function getBigscreenScale() {
|
|
100
|
+
if (window.getScreenScale) {
|
|
101
|
+
return window.getScreenScale();
|
|
102
|
+
} else {
|
|
103
|
+
var bigscreenDom = document.getElementById('bigscreen-container');
|
|
104
|
+
if (!bigscreenDom) return [1, 1];
|
|
105
|
+
var transform = bigscreenDom.style.transform;
|
|
106
|
+
if (!transform) return [1, 1];
|
|
107
|
+
var match = transform.match(/scale\(([^)]+)\)/);
|
|
108
|
+
if (match) {
|
|
109
|
+
var scaleMatch = match[1].split(',');
|
|
110
|
+
var _scaleX = scaleMatch[0];
|
|
111
|
+
var _scaleY = scaleMatch[1];
|
|
112
|
+
if (_scaleY) {
|
|
113
|
+
return [Number(_scaleX), Number(_scaleY)];
|
|
114
|
+
} else {
|
|
115
|
+
return [Number(_scaleX), Number(_scaleX)];
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
return [1, 1];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var _getBigscreenScale = getBigscreenScale(),
|
|
123
|
+
_getBigscreenScale2 = (0, _slicedToArray2["default"])(_getBigscreenScale, 2),
|
|
124
|
+
scaleX = _getBigscreenScale2[0],
|
|
125
|
+
scaleY = _getBigscreenScale2[1];
|
|
126
|
+
var _mouseX = mouseX / scaleX;
|
|
127
|
+
var _mouseY = mouseY / scaleY;
|
|
98
128
|
var tipPosMap = {
|
|
99
|
-
rightTop: "translate(".concat(
|
|
100
|
-
leftTop: "translate(".concat(
|
|
101
|
-
leftBottom: "translate(".concat(
|
|
102
|
-
rightBottom: "translate(".concat(
|
|
129
|
+
rightTop: "translate(".concat(_mouseX + translateTip.x, "px,").concat(_mouseY - tipHeight - translateTip.y, "px)"),
|
|
130
|
+
leftTop: "translate(".concat(_mouseX - tipWidth - translateTip.x, "px,").concat(_mouseY - tipHeight - translateTip.y, "px)"),
|
|
131
|
+
leftBottom: "translate(".concat(_mouseX - tipWidth - translateTip.x, "px,").concat(_mouseY + translateTip.y, "px)"),
|
|
132
|
+
rightBottom: "translate(".concat(_mouseX + translateTip.x, "px,").concat(_mouseY + translateTip.y, "px)")
|
|
103
133
|
};
|
|
104
|
-
if (
|
|
134
|
+
if (_mouseX < centerX && _mouseY < centerY) {
|
|
105
135
|
return tipPosMap.leftTop;
|
|
106
|
-
} else if (
|
|
136
|
+
} else if (_mouseX > centerX && _mouseY < centerY) {
|
|
107
137
|
return tipPosMap.rightTop;
|
|
108
|
-
} else if (
|
|
138
|
+
} else if (_mouseX >= centerX && _mouseY >= centerY) {
|
|
109
139
|
return tipPosMap.rightBottom;
|
|
110
140
|
} else {
|
|
111
141
|
return tipPosMap.leftBottom;
|
package/package.json
CHANGED
|
@@ -152,7 +152,7 @@ const Chart = memo(
|
|
|
152
152
|
e.stopPropagation();
|
|
153
153
|
const { data } = e.currentTarget.dataset;
|
|
154
154
|
const _data = JSON.parse(data);
|
|
155
|
-
triggerOnRelative(_data);
|
|
155
|
+
triggerOnRelative('click',_data);
|
|
156
156
|
onEmit("click", _data);
|
|
157
157
|
},
|
|
158
158
|
[triggerOnRelative, onEmit]
|
package/src/components/Chart.js
CHANGED
|
@@ -5,12 +5,14 @@ import React, { memo, useMemo, createRef, useCallback } from 'react';
|
|
|
5
5
|
import { chartContext } from '../context';
|
|
6
6
|
import { PieChart, CartesianChart } from '.';
|
|
7
7
|
|
|
8
|
-
const getCallbackData = (callbacks, data) => {
|
|
8
|
+
const getCallbackData = (action,callbacks, data) => {
|
|
9
9
|
let callbackData;
|
|
10
10
|
if (callbacks && Array.isArray(callbacks) && callbacks.length && data) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
callbacks.forEach(({ origin, target, actions:_action }) => {
|
|
12
|
+
if(action === _action){
|
|
13
|
+
callbackData = {};
|
|
14
|
+
callbackData[target] = data[origin];
|
|
15
|
+
}
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
return callbackData;
|
|
@@ -41,10 +43,10 @@ const Chart = memo(
|
|
|
41
43
|
const chartHeight = height - marginTop - marginBottom;
|
|
42
44
|
|
|
43
45
|
const triggerOnRelative = useCallback(
|
|
44
|
-
(data) => {
|
|
46
|
+
(action,data) => {
|
|
45
47
|
if (!interaction) return;
|
|
46
48
|
const { callbacks, remoteControls } = interaction;
|
|
47
|
-
const callbackData = getCallbackData(callbacks, data);
|
|
49
|
+
const callbackData = getCallbackData(action,callbacks, data);
|
|
48
50
|
if (callbackData) {
|
|
49
51
|
onRelative && onRelative(id, callbackData);
|
|
50
52
|
remoteControls &&
|
|
@@ -34,7 +34,7 @@ import { pieLegendFormatter as legendFormatter } from "../formatter";
|
|
|
34
34
|
import ringCss from "../css/piechart.module.css";
|
|
35
35
|
import { useAiDataOfPie } from "../hooks";
|
|
36
36
|
import { PieTooltip } from "./PieTooltip";
|
|
37
|
-
import { toFixed } from
|
|
37
|
+
import { toFixed } from "@easyv/utils/lib/common/utils";
|
|
38
38
|
|
|
39
39
|
const PI = Math.PI;
|
|
40
40
|
|
|
@@ -399,19 +399,20 @@ const Component = memo(
|
|
|
399
399
|
}, [series, arcs, radius]);
|
|
400
400
|
|
|
401
401
|
const onClick = useCallback(
|
|
402
|
-
(e) =>
|
|
402
|
+
(e) => {
|
|
403
403
|
onEvent({
|
|
404
404
|
currentIndex: +e.currentTarget.dataset.index,
|
|
405
405
|
type: "onClick",
|
|
406
|
-
})
|
|
406
|
+
});
|
|
407
|
+
},
|
|
407
408
|
[onEvent]
|
|
408
409
|
);
|
|
409
410
|
|
|
410
411
|
const onMouseEnter = useCallback(
|
|
411
412
|
(e) => {
|
|
412
|
-
const _data = arcs[+
|
|
413
|
-
triggerOnRelative(_data);
|
|
414
|
-
onEmit("
|
|
413
|
+
const _data = arcs[+e.currentTarget.dataset.index].data;
|
|
414
|
+
triggerOnRelative('mousehover',_data);
|
|
415
|
+
onEmit("mousehover", _data);
|
|
415
416
|
onEvent({
|
|
416
417
|
currentIndex: +e.currentTarget.dataset.index,
|
|
417
418
|
type: "onMouseEnter",
|
|
@@ -448,15 +449,15 @@ const Component = memo(
|
|
|
448
449
|
},
|
|
449
450
|
onComplete: () => {
|
|
450
451
|
const _data = arcs[+currentIndex].data;
|
|
451
|
-
triggerOnRelative(_data);
|
|
452
|
+
triggerOnRelative("carousel",_data);
|
|
452
453
|
onEmit("carousel", _data);
|
|
453
454
|
},
|
|
454
455
|
});
|
|
455
456
|
} else {
|
|
456
457
|
if (currentIndex !== null && trigger === "onClick") {
|
|
457
458
|
const _data = arcs[+currentIndex].data;
|
|
458
|
-
triggerOnRelative(_data);
|
|
459
|
-
onEmit(
|
|
459
|
+
triggerOnRelative('click',_data);
|
|
460
|
+
onEmit('click', _data);
|
|
460
461
|
}
|
|
461
462
|
}
|
|
462
463
|
return () => {
|
|
@@ -564,7 +565,7 @@ const Component = memo(
|
|
|
564
565
|
onClick={onClick}
|
|
565
566
|
onMouseEnter={onMouseEnter}
|
|
566
567
|
onMouseLeave={onMouseLeave}
|
|
567
|
-
onMouseMove={(e)=>{
|
|
568
|
+
onMouseMove={(e) => {
|
|
568
569
|
const _data = arcs[+e.currentTarget.dataset.index];
|
|
569
570
|
const warpBoxPos = {
|
|
570
571
|
x: pieWarpEl.current.getBoundingClientRect().x,
|
|
@@ -620,7 +621,10 @@ const Component = memo(
|
|
|
620
621
|
)}
|
|
621
622
|
<Legend
|
|
622
623
|
{...legend}
|
|
623
|
-
series={_arcs.map((arc)=>({
|
|
624
|
+
series={_arcs.map((arc) => ({
|
|
625
|
+
...arc,
|
|
626
|
+
percent: arc.percent.toFixed(legendPrecision),
|
|
627
|
+
}))}
|
|
624
628
|
formatter={formatter}
|
|
625
629
|
judge={judgeData}
|
|
626
630
|
/>
|
|
@@ -856,7 +860,10 @@ const Component = memo(
|
|
|
856
860
|
)}
|
|
857
861
|
<Legend
|
|
858
862
|
{...legend}
|
|
859
|
-
series={_arcs.map((arc)=>({
|
|
863
|
+
series={_arcs.map((arc) => ({
|
|
864
|
+
...arc,
|
|
865
|
+
percent: arc.percent.toFixed(legendPrecision),
|
|
866
|
+
}))}
|
|
860
867
|
formatter={formatter}
|
|
861
868
|
judge={judgeData}
|
|
862
869
|
/>
|
|
@@ -3,132 +3,159 @@ import { getFontStyle, getMargin, getTranslate3d, getTranslate2d, getIcon } from
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const PieTooltip = memo((props) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
const { mousePos,
|
|
7
|
+
pieCenter,
|
|
8
|
+
config: {
|
|
9
|
+
tip: {
|
|
10
|
+
data: { lineHeight, iconSize, name,
|
|
11
|
+
value: { show: valueIsShow, fontStyle: valueFont, suffix: valueSuffix, suffix: { show: valueSuffixIsShow } },
|
|
12
|
+
percentage: { show: percentageIsShow, fontStyle: percentageFont, suffix: percentageSuffix, suffix: { show: percentageSuffixIsShow }, precision },
|
|
13
|
+
},
|
|
14
|
+
image,
|
|
15
|
+
margin,
|
|
16
|
+
size: { width: tipWidth, height: tipHeight },
|
|
17
|
+
translate: translateTip,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
data,
|
|
21
|
+
series } = props
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const Item = () => {
|
|
24
|
+
const { data: { s, y }, percent } = data
|
|
25
|
+
const { type, icon, displayName } = [...series.values()].find(
|
|
26
|
+
(series) => series.name == s
|
|
27
|
+
);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
const renderSuffix = (suffix) => {
|
|
30
|
+
const {
|
|
31
|
+
content,
|
|
32
|
+
font: suffiixFont,
|
|
33
|
+
translate: suffixTranslate,
|
|
34
|
+
} = suffix;
|
|
35
|
+
return (
|
|
36
|
+
<span
|
|
37
|
+
style={{
|
|
38
|
+
...getFontStyle(suffiixFont),
|
|
39
|
+
display: "inline-block",
|
|
40
|
+
transform: getTranslate3d(suffixTranslate),
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{content}
|
|
44
|
+
</span>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const _icon = getIcon(type, icon);
|
|
49
|
+
return (
|
|
50
|
+
<dd
|
|
51
|
+
style={{
|
|
52
|
+
display: 'flex',
|
|
53
|
+
justifyContent: 'space-between',
|
|
54
|
+
lineHeight: lineHeight + 'px',
|
|
55
|
+
}}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const tipPosMap = {
|
|
90
|
-
rightTop: `translate(${mouseX + translateTip.x}px,${mouseY - tipHeight - translateTip.y}px)`,
|
|
91
|
-
leftTop: `translate(${mouseX - tipWidth - translateTip.x}px,${mouseY - tipHeight - translateTip.y}px)`,
|
|
92
|
-
leftBottom: `translate(${mouseX - tipWidth - translateTip.x}px,${mouseY + translateTip.y}px)`,
|
|
93
|
-
rightBottom: `translate(${mouseX + translateTip.x}px,${mouseY + translateTip.y}px)`,
|
|
94
|
-
}
|
|
95
|
-
if (mouseX < centerX && mouseY < centerY) {
|
|
96
|
-
return tipPosMap.leftTop
|
|
97
|
-
} else if (mouseX > centerX && mouseY < centerY) {
|
|
98
|
-
return tipPosMap.rightTop
|
|
99
|
-
} else if (mouseX >= centerX && mouseY >= centerY) {
|
|
100
|
-
return tipPosMap.rightBottom
|
|
101
|
-
} else {
|
|
102
|
-
return tipPosMap.leftBottom
|
|
103
|
-
}
|
|
104
|
-
}
|
|
57
|
+
>
|
|
58
|
+
<span
|
|
59
|
+
style={{
|
|
60
|
+
// border: '1px solid red',
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
gap: icon.iconGap,
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<span
|
|
67
|
+
style={{
|
|
68
|
+
..._icon,
|
|
69
|
+
width: iconSize + 'px',
|
|
70
|
+
height: iconSize + 'px',
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
<span style={getFontStyle(name)}>{displayName || s}</span>
|
|
74
|
+
</span>
|
|
75
|
+
{valueIsShow && <span style={getFontStyle(valueFont)}>
|
|
76
|
+
{y}
|
|
77
|
+
{valueSuffixIsShow && renderSuffix(valueSuffix)}
|
|
78
|
+
</span>}
|
|
79
|
+
{percentageIsShow && <span style={getFontStyle(percentageFont)}>
|
|
80
|
+
{Number(percent).toFixed(precision)}
|
|
81
|
+
{percentageSuffixIsShow && renderSuffix(percentageSuffix)}
|
|
82
|
+
</span>}
|
|
83
|
+
</dd>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const { x: mouseX, y: mouseY } = mousePos
|
|
87
|
+
const { x: centerX, y: centerY } = pieCenter
|
|
88
|
+
const getTipPos = () => {
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
90
|
+
const getBigscreenScale = () => {
|
|
91
|
+
if (window.getScreenScale) {
|
|
92
|
+
return window.getScreenScale()
|
|
93
|
+
} else {
|
|
94
|
+
const bigscreenDom = document.getElementById('bigscreen-container')
|
|
95
|
+
if (!bigscreenDom) return [1, 1]
|
|
96
|
+
const transform = bigscreenDom.style.transform
|
|
97
|
+
if (!transform) return [1, 1]
|
|
98
|
+
let match = transform.match(/scale\(([^)]+)\)/)
|
|
99
|
+
if (match) {
|
|
100
|
+
const scaleMatch = match[1].split(',')
|
|
101
|
+
let scaleX = scaleMatch[0];
|
|
102
|
+
let scaleY = scaleMatch[1];
|
|
103
|
+
if (scaleY) {
|
|
104
|
+
return [Number(scaleX), Number(scaleY)]
|
|
105
|
+
} else {
|
|
106
|
+
return [Number(scaleX), Number(scaleX)]
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
return [1, 1]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const [scaleX, scaleY] = getBigscreenScale()
|
|
114
|
+
const _mouseX = mouseX / scaleX
|
|
115
|
+
const _mouseY = mouseY / scaleY
|
|
116
|
+
const tipPosMap = {
|
|
117
|
+
rightTop: `translate(${_mouseX + translateTip.x}px,${_mouseY - tipHeight - translateTip.y}px)`,
|
|
118
|
+
leftTop: `translate(${_mouseX - tipWidth - translateTip.x}px,${_mouseY - tipHeight - translateTip.y}px)`,
|
|
119
|
+
leftBottom: `translate(${_mouseX - tipWidth - translateTip.x}px,${_mouseY + translateTip.y}px)`,
|
|
120
|
+
rightBottom: `translate(${_mouseX + translateTip.x}px,${(_mouseY + translateTip.y)}px)`,
|
|
121
|
+
}
|
|
122
|
+
if (_mouseX < centerX && _mouseY < centerY) {
|
|
123
|
+
return tipPosMap.leftTop
|
|
124
|
+
} else if (_mouseX > centerX && _mouseY < centerY) {
|
|
125
|
+
return tipPosMap.rightTop
|
|
126
|
+
} else if (_mouseX >= centerX && _mouseY >= centerY) {
|
|
127
|
+
return tipPosMap.rightBottom
|
|
128
|
+
} else {
|
|
129
|
+
return tipPosMap.leftBottom
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
return <div
|
|
134
|
+
className='__easyv-tooltip'
|
|
135
|
+
style={{
|
|
136
|
+
pointerEvents: 'none',
|
|
137
|
+
transform: getTipPos(mousePos, pieCenter),
|
|
138
|
+
width: tipWidth,
|
|
139
|
+
height: tipHeight,
|
|
140
|
+
padding: getMargin(margin),
|
|
141
|
+
background: image
|
|
142
|
+
? '50% 50% / 100% 100% no-repeat url(' +
|
|
143
|
+
window.appConfig.ASSETS_URL +
|
|
144
|
+
image +
|
|
145
|
+
')'
|
|
146
|
+
: 'rgba(48, 55, 66, 0.85)',
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
<dl
|
|
150
|
+
style={{
|
|
151
|
+
display: 'flex',
|
|
152
|
+
flexDirection: 'column',
|
|
153
|
+
justifyContent: 'space-between',
|
|
154
|
+
height: '100%',
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
{Item()}
|
|
158
|
+
</dl>
|
|
159
|
+
|
|
160
|
+
</div>
|
|
134
161
|
})
|