@easyv/charts 1.6.10 → 1.6.12
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/formatter/legend.js +18 -6
- package/lib/utils/index.js +10 -7
- package/package.json +1 -1
- package/src/formatter/legend.js +14 -6
- package/src/utils/index.js +13 -10
package/lib/formatter/legend.js
CHANGED
|
@@ -25,12 +25,18 @@ var pieLegendFormatter = exports.pieLegendFormatter = function pieLegendFormatte
|
|
|
25
25
|
textOverflow = _ref2$name.textOverflow,
|
|
26
26
|
speed = _ref2$name.speed,
|
|
27
27
|
maxWidth = _ref2$name.maxWidth,
|
|
28
|
+
_ref2$name$translate = _ref2$name.translate,
|
|
29
|
+
nameX = _ref2$name$translate.x,
|
|
30
|
+
nameY = _ref2$name$translate.y,
|
|
28
31
|
_ref2$value = _ref2.value,
|
|
29
32
|
showValue = _ref2$value.show,
|
|
30
33
|
valueFont = _ref2$value.font,
|
|
31
34
|
valueSameColor = _ref2$value.sameColor,
|
|
32
35
|
valueGap = _ref2$value.gap,
|
|
33
36
|
valueAlign = _ref2$value.align,
|
|
37
|
+
_ref2$value$translate = _ref2$value.translate,
|
|
38
|
+
valueX = _ref2$value$translate.x,
|
|
39
|
+
valueY = _ref2$value$translate.y,
|
|
34
40
|
_ref2$value$suffix = _ref2$value.suffix,
|
|
35
41
|
showSuffix = _ref2$value$suffix.show,
|
|
36
42
|
text = _ref2$value$suffix.text,
|
|
@@ -43,14 +49,18 @@ var pieLegendFormatter = exports.pieLegendFormatter = function pieLegendFormatte
|
|
|
43
49
|
percentFont = _ref2$percent.font,
|
|
44
50
|
percentSameColor = _ref2$percent.sameColor,
|
|
45
51
|
percentGap = _ref2$percent.gap,
|
|
46
|
-
percentAlign = _ref2$percent.align
|
|
52
|
+
percentAlign = _ref2$percent.align,
|
|
53
|
+
_ref2$percent$transla = _ref2$percent.translate,
|
|
54
|
+
percentX = _ref2$percent$transla.x,
|
|
55
|
+
percentY = _ref2$percent$transla.y;
|
|
47
56
|
var seriesColorType = seriesColor.type,
|
|
48
57
|
pure = seriesColor.pure,
|
|
49
58
|
stops = seriesColor.linear.stops;
|
|
50
59
|
var _color = seriesColorType == 'pure' ? pure : stops[0].color;
|
|
51
60
|
return /*#__PURE__*/React.createElement(React.Fragment, null, icon && /*#__PURE__*/React.createElement("span", {
|
|
52
61
|
style: _objectSpread(_objectSpread({}, icon), {}, {
|
|
53
|
-
marginRight: icon.marginRight
|
|
62
|
+
marginRight: icon.marginRight,
|
|
63
|
+
transform: "translate(".concat(nameX, "px, ").concat(nameY, "px)")
|
|
54
64
|
})
|
|
55
65
|
}), /*#__PURE__*/React.createElement("div", {
|
|
56
66
|
className: showName && showValue && showPercent ? _indexModule["default"].showAllStyle : _indexModule["default"].notShowAllStyle,
|
|
@@ -61,16 +71,18 @@ var pieLegendFormatter = exports.pieLegendFormatter = function pieLegendFormatte
|
|
|
61
71
|
value: displayName,
|
|
62
72
|
type: textOverflow,
|
|
63
73
|
speed: speed,
|
|
64
|
-
style: _objectSpread({
|
|
74
|
+
style: _objectSpread(_objectSpread({
|
|
65
75
|
width: maxWidth,
|
|
66
76
|
marginLeft: 5
|
|
67
|
-
}, (0, _utils.getFontStyle)(nameFont))
|
|
77
|
+
}, (0, _utils.getFontStyle)(nameFont)), {}, {
|
|
78
|
+
transform: "translate(".concat(nameX, "px, ").concat(nameY, "px)")
|
|
79
|
+
})
|
|
68
80
|
}), showValue && /*#__PURE__*/React.createElement("span", {
|
|
69
81
|
style: _objectSpread(_objectSpread({
|
|
70
82
|
whiteSpace: "nowrap"
|
|
71
83
|
}, (0, _utils.getFontStyle)(valueFont)), {}, {
|
|
72
84
|
marginLeft: valueGap,
|
|
73
|
-
|
|
85
|
+
transform: "translate(".concat(valueX, "px,").concat(valueY, "px)"),
|
|
74
86
|
display: 'flex',
|
|
75
87
|
flex: 1,
|
|
76
88
|
color: valueSameColor ? _color : valueFont.color,
|
|
@@ -88,7 +100,7 @@ var pieLegendFormatter = exports.pieLegendFormatter = function pieLegendFormatte
|
|
|
88
100
|
whiteSpace: "nowrap"
|
|
89
101
|
}, (0, _utils.getFontStyle)(percentFont)), {}, {
|
|
90
102
|
marginLeft: percentGap,
|
|
91
|
-
|
|
103
|
+
transform: "translate(".concat(percentX, "px,").concat(percentY, "px)"),
|
|
92
104
|
display: "flex",
|
|
93
105
|
flex: 1,
|
|
94
106
|
alignItems: 'center',
|
package/lib/utils/index.js
CHANGED
|
@@ -495,13 +495,16 @@ var getCurrentStack = exports.getCurrentStack = function getCurrentStack(stack,
|
|
|
495
495
|
};
|
|
496
496
|
var getBandBackground = exports.getBandBackground = function getBandBackground(pattern, fill) {
|
|
497
497
|
if (!(pattern && pattern.path)) return (0, _utils.getColor)(fill);
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
498
|
+
try {
|
|
499
|
+
var _pattern$backgroundSi = pattern.backgroundSize,
|
|
500
|
+
backgroundSize = _pattern$backgroundSi === void 0 ? '100% 100%' : _pattern$backgroundSi,
|
|
501
|
+
_pattern = (0, _objectWithoutProperties2["default"])(pattern, _excluded);
|
|
502
|
+
return 'center top / ' + backgroundSize + ' url("data:image/svg+xml,' + encodeURIComponent((0, _server.renderToStaticMarkup)( /*#__PURE__*/React.createElement(SvgBackground, {
|
|
503
|
+
fill: fill,
|
|
504
|
+
pattern: _pattern
|
|
505
|
+
}))) + '")';
|
|
506
|
+
} catch (e) {}
|
|
507
|
+
return "";
|
|
505
508
|
};
|
|
506
509
|
var getBandwidth = exports.getBandwidth = function getBandwidth(step, paddingOuter) {
|
|
507
510
|
return step * (1 - paddingOuter);
|
package/package.json
CHANGED
package/src/formatter/legend.js
CHANGED
|
@@ -5,13 +5,17 @@ import { TextOverflow } from '../components';
|
|
|
5
5
|
export const pieLegendFormatter = (
|
|
6
6
|
{ displayName, data, percent, series: { color: seriesColor, icon="" } },
|
|
7
7
|
{
|
|
8
|
-
name: { show: showName, font: nameFont, textOverflow, speed, maxWidth },
|
|
8
|
+
name: { show: showName, font: nameFont, textOverflow, speed, maxWidth, translate: { x:nameX, y:nameY } },
|
|
9
9
|
value: {
|
|
10
10
|
show: showValue,
|
|
11
11
|
font: valueFont,
|
|
12
12
|
sameColor: valueSameColor,
|
|
13
13
|
gap: valueGap,
|
|
14
14
|
align: valueAlign,
|
|
15
|
+
translate: {
|
|
16
|
+
x:valueX,
|
|
17
|
+
y:valueY
|
|
18
|
+
},
|
|
15
19
|
suffix: {
|
|
16
20
|
show: showSuffix,
|
|
17
21
|
text,
|
|
@@ -24,7 +28,11 @@ export const pieLegendFormatter = (
|
|
|
24
28
|
font: percentFont,
|
|
25
29
|
sameColor: percentSameColor,
|
|
26
30
|
gap: percentGap,
|
|
27
|
-
align: percentAlign
|
|
31
|
+
align: percentAlign,
|
|
32
|
+
translate: {
|
|
33
|
+
x:percentX,
|
|
34
|
+
y:percentY
|
|
35
|
+
}
|
|
28
36
|
},
|
|
29
37
|
}
|
|
30
38
|
) => {
|
|
@@ -37,7 +45,7 @@ export const pieLegendFormatter = (
|
|
|
37
45
|
const _color = seriesColorType == 'pure' ? pure : stops[0].color;
|
|
38
46
|
return (
|
|
39
47
|
<>
|
|
40
|
-
{icon &&<span style={{ ...icon, marginRight: icon.marginRight }} />}
|
|
48
|
+
{icon &&<span style={{ ...icon, marginRight: icon.marginRight, transform:`translate(${nameX}px, ${nameY}px)` }} />}
|
|
41
49
|
<div
|
|
42
50
|
className={
|
|
43
51
|
showName && showValue && showPercent
|
|
@@ -50,7 +58,7 @@ export const pieLegendFormatter = (
|
|
|
50
58
|
>
|
|
51
59
|
{showName && (
|
|
52
60
|
<TextOverflow value={displayName} type={textOverflow} speed={speed} style={{
|
|
53
|
-
width:maxWidth, marginLeft: 5, ...getFontStyle(nameFont)
|
|
61
|
+
width:maxWidth, marginLeft: 5, ...getFontStyle(nameFont), transform:`translate(${nameX}px, ${nameY}px)`
|
|
54
62
|
}}></TextOverflow>
|
|
55
63
|
)}
|
|
56
64
|
{showValue && (
|
|
@@ -59,7 +67,7 @@ export const pieLegendFormatter = (
|
|
|
59
67
|
whiteSpace:"nowrap",
|
|
60
68
|
...getFontStyle(valueFont),
|
|
61
69
|
marginLeft: valueGap,
|
|
62
|
-
|
|
70
|
+
transform:`translate(${valueX}px,${valueY}px)`,
|
|
63
71
|
display: 'flex',
|
|
64
72
|
flex:1,
|
|
65
73
|
color: valueSameColor ? _color : valueFont.color,
|
|
@@ -87,7 +95,7 @@ export const pieLegendFormatter = (
|
|
|
87
95
|
whiteSpace:"nowrap",
|
|
88
96
|
...getFontStyle(percentFont),
|
|
89
97
|
marginLeft: percentGap,
|
|
90
|
-
|
|
98
|
+
transform:`translate(${percentX}px,${percentY}px)`,
|
|
91
99
|
display:"flex",
|
|
92
100
|
flex:1,
|
|
93
101
|
alignItems: 'center',
|
package/src/utils/index.js
CHANGED
|
@@ -486,16 +486,19 @@ const getCurrentStack = (stack, stackMap) =>
|
|
|
486
486
|
|
|
487
487
|
const getBandBackground = (pattern, fill) => {
|
|
488
488
|
if (!(pattern && pattern.path)) return getColor(fill);
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
489
|
+
try{
|
|
490
|
+
const { backgroundSize = '100% 100%', ..._pattern } = pattern;
|
|
491
|
+
return (
|
|
492
|
+
'center top / ' +
|
|
493
|
+
backgroundSize +
|
|
494
|
+
' url("data:image/svg+xml,' +
|
|
495
|
+
encodeURIComponent(
|
|
496
|
+
renderToStaticMarkup(<SvgBackground fill={fill} pattern={_pattern} />)
|
|
497
|
+
) +
|
|
498
|
+
'")'
|
|
499
|
+
);
|
|
500
|
+
}catch(e){}
|
|
501
|
+
return "";
|
|
499
502
|
};
|
|
500
503
|
const getBandwidth = (step, paddingOuter) => step * (1 - paddingOuter);
|
|
501
504
|
|