@easyv/charts 1.8.6 → 1.8.8
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.
|
@@ -305,7 +305,6 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
305
305
|
});
|
|
306
306
|
});
|
|
307
307
|
var prevIndex = (0, _react.useRef)(null);
|
|
308
|
-
var domRef = (0, _react.useRef)();
|
|
309
308
|
var legendPrecision = legend.config.percent.precision;
|
|
310
309
|
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
311
310
|
id = _useContext.id,
|
|
@@ -519,9 +518,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
519
518
|
hoverData = _useState6[0],
|
|
520
519
|
setHoverData = _useState6[1];
|
|
521
520
|
var pieWarpEl = (0, _react.useRef)(null);
|
|
522
|
-
return outerDecorate ? /*#__PURE__*/_react["default"].createElement("
|
|
523
|
-
ref: domRef
|
|
524
|
-
}, /*#__PURE__*/_react["default"].createElement(_.ChartContainer //用于生成甜甜圈图,判断依据是外环装饰这个配置项(outerDecorate)
|
|
521
|
+
return outerDecorate ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer //用于生成甜甜圈图,判断依据是外环装饰这个配置项(outerDecorate)
|
|
525
522
|
, {
|
|
526
523
|
width: width,
|
|
527
524
|
height: height,
|
|
@@ -617,8 +614,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
617
614
|
x: halfChartWidth,
|
|
618
615
|
y: maxRadius + marginTop
|
|
619
616
|
},
|
|
620
|
-
mousePos: mousePos
|
|
621
|
-
domRef: domRef.current ? domRef : null
|
|
617
|
+
mousePos: mousePos
|
|
622
618
|
})), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
|
|
623
619
|
height: chartHeight,
|
|
624
620
|
series: _arcs.map(function (arc) {
|
|
@@ -628,9 +624,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
628
624
|
}),
|
|
629
625
|
formatter: formatter,
|
|
630
626
|
judge: judgeData
|
|
631
|
-
}))) : /*#__PURE__*/_react["default"].createElement("
|
|
632
|
-
ref: domRef
|
|
633
|
-
}, /*#__PURE__*/_react["default"].createElement(_.ChartContainer, {
|
|
627
|
+
}))) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer, {
|
|
634
628
|
width: width,
|
|
635
629
|
height: height,
|
|
636
630
|
marginLeft: marginLeft,
|
|
@@ -784,8 +778,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
784
778
|
x: halfChartWidth,
|
|
785
779
|
y: maxRadius + marginTop
|
|
786
780
|
},
|
|
787
|
-
mousePos: mousePos
|
|
788
|
-
domRef: domRef.current ? domRef : null
|
|
781
|
+
mousePos: mousePos
|
|
789
782
|
})), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
|
|
790
783
|
height: chartHeight,
|
|
791
784
|
series: _arcs.map(function (arc) {
|
|
@@ -17,7 +17,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
17
17
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
18
|
var PieTooltip = exports.PieTooltip = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
19
19
|
var mousePos = props.mousePos,
|
|
20
|
-
domRef = props.domRef,
|
|
21
20
|
pieCenter = props.pieCenter,
|
|
22
21
|
_props$config$tip = props.config.tip,
|
|
23
22
|
_props$config$tip$dat = _props$config$tip.data,
|
|
@@ -43,7 +42,6 @@ var PieTooltip = exports.PieTooltip = /*#__PURE__*/(0, _react.memo)(function (pr
|
|
|
43
42
|
translateTip = _props$config$tip.translate,
|
|
44
43
|
data = props.data,
|
|
45
44
|
series = props.series;
|
|
46
|
-
var screenRef = domRef.current.getBoundingClientRect();
|
|
47
45
|
var Item = function Item() {
|
|
48
46
|
var _data$data = data.data,
|
|
49
47
|
s = _data$data.s,
|
|
@@ -99,84 +97,45 @@ var PieTooltip = exports.PieTooltip = /*#__PURE__*/(0, _react.memo)(function (pr
|
|
|
99
97
|
centerY = pieCenter.y;
|
|
100
98
|
var getTipPos = function getTipPos() {
|
|
101
99
|
var getBigscreenScale = function getBigscreenScale() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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)];
|
|
108
116
|
}
|
|
109
|
-
}
|
|
110
|
-
|
|
117
|
+
} else {
|
|
118
|
+
return [1, 1];
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
|
-
|
|
114
|
-
// 获取容器元素
|
|
115
|
-
var bigscreenDom = document.getElementById('bigscreen-container');
|
|
116
|
-
|
|
117
|
-
// 元素不存在时的处理
|
|
118
|
-
if (!bigscreenDom) {
|
|
119
|
-
console.warn('未找到 bigscreen-container 元素,使用视口尺寸');
|
|
120
|
-
return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// 确保元素可见(未被隐藏)
|
|
124
|
-
var isVisible = window.getComputedStyle(bigscreenDom).display !== 'none' && window.getComputedStyle(bigscreenDom).visibility !== 'hidden';
|
|
125
|
-
if (!isVisible) {
|
|
126
|
-
console.warn('bigscreen-container 元素不可见,使用视口尺寸');
|
|
127
|
-
return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// 获取元素的布局矩形(最可靠的尺寸获取方式)
|
|
131
|
-
var rect = bigscreenDom.getBoundingClientRect();
|
|
132
|
-
|
|
133
|
-
// 提取基础尺寸(从布局矩形获取,不受样式影响)
|
|
134
|
-
var screenWidth = rect.width || window.innerWidth;
|
|
135
|
-
var screenHeight = rect.height || window.innerHeight;
|
|
136
|
-
var screenLeft = rect.left || 0;
|
|
137
|
-
var screenTop = rect.top || 0;
|
|
138
|
-
|
|
139
|
-
// 处理缩放
|
|
140
|
-
var scaleX = 1;
|
|
141
|
-
var scaleY = 1;
|
|
142
|
-
try {
|
|
143
|
-
var computedStyle = window.getComputedStyle(bigscreenDom);
|
|
144
|
-
var transform = computedStyle.transform;
|
|
145
|
-
if (transform && transform !== 'none') {
|
|
146
|
-
// 解析 transform matrix
|
|
147
|
-
var matrix = new DOMMatrix(transform);
|
|
148
|
-
scaleX = matrix.a; // 缩放X因子
|
|
149
|
-
scaleY = matrix.d; // 缩放Y因子
|
|
150
|
-
}
|
|
151
|
-
} catch (e) {
|
|
152
|
-
console.error('解析缩放样式出错:', e);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// 最终返回值(确保不会有undefined)
|
|
156
|
-
var result = [isNaN(scaleX) ? 1 : scaleX, isNaN(scaleY) ? 1 : scaleY, isNaN(screenWidth) ? window.innerWidth : screenWidth, isNaN(screenHeight) ? window.innerHeight : screenHeight, isNaN(screenLeft) ? 0 : screenLeft, isNaN(screenTop) ? 0 : screenTop];
|
|
157
|
-
return result;
|
|
158
121
|
};
|
|
159
122
|
var _getBigscreenScale = getBigscreenScale(),
|
|
160
|
-
_getBigscreenScale2 = (0, _slicedToArray2["default"])(_getBigscreenScale,
|
|
123
|
+
_getBigscreenScale2 = (0, _slicedToArray2["default"])(_getBigscreenScale, 2),
|
|
161
124
|
scaleX = _getBigscreenScale2[0],
|
|
162
|
-
scaleY = _getBigscreenScale2[1]
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
screenLeft = _getBigscreenScale2[4],
|
|
166
|
-
screenTop = _getBigscreenScale2[5];
|
|
167
|
-
// const _mouseX = mouseX / scaleX
|
|
168
|
-
// const _mouseY = mouseY / scaleY
|
|
125
|
+
scaleY = _getBigscreenScale2[1];
|
|
126
|
+
var _mouseX = mouseX / scaleX;
|
|
127
|
+
var _mouseY = mouseY / scaleY;
|
|
169
128
|
var tipPosMap = {
|
|
170
|
-
rightTop: "translate(".concat(
|
|
171
|
-
leftTop: "translate(".concat(
|
|
172
|
-
leftBottom: "translate(".concat(
|
|
173
|
-
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)")
|
|
174
133
|
};
|
|
175
|
-
if (
|
|
134
|
+
if (_mouseX < centerX && _mouseY < centerY) {
|
|
176
135
|
return tipPosMap.leftTop;
|
|
177
|
-
} else if (
|
|
136
|
+
} else if (_mouseX > centerX && _mouseY < centerY) {
|
|
178
137
|
return tipPosMap.rightTop;
|
|
179
|
-
} else if (
|
|
138
|
+
} else if (_mouseX >= centerX && _mouseY >= centerY) {
|
|
180
139
|
return tipPosMap.rightBottom;
|
|
181
140
|
} else {
|
|
182
141
|
return tipPosMap.leftBottom;
|
package/package.json
CHANGED
|
@@ -292,7 +292,6 @@ const Component = memo(
|
|
|
292
292
|
}) => {
|
|
293
293
|
const data = originData.map((d) => ({ ...d, y: d.y < 0 ? 0 : d.y }));
|
|
294
294
|
const prevIndex = useRef(null);
|
|
295
|
-
const domRef=useRef()
|
|
296
295
|
const { precision: legendPrecision } = legend.config.percent;
|
|
297
296
|
const {
|
|
298
297
|
id,
|
|
@@ -514,7 +513,7 @@ const Component = memo(
|
|
|
514
513
|
const [hoverData, setHoverData] = useState(null);
|
|
515
514
|
const pieWarpEl = useRef(null);
|
|
516
515
|
return outerDecorate ? (
|
|
517
|
-
|
|
516
|
+
<>
|
|
518
517
|
<ChartContainer //用于生成甜甜圈图,判断依据是外环装饰这个配置项(outerDecorate)
|
|
519
518
|
width={width}
|
|
520
519
|
height={height}
|
|
@@ -636,7 +635,6 @@ const Component = memo(
|
|
|
636
635
|
y: maxRadius + marginTop,
|
|
637
636
|
}}
|
|
638
637
|
mousePos={mousePos}
|
|
639
|
-
domRef={domRef.current ? domRef : null}
|
|
640
638
|
/>
|
|
641
639
|
</div>
|
|
642
640
|
)}
|
|
@@ -650,9 +648,9 @@ const Component = memo(
|
|
|
650
648
|
formatter={formatter}
|
|
651
649
|
judge={judgeData}
|
|
652
650
|
/>
|
|
653
|
-
|
|
651
|
+
</>
|
|
654
652
|
) : (
|
|
655
|
-
|
|
653
|
+
<>
|
|
656
654
|
<ChartContainer
|
|
657
655
|
width={width}
|
|
658
656
|
height={height}
|
|
@@ -898,7 +896,6 @@ const Component = memo(
|
|
|
898
896
|
y: maxRadius + marginTop,
|
|
899
897
|
}}
|
|
900
898
|
mousePos={mousePos}
|
|
901
|
-
domRef={domRef.current ? domRef : null}
|
|
902
899
|
/>
|
|
903
900
|
</div>
|
|
904
901
|
)}
|
|
@@ -912,7 +909,7 @@ const Component = memo(
|
|
|
912
909
|
formatter={formatter}
|
|
913
910
|
judge={judgeData}
|
|
914
911
|
/>
|
|
915
|
-
|
|
912
|
+
</>
|
|
916
913
|
);
|
|
917
914
|
}
|
|
918
915
|
);
|
|
@@ -3,7 +3,7 @@ import { getFontStyle, getMargin, getTranslate3d, getTranslate2d, getIcon } from
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const PieTooltip = memo((props) => {
|
|
6
|
-
const { mousePos,
|
|
6
|
+
const { mousePos,
|
|
7
7
|
pieCenter,
|
|
8
8
|
config: {
|
|
9
9
|
tip: {
|
|
@@ -19,7 +19,7 @@ export const PieTooltip = memo((props) => {
|
|
|
19
19
|
},
|
|
20
20
|
data,
|
|
21
21
|
series } = props
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
const Item = () => {
|
|
24
24
|
const { data: { s, y }, percent } = data
|
|
25
25
|
const { type, icon, displayName } = [...series.values()].find(
|
|
@@ -87,93 +87,43 @@ export const PieTooltip = memo((props) => {
|
|
|
87
87
|
const { x: centerX, y: centerY } = pieCenter
|
|
88
88
|
const getTipPos = () => {
|
|
89
89
|
|
|
90
|
-
const getBigscreenScale = () => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
console.warn('bigscreen-container 元素不可见,使用视口尺寸');
|
|
117
|
-
return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// 获取元素的布局矩形(最可靠的尺寸获取方式)
|
|
121
|
-
const rect = bigscreenDom.getBoundingClientRect();
|
|
122
|
-
|
|
123
|
-
// 提取基础尺寸(从布局矩形获取,不受样式影响)
|
|
124
|
-
const screenWidth = rect.width || window.innerWidth;
|
|
125
|
-
const screenHeight = rect.height || window.innerHeight;
|
|
126
|
-
const screenLeft = rect.left || 0;
|
|
127
|
-
const screenTop = rect.top || 0;
|
|
128
|
-
|
|
129
|
-
// 处理缩放
|
|
130
|
-
let scaleX = 1;
|
|
131
|
-
let scaleY = 1;
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
const computedStyle = window.getComputedStyle(bigscreenDom);
|
|
135
|
-
const transform = computedStyle.transform;
|
|
136
|
-
|
|
137
|
-
if (transform && transform !== 'none') {
|
|
138
|
-
// 解析 transform matrix
|
|
139
|
-
const matrix = new DOMMatrix(transform);
|
|
140
|
-
scaleX = matrix.a; // 缩放X因子
|
|
141
|
-
scaleY = matrix.d; // 缩放Y因子
|
|
142
|
-
}
|
|
143
|
-
} catch (e) {
|
|
144
|
-
console.error('解析缩放样式出错:', e);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// 最终返回值(确保不会有undefined)
|
|
148
|
-
const result = [
|
|
149
|
-
isNaN(scaleX) ? 1 : scaleX,
|
|
150
|
-
isNaN(scaleY) ? 1 : scaleY,
|
|
151
|
-
isNaN(screenWidth) ? window.innerWidth : screenWidth,
|
|
152
|
-
isNaN(screenHeight) ? window.innerHeight : screenHeight,
|
|
153
|
-
isNaN(screenLeft) ? 0 : screenLeft,
|
|
154
|
-
isNaN(screenTop) ? 0 : screenTop
|
|
155
|
-
];
|
|
156
|
-
return result;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const [scaleX, scaleY,screenWidth,screenHeight,screenLeft,screenTop] = getBigscreenScale()
|
|
160
|
-
// const _mouseX = mouseX / scaleX
|
|
161
|
-
// const _mouseY = mouseY / scaleY
|
|
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
|
|
162
116
|
const tipPosMap = {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
rightBottom: `translate(${(screenRef.x+tipWidth)/scaleX+mouseX-screenLeft+translateTip.x>screenWidth?mouseX -tipWidth- translateTip.x:mouseX + translateTip.x}px,
|
|
170
|
-
${(screenRef.y+tipHeight)/scaleY+mouseY-screenTop+translateTip.y>screenHeight? mouseY- tipHeight- translateTip.y: mouseY + translateTip.y}px)`,
|
|
171
|
-
}
|
|
172
|
-
if (mouseX < centerX && mouseY < centerY) {
|
|
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) {
|
|
173
123
|
return tipPosMap.leftTop
|
|
174
|
-
} else if (
|
|
124
|
+
} else if (_mouseX > centerX && _mouseY < centerY) {
|
|
175
125
|
return tipPosMap.rightTop
|
|
176
|
-
} else if (
|
|
126
|
+
} else if (_mouseX >= centerX && _mouseY >= centerY) {
|
|
177
127
|
return tipPosMap.rightBottom
|
|
178
128
|
} else {
|
|
179
129
|
return tipPosMap.leftBottom
|