@easyv/charts 1.0.73 → 1.1.0
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 +4 -0
- package/CHANGELOG.md +16 -0
- package/commitlint.config.js +1 -0
- package/lib/components/Axis.js +26 -7
- package/lib/components/Band.js +4 -1
- package/lib/components/CartesianChart.js +8 -2
- package/lib/components/Lighter.js +180 -0
- package/lib/components/PieChart.js +14 -8
- package/lib/components/Tooltip.js +30 -12
- package/lib/components/index.js +8 -0
- package/lib/element/ConicGradient.js +73 -0
- package/lib/utils/index.js +3 -3
- package/package.json +18 -5
- package/src/components/Axis.tsx +91 -73
- package/src/components/Band.tsx +4 -2
- package/src/components/CartesianChart.js +7 -1
- package/src/components/Lighter.jsx +74 -63
- package/src/components/PieChart.js +64 -60
- package/src/components/Tooltip.js +69 -34
- package/src/components/index.js +2 -0
- package/src/types/index.d.ts +4 -1
- package/src/utils/index.js +2 -2
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 提示框
|
|
3
3
|
*/
|
|
4
|
-
import { memo } from 'react';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
5
5
|
import { getFontStyle, getMargin, getTranslate3d } from '../utils';
|
|
6
6
|
import { getIcon } from '../utils';
|
|
7
|
-
|
|
8
7
|
export default memo(
|
|
9
8
|
({
|
|
10
9
|
x: position,
|
|
11
10
|
tickName: x,
|
|
11
|
+
marginLeft,
|
|
12
|
+
marginTop,
|
|
12
13
|
data,
|
|
13
14
|
series,
|
|
14
|
-
config,
|
|
15
15
|
config: {
|
|
16
16
|
tip: {
|
|
17
17
|
data: {
|
|
@@ -22,39 +22,61 @@ export default memo(
|
|
|
22
22
|
},
|
|
23
23
|
image,
|
|
24
24
|
margin,
|
|
25
|
-
size: { width, height },
|
|
25
|
+
size: { width: tipWidth, height: tipHeight },
|
|
26
26
|
translate: translateTip,
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
formatter,
|
|
30
30
|
isVertical,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
31
33
|
}) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const tipPosition = useMemo(() => {
|
|
35
|
+
const translate3d = isVertical
|
|
36
|
+
? {
|
|
37
|
+
...translateTip,
|
|
38
|
+
y: translateTip.y + position + marginTop,
|
|
39
|
+
}
|
|
40
|
+
: {
|
|
41
|
+
...translateTip,
|
|
42
|
+
x: translateTip.x + position + marginLeft,
|
|
43
|
+
};
|
|
44
|
+
if (translate3d.x + tipWidth > width) {
|
|
45
|
+
const newPositon = position + marginLeft - tipWidth - translateTip.x;
|
|
46
|
+
translate3d.x = newPositon >= 0 ? newPositon : 0;
|
|
47
|
+
}
|
|
48
|
+
if (translate3d.y + tipHeight > height) {
|
|
49
|
+
const newPositon = position + marginTop - tipHeight - translateTip.y;
|
|
50
|
+
translate3d.y = newPositon >= 0 ? newPositon : height - tipHeight;
|
|
36
51
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
return getTranslate3d(translate3d);
|
|
53
|
+
}, [
|
|
54
|
+
width,
|
|
55
|
+
height,
|
|
56
|
+
marginLeft,
|
|
57
|
+
marginTop,
|
|
58
|
+
position,
|
|
59
|
+
tipWidth,
|
|
60
|
+
tipHeight,
|
|
61
|
+
translateTip,
|
|
62
|
+
]);
|
|
41
63
|
|
|
42
64
|
return (
|
|
43
65
|
<div
|
|
44
66
|
className='__easyv-tooltip'
|
|
45
67
|
style={{
|
|
46
68
|
pointerEvents: 'none',
|
|
47
|
-
transform:
|
|
48
|
-
width,
|
|
49
|
-
height,
|
|
69
|
+
transform: tipPosition,
|
|
70
|
+
width: tipWidth,
|
|
71
|
+
height: tipHeight,
|
|
50
72
|
padding: getMargin(margin),
|
|
51
73
|
background: image
|
|
52
74
|
? '50% 50% / 100% 100% no-repeat url(' +
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
window.appConfig.ASSETS_URL +
|
|
76
|
+
image +
|
|
77
|
+
')'
|
|
56
78
|
: 'rgba(48, 55, 66, 0.85)',
|
|
57
|
-
...getFontStyle(font)
|
|
79
|
+
...getFontStyle(font),
|
|
58
80
|
}}
|
|
59
81
|
>
|
|
60
82
|
{formatter ? (
|
|
@@ -80,21 +102,21 @@ export default memo(
|
|
|
80
102
|
}}
|
|
81
103
|
>
|
|
82
104
|
{x}
|
|
83
|
-
|
|
84
105
|
</dt>
|
|
85
106
|
{data.map(({ showY, s }, index) => {
|
|
86
107
|
const { type, icon, displayName } = series.find(
|
|
87
108
|
(series) => series.name == s
|
|
88
109
|
);
|
|
89
|
-
const {
|
|
110
|
+
const {
|
|
111
|
+
show: showSuffix,
|
|
112
|
+
content,
|
|
113
|
+
font: suffiixFont,
|
|
114
|
+
translate: suffixTranslate,
|
|
115
|
+
} = suffix;
|
|
90
116
|
const tmp = new Map();
|
|
91
|
-
Object.values(content).forEach(
|
|
92
|
-
(item)
|
|
93
|
-
|
|
94
|
-
item['suffix'].suffix
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
);
|
|
117
|
+
Object.values(content).forEach((item) => {
|
|
118
|
+
tmp.set(item['suffix'].name, item['suffix'].suffix);
|
|
119
|
+
});
|
|
98
120
|
const _icon = getIcon(type, icon);
|
|
99
121
|
return (
|
|
100
122
|
<dd
|
|
@@ -113,14 +135,27 @@ export default memo(
|
|
|
113
135
|
gap: icon.iconGap,
|
|
114
136
|
}}
|
|
115
137
|
>
|
|
116
|
-
<span
|
|
138
|
+
<span
|
|
139
|
+
style={{
|
|
140
|
+
..._icon,
|
|
141
|
+
width: iconSize + 'px',
|
|
142
|
+
height: iconSize + 'px',
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
117
145
|
<span style={getFontStyle(name)}>{displayName || s}</span>
|
|
118
146
|
</span>
|
|
119
|
-
<span style={getFontStyle(value)}>
|
|
120
|
-
{
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
147
|
+
<span style={getFontStyle(value)}>
|
|
148
|
+
{showY}
|
|
149
|
+
{showSuffix && (
|
|
150
|
+
<span
|
|
151
|
+
style={{
|
|
152
|
+
...getFontStyle(suffiixFont),
|
|
153
|
+
transform: getTranslate3d(suffixTranslate),
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
{tmp.get(s)}
|
|
157
|
+
</span>
|
|
158
|
+
)}
|
|
124
159
|
</span>
|
|
125
160
|
</dd>
|
|
126
161
|
);
|
package/src/components/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import Axis from './Axis';
|
|
|
9
9
|
import Tooltip from './Tooltip';
|
|
10
10
|
import Indicator from './Indicator';
|
|
11
11
|
import Band from './Band';
|
|
12
|
+
import Lighter from './Lighter';
|
|
12
13
|
import Line from './Line';
|
|
13
14
|
import Background from './Background';
|
|
14
15
|
import LinearGradient from './LinearGradient';
|
|
@@ -34,6 +35,7 @@ export {
|
|
|
34
35
|
Axis,
|
|
35
36
|
Indicator,
|
|
36
37
|
Band,
|
|
38
|
+
Lighter,
|
|
37
39
|
Line,
|
|
38
40
|
Area,
|
|
39
41
|
Background,
|
package/src/types/index.d.ts
CHANGED
package/src/utils/index.js
CHANGED
|
@@ -632,7 +632,7 @@ const sortPie = (data, order) => {
|
|
|
632
632
|
|
|
633
633
|
const getDataWithPercent = (data = [], precision = 0) => {
|
|
634
634
|
const digits = Math.pow(10, precision);
|
|
635
|
-
|
|
635
|
+
const targetSeats = digits * 100;
|
|
636
636
|
|
|
637
637
|
const total = sum(data, (d) => d.value);
|
|
638
638
|
|
|
@@ -643,7 +643,7 @@ const getDataWithPercent = (data = [], precision = 0) => {
|
|
|
643
643
|
}));
|
|
644
644
|
const currentSum = sum(votesPerQuota, (d) => d.vote);
|
|
645
645
|
|
|
646
|
-
let remainder =
|
|
646
|
+
let remainder = targetSeats - currentSum;
|
|
647
647
|
votesPerQuota.sort(({ value: a }, { value: b }) => (a % total) - (b % total));
|
|
648
648
|
|
|
649
649
|
const tmp = votesPerQuota.map(({ vote, value, ...data }, index) => {
|