@easyv/charts 1.4.26 → 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.
@@ -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
 
@@ -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
- callbackData[target] = data[origin];
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) {
@@ -22,6 +22,7 @@ var _formatter = require("../formatter");
22
22
  var _piechartModule = _interopRequireDefault(require("../css/piechart.module.css"));
23
23
  var _hooks = require("../hooks");
24
24
  var _PieTooltip = require("./PieTooltip");
25
+ var _utils2 = require("@easyv/utils/lib/common/utils");
25
26
  var _excluded = ["startAngle", "endAngle", "antiClockwise"],
26
27
  _excluded2 = ["padAngle", "innerRadius", "outerRadius", "cornerRadius", "startAngle", "endAngle"],
27
28
  _excluded3 = ["formatter"],
@@ -417,15 +418,15 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
417
418
  });
418
419
  }, [series, arcs, radius]);
419
420
  var onClick = (0, _react.useCallback)(function (e) {
420
- return onEvent({
421
+ onEvent({
421
422
  currentIndex: +e.currentTarget.dataset.index,
422
423
  type: "onClick"
423
424
  });
424
425
  }, [onEvent]);
425
426
  var onMouseEnter = (0, _react.useCallback)(function (e) {
426
- var _data = arcs[+currentIndex].data;
427
- triggerOnRelative(_data);
428
- onEmit("onMouseEnter", _data);
427
+ var _data = arcs[+e.currentTarget.dataset.index].data;
428
+ triggerOnRelative('mousehover', _data);
429
+ onEmit("mousehover", _data);
429
430
  onEvent({
430
431
  currentIndex: +e.currentTarget.dataset.index,
431
432
  type: "onMouseEnter"
@@ -455,15 +456,15 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
455
456
  },
456
457
  onComplete: function onComplete() {
457
458
  var _data = arcs[+currentIndex].data;
458
- triggerOnRelative(_data);
459
+ triggerOnRelative("carousel", _data);
459
460
  onEmit("carousel", _data);
460
461
  }
461
462
  });
462
463
  } else {
463
464
  if (currentIndex !== null && trigger === "onClick") {
464
465
  var _data = arcs[+currentIndex].data;
465
- triggerOnRelative(_data);
466
- onEmit(trigger, _data);
466
+ triggerOnRelative('click', _data);
467
+ onEmit('click', _data);
467
468
  }
468
469
  }
469
470
  return function () {
@@ -592,7 +593,11 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
592
593
  },
593
594
  mousePos: mousePos
594
595
  }), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
595
- series: _arcs,
596
+ series: _arcs.map(function (arc) {
597
+ return _objectSpread(_objectSpread({}, arc), {}, {
598
+ percent: arc.percent.toFixed(legendPrecision)
599
+ });
600
+ }),
596
601
  formatter: formatter,
597
602
  judge: judgeData
598
603
  }))) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer, {
@@ -736,7 +741,11 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
736
741
  },
737
742
  mousePos: mousePos
738
743
  }), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
739
- series: _arcs,
744
+ series: _arcs.map(function (arc) {
745
+ return _objectSpread(_objectSpread({}, arc), {}, {
746
+ percent: arc.percent.toFixed(legendPrecision)
747
+ });
748
+ }),
740
749
  formatter: formatter,
741
750
  judge: judgeData
742
751
  })));
@@ -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"));
@@ -32,6 +33,7 @@ var PieTooltip = /*#__PURE__*/(0, _react.memo)(function (props) {
32
33
  percentageFont = _props$config$tip$dat3.fontStyle,
33
34
  percentageSuffix = _props$config$tip$dat3.suffix,
34
35
  percentageSuffixIsShow = _props$config$tip$dat3.suffix.show,
36
+ precision = _props$config$tip$dat3.precision,
35
37
  image = _props$config$tip.image,
36
38
  margin = _props$config$tip.margin,
37
39
  _props$config$tip$siz = _props$config$tip.size,
@@ -87,24 +89,53 @@ var PieTooltip = /*#__PURE__*/(0, _react.memo)(function (props) {
87
89
  style: (0, _utils.getFontStyle)(valueFont)
88
90
  }, y, valueSuffixIsShow && renderSuffix(valueSuffix)), percentageIsShow && /*#__PURE__*/_react["default"].createElement("span", {
89
91
  style: (0, _utils.getFontStyle)(percentageFont)
90
- }, percent, percentageSuffixIsShow && renderSuffix(percentageSuffix)));
92
+ }, Number(percent).toFixed(precision), percentageSuffixIsShow && renderSuffix(percentageSuffix)));
91
93
  };
92
94
  var mouseX = mousePos.x,
93
95
  mouseY = mousePos.y;
94
96
  var centerX = pieCenter.x,
95
97
  centerY = pieCenter.y;
96
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;
97
128
  var tipPosMap = {
98
- rightTop: "translate(".concat(mouseX + translateTip.x, "px,").concat(mouseY - tipHeight - translateTip.y, "px)"),
99
- leftTop: "translate(".concat(mouseX - tipWidth - translateTip.x, "px,").concat(mouseY - tipHeight - translateTip.y, "px)"),
100
- leftBottom: "translate(".concat(mouseX - tipWidth - translateTip.x, "px,").concat(mouseY + translateTip.y, "px)"),
101
- rightBottom: "translate(".concat(mouseX + translateTip.x, "px,").concat(mouseY + translateTip.y, "px)")
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)")
102
133
  };
103
- if (mouseX < centerX && mouseY < centerY) {
134
+ if (_mouseX < centerX && _mouseY < centerY) {
104
135
  return tipPosMap.leftTop;
105
- } else if (mouseX > centerX && mouseY < centerY) {
136
+ } else if (_mouseX > centerX && _mouseY < centerY) {
106
137
  return tipPosMap.rightTop;
107
- } else if (mouseX >= centerX && mouseY >= centerY) {
138
+ } else if (_mouseX >= centerX && _mouseY >= centerY) {
108
139
  return tipPosMap.rightBottom;
109
140
  } else {
110
141
  return tipPosMap.leftBottom;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.4.26",
3
+ "version": "1.4.29",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -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]
@@ -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
- callbackData = {};
12
- callbacks.forEach(({ origin, target }) => {
13
- callbackData[target] = data[origin];
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,6 +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 "@easyv/utils/lib/common/utils";
37
38
 
38
39
  const PI = Math.PI;
39
40
 
@@ -398,19 +399,20 @@ const Component = memo(
398
399
  }, [series, arcs, radius]);
399
400
 
400
401
  const onClick = useCallback(
401
- (e) =>
402
+ (e) => {
402
403
  onEvent({
403
404
  currentIndex: +e.currentTarget.dataset.index,
404
405
  type: "onClick",
405
- }),
406
+ });
407
+ },
406
408
  [onEvent]
407
409
  );
408
410
 
409
411
  const onMouseEnter = useCallback(
410
412
  (e) => {
411
- const _data = arcs[+currentIndex].data;
412
- triggerOnRelative(_data);
413
- onEmit("onMouseEnter", _data);
413
+ const _data = arcs[+e.currentTarget.dataset.index].data;
414
+ triggerOnRelative('mousehover',_data);
415
+ onEmit("mousehover", _data);
414
416
  onEvent({
415
417
  currentIndex: +e.currentTarget.dataset.index,
416
418
  type: "onMouseEnter",
@@ -447,15 +449,15 @@ const Component = memo(
447
449
  },
448
450
  onComplete: () => {
449
451
  const _data = arcs[+currentIndex].data;
450
- triggerOnRelative(_data);
452
+ triggerOnRelative("carousel",_data);
451
453
  onEmit("carousel", _data);
452
454
  },
453
455
  });
454
456
  } else {
455
457
  if (currentIndex !== null && trigger === "onClick") {
456
458
  const _data = arcs[+currentIndex].data;
457
- triggerOnRelative(_data);
458
- onEmit(trigger, _data);
459
+ triggerOnRelative('click',_data);
460
+ onEmit('click', _data);
459
461
  }
460
462
  }
461
463
  return () => {
@@ -563,7 +565,7 @@ const Component = memo(
563
565
  onClick={onClick}
564
566
  onMouseEnter={onMouseEnter}
565
567
  onMouseLeave={onMouseLeave}
566
- onMouseMove={(e)=>{
568
+ onMouseMove={(e) => {
567
569
  const _data = arcs[+e.currentTarget.dataset.index];
568
570
  const warpBoxPos = {
569
571
  x: pieWarpEl.current.getBoundingClientRect().x,
@@ -619,7 +621,10 @@ const Component = memo(
619
621
  )}
620
622
  <Legend
621
623
  {...legend}
622
- series={_arcs}
624
+ series={_arcs.map((arc) => ({
625
+ ...arc,
626
+ percent: arc.percent.toFixed(legendPrecision),
627
+ }))}
623
628
  formatter={formatter}
624
629
  judge={judgeData}
625
630
  />
@@ -855,7 +860,10 @@ const Component = memo(
855
860
  )}
856
861
  <Legend
857
862
  {...legend}
858
- series={_arcs}
863
+ series={_arcs.map((arc) => ({
864
+ ...arc,
865
+ percent: arc.percent.toFixed(legendPrecision),
866
+ }))}
859
867
  formatter={formatter}
860
868
  judge={judgeData}
861
869
  />
@@ -3,132 +3,159 @@ import { getFontStyle, getMargin, getTranslate3d, getTranslate2d, getIcon } from
3
3
 
4
4
 
5
5
  export const PieTooltip = memo((props) => {
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} },
13
- },
14
- image,
15
- margin,
16
- size: { width: tipWidth, height: tipHeight },
17
- translate: translateTip,
18
- },
19
- },
20
- data,
21
- series } = props
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
- const Item = () => {
24
- const { data: { s, y }, percent } = data
25
- const { type, icon, displayName } = [...series.values()].find(
26
- (series) => series.name == s
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
- 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
- }
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
- const _icon = getIcon(type, icon);
49
- return (
50
- <dd
51
- style={{
52
- display: 'flex',
53
- justifyContent: 'space-between',
54
- lineHeight: lineHeight + 'px',
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
- <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
- {percent}
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 = () => {
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
- return <div
107
- className='__easyv-tooltip'
108
- style={{
109
- pointerEvents: 'none',
110
- transform: getTipPos(mousePos, pieCenter),
111
- width: tipWidth,
112
- height: tipHeight,
113
- padding: getMargin(margin),
114
- background: image
115
- ? '50% 50% / 100% 100% no-repeat url(' +
116
- window.appConfig.ASSETS_URL +
117
- image +
118
- ')'
119
- : 'rgba(48, 55, 66, 0.85)',
120
- }}
121
- >
122
- <dl
123
- style={{
124
- display: 'flex',
125
- flexDirection: 'column',
126
- justifyContent: 'space-between',
127
- height: '100%',
128
- }}
129
- >
130
- {Item()}
131
- </dl>
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
- </div>
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
  })