@easyv/charts 1.0.55 → 1.0.59
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/Label.js +2 -1
- package/lib/components/PieChart.js +64 -16
- package/lib/components/Tooltip.js +3 -3
- package/lib/formatter/legend.js +4 -2
- package/lib/hooks/useFilterData.js +6 -1
- package/package.json +1 -1
- package/src/components/Label.js +2 -3
- package/src/components/PieChart.js +74 -59
- package/src/components/Tooltip.js +3 -3
- package/src/formatter/legend.js +1 -1
- package/src/hooks/useFilterData.js +9 -2
package/lib/components/Label.js
CHANGED
|
@@ -72,6 +72,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
72
72
|
_ref2$data = _ref2.data,
|
|
73
73
|
x = _ref2$data.x,
|
|
74
74
|
y = _ref2$data.y,
|
|
75
|
+
showY = _ref2$data.showY,
|
|
75
76
|
s = _ref2$data.s;
|
|
76
77
|
|
|
77
78
|
var y1 = yScaler(isVertical ? end : start);
|
|
@@ -108,7 +109,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
108
109
|
cy: attr.y,
|
|
109
110
|
config: icon
|
|
110
111
|
}), showLabel && /*#__PURE__*/React.createElement(Label, (0, _extends2["default"])({
|
|
111
|
-
value:
|
|
112
|
+
value: showY,
|
|
112
113
|
config: label
|
|
113
114
|
}, attr)));
|
|
114
115
|
}));
|
|
@@ -670,6 +670,7 @@ var Current = function Current(_ref9) {
|
|
|
670
670
|
_ref9$config$name = _ref9$config.name,
|
|
671
671
|
showName = _ref9$config$name.show,
|
|
672
672
|
nameFont = _ref9$config$name.font,
|
|
673
|
+
textBreak = _ref9$config$name.textBreak,
|
|
673
674
|
_ref9$config$percent = _ref9$config.percent,
|
|
674
675
|
showPercent = _ref9$config$percent.show,
|
|
675
676
|
percentFont = _ref9$config$percent.font,
|
|
@@ -704,22 +705,69 @@ var Current = function Current(_ref9) {
|
|
|
704
705
|
fieldName = currentData.fieldName,
|
|
705
706
|
value = currentData.value,
|
|
706
707
|
percent = currentData.percent;
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
708
|
+
var nameTemp = displayName ? displayName : fieldName; //类目名
|
|
709
|
+
|
|
710
|
+
var nameList = [];
|
|
711
|
+
|
|
712
|
+
if (textBreak) {
|
|
713
|
+
//如果限制了首行字符,则切割组件
|
|
714
|
+
while (nameTemp.length > textBreak) {
|
|
715
|
+
nameList.push(nameTemp.slice(0, textBreak));
|
|
716
|
+
nameTemp = nameTemp.slice(textBreak);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
nameList.push(nameTemp);
|
|
721
|
+
var foreignStyle = {
|
|
722
|
+
//foreignObject标签样式,
|
|
723
|
+
width: "100%",
|
|
724
|
+
height: "100%",
|
|
725
|
+
transform: "translate(-50%,-50%)"
|
|
726
|
+
},
|
|
727
|
+
boxStyle = {
|
|
728
|
+
//弹性盒子样式,用于当前值的上下居中对齐等
|
|
729
|
+
width: "100%",
|
|
730
|
+
height: '100%',
|
|
731
|
+
display: "flex",
|
|
732
|
+
flexDirection: "column",
|
|
733
|
+
justifyContent: "center",
|
|
734
|
+
alignItems: "center"
|
|
735
|
+
};
|
|
736
|
+
return show && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
737
|
+
style: foreignStyle
|
|
738
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
739
|
+
style: boxStyle
|
|
740
|
+
}, //类目名称
|
|
741
|
+
showName && /*#__PURE__*/_react["default"].createElement("div", {
|
|
742
|
+
style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(nameFont)), {}, {
|
|
743
|
+
margin: gap / 2 + "px 0",
|
|
744
|
+
display: "flex",
|
|
745
|
+
flexDirection: "column",
|
|
746
|
+
alignItems: "center"
|
|
747
|
+
})
|
|
748
|
+
}, nameList.map(function (d, i) {
|
|
749
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
750
|
+
key: i
|
|
751
|
+
}, d);
|
|
752
|
+
})), //真实值
|
|
753
|
+
showValue && /*#__PURE__*/_react["default"].createElement("span", {
|
|
754
|
+
style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont)), {}, {
|
|
755
|
+
transform: "translate(" + translateValueX + "px," + translateValueY + "px)",
|
|
756
|
+
margin: gap / 2 + "px 0"
|
|
757
|
+
})
|
|
758
|
+
}, value, showSuffix && text && /*#__PURE__*/_react["default"].createElement("span", {
|
|
759
|
+
style: {
|
|
760
|
+
transform: "translate(" + translateSuffixX + "px," + translateSuffixY + "px)",
|
|
761
|
+
fontSize: fontSize
|
|
762
|
+
}
|
|
763
|
+
}, text)), //百分比值
|
|
764
|
+
showPercent && /*#__PURE__*/_react["default"].createElement("span", {
|
|
765
|
+
style: _objectSpread(_objectSpread({
|
|
766
|
+
transform: "translate(" + translatePercentX + "px," + translatePercentY + ")"
|
|
767
|
+
}, (0, _utils.getFontStyle)(percentFont)), {}, {
|
|
768
|
+
margin: gap / 2 + "px 0"
|
|
769
|
+
})
|
|
770
|
+
}, percent + '%'))));
|
|
723
771
|
};
|
|
724
772
|
|
|
725
773
|
var Label = function Label(_ref10) {
|
|
@@ -43,7 +43,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
43
43
|
formatter = _ref.formatter,
|
|
44
44
|
isVertical = _ref.isVertical;
|
|
45
45
|
var translate3d = isVertical ? _objectSpread(_objectSpread({}, translateTip), {}, {
|
|
46
|
-
y: translateTip.
|
|
46
|
+
y: translateTip.y + position
|
|
47
47
|
}) : _objectSpread(_objectSpread({}, translateTip), {}, {
|
|
48
48
|
x: translateTip.x + position
|
|
49
49
|
});
|
|
@@ -81,7 +81,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
81
81
|
transform: (0, _utils.getTranslate3d)(translateXAxis)
|
|
82
82
|
}, font)
|
|
83
83
|
}, x), data.map(function (_ref2, index) {
|
|
84
|
-
var
|
|
84
|
+
var showY = _ref2.showY,
|
|
85
85
|
s = _ref2.s;
|
|
86
86
|
|
|
87
87
|
var _series$find = series.find(function (series) {
|
|
@@ -112,7 +112,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
112
112
|
style: (0, _utils.getFontStyle)(name)
|
|
113
113
|
}, displayName || s)), /*#__PURE__*/React.createElement("span", {
|
|
114
114
|
style: (0, _utils.getFontStyle)(value)
|
|
115
|
-
},
|
|
115
|
+
}, showY));
|
|
116
116
|
})));
|
|
117
117
|
});
|
|
118
118
|
|
package/lib/formatter/legend.js
CHANGED
|
@@ -58,9 +58,11 @@ var pieLegendFormatter = function pieLegendFormatter(_ref, _ref2) {
|
|
|
58
58
|
}), /*#__PURE__*/React.createElement("span", {
|
|
59
59
|
className: showName && showValue && showPercent ? _indexModule["default"].showAllStyle : _indexModule["default"].notShowAllStyle
|
|
60
60
|
}, showName && /*#__PURE__*/React.createElement("span", {
|
|
61
|
-
style: _objectSpread({
|
|
61
|
+
style: _objectSpread(_objectSpread({
|
|
62
62
|
paddingLeft: 5
|
|
63
|
-
}, (0, _utils.getFontStyle)(nameFont))
|
|
63
|
+
}, (0, _utils.getFontStyle)(nameFont)), {}, {
|
|
64
|
+
whiteSpace: "nowrap"
|
|
65
|
+
})
|
|
64
66
|
}, displayName), showValue && /*#__PURE__*/React.createElement("span", {
|
|
65
67
|
style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont)), {}, {
|
|
66
68
|
marginLeft: valueGap,
|
|
@@ -101,7 +101,12 @@ var _default = function _default(_ref) {
|
|
|
101
101
|
}, [series]);
|
|
102
102
|
return [{
|
|
103
103
|
series: _series,
|
|
104
|
-
data: _data
|
|
104
|
+
data: _data.map(function (d) {
|
|
105
|
+
return _objectSpread(_objectSpread({}, d), {}, {
|
|
106
|
+
y: parseFloat(d.y),
|
|
107
|
+
showY: d.y
|
|
108
|
+
});
|
|
109
|
+
})
|
|
105
110
|
}, onClick];
|
|
106
111
|
};
|
|
107
112
|
|
package/package.json
CHANGED
package/src/components/Label.js
CHANGED
|
@@ -40,11 +40,10 @@ export default memo(
|
|
|
40
40
|
paddingInner * seriesStep;
|
|
41
41
|
const isVertical = direction === 'vertical';
|
|
42
42
|
const _position = label.position;
|
|
43
|
-
|
|
44
43
|
return (
|
|
45
44
|
<g className='__easyv-label'>
|
|
46
45
|
{data.map(
|
|
47
|
-
({ index, bound: [start, end], data, data: { x, y, s } }, i) => {
|
|
46
|
+
({ index, bound: [start, end], data, data: { x, y, showY, s } }, i) => {
|
|
48
47
|
|
|
49
48
|
const y1 = yScaler(isVertical ? end : start);
|
|
50
49
|
const y2 = start ? yScaler(isVertical ? start : end - start) : yScaler(isVertical ? start : end);
|
|
@@ -84,7 +83,7 @@ export default memo(
|
|
|
84
83
|
data-data={JSON.stringify(data)}
|
|
85
84
|
>
|
|
86
85
|
{showIcon && <Icon cx={attr.x} cy={attr.y} config={icon} />}
|
|
87
|
-
{showLabel && <Label value={
|
|
86
|
+
{showLabel && <Label value={showY} config={label} {...attr} />}
|
|
88
87
|
</g>
|
|
89
88
|
);
|
|
90
89
|
}
|
|
@@ -630,7 +630,7 @@ const Current = ({
|
|
|
630
630
|
config: {
|
|
631
631
|
show,
|
|
632
632
|
gap,
|
|
633
|
-
name: { show: showName, font: nameFont },
|
|
633
|
+
name: { show: showName, font: nameFont, textBreak },
|
|
634
634
|
percent: {
|
|
635
635
|
show: showPercent,
|
|
636
636
|
font: percentFont,
|
|
@@ -661,68 +661,83 @@ const Current = ({
|
|
|
661
661
|
if (!currentData) return null;
|
|
662
662
|
|
|
663
663
|
const { displayName, fieldName, value, percent } = currentData;
|
|
664
|
+
let nameTemp = displayName? displayName : fieldName; //类目名
|
|
665
|
+
let nameList = [];
|
|
666
|
+
if(textBreak){ //如果限制了首行字符,则切割组件
|
|
667
|
+
while(nameTemp.length>textBreak){
|
|
668
|
+
nameList.push(nameTemp.slice(0,textBreak));
|
|
669
|
+
nameTemp = nameTemp.slice(textBreak)
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
nameList.push(nameTemp)
|
|
673
|
+
let foreignStyle={ //foreignObject标签样式,
|
|
674
|
+
width:"100%",
|
|
675
|
+
height:"100%",
|
|
676
|
+
transform:"translate(-50%,-50%)",
|
|
677
|
+
},
|
|
678
|
+
boxStyle={ //弹性盒子样式,用于当前值的上下居中对齐等
|
|
679
|
+
width:"100%",
|
|
680
|
+
height:'100%',
|
|
681
|
+
display:"flex",
|
|
682
|
+
flexDirection:"column",
|
|
683
|
+
justifyContent:"center",
|
|
684
|
+
alignItems:"center"
|
|
685
|
+
}
|
|
664
686
|
|
|
665
687
|
return (
|
|
666
688
|
show && (
|
|
667
689
|
<>
|
|
668
|
-
{
|
|
669
|
-
<
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
690
|
+
<foreignObject style={foreignStyle}>
|
|
691
|
+
<div style={boxStyle}>
|
|
692
|
+
{ //类目名称
|
|
693
|
+
showName && <div
|
|
694
|
+
style={{
|
|
695
|
+
...getFontStyle(nameFont),
|
|
696
|
+
margin:gap/2+"px 0",
|
|
697
|
+
display:"flex",
|
|
698
|
+
flexDirection:"column",
|
|
699
|
+
alignItems:"center"
|
|
700
|
+
}}>
|
|
701
|
+
{
|
|
702
|
+
nameList.map((d,i)=>{
|
|
703
|
+
return <span key={i}>{d}</span>
|
|
704
|
+
})
|
|
705
|
+
}
|
|
706
|
+
</div>
|
|
677
707
|
}
|
|
678
|
-
{
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
708
|
+
{ //真实值
|
|
709
|
+
showValue && <span
|
|
710
|
+
style={{
|
|
711
|
+
...getFontStyle(valueFont),
|
|
712
|
+
transform:"translate("+translateValueX+"px,"+translateValueY+"px)",
|
|
713
|
+
margin:gap/2+"px 0"
|
|
714
|
+
}}>
|
|
715
|
+
{value}
|
|
716
|
+
{showSuffix && text && (
|
|
717
|
+
<span
|
|
718
|
+
style={{
|
|
719
|
+
transform:"translate("+translateSuffixX+"px,"+translateSuffixY+"px)",
|
|
720
|
+
fontSize:fontSize
|
|
721
|
+
}}
|
|
722
|
+
>
|
|
723
|
+
{text}
|
|
724
|
+
</span>
|
|
725
|
+
)}
|
|
726
|
+
</span>
|
|
696
727
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
dy={translateSuffixY}
|
|
705
|
-
fontSize={fontSize}
|
|
728
|
+
{ //百分比值
|
|
729
|
+
showPercent && <span
|
|
730
|
+
style={{
|
|
731
|
+
transform:"translate("+translatePercentX+"px,"+translatePercentY+")",
|
|
732
|
+
...getFontStyle(percentFont),
|
|
733
|
+
margin:gap/2+"px 0"
|
|
734
|
+
}}
|
|
706
735
|
>
|
|
707
|
-
{
|
|
708
|
-
</
|
|
709
|
-
)}
|
|
710
|
-
</text>
|
|
711
|
-
)}
|
|
712
|
-
{showPercent && (
|
|
713
|
-
<text
|
|
714
|
-
textAnchor='middle'
|
|
715
|
-
dy={
|
|
716
|
-
(showName && showValue ? 1 : showName || showValue ? 0.5 : 0) *
|
|
717
|
-
gap +
|
|
718
|
-
translatePercentY
|
|
736
|
+
{percent + '%'}
|
|
737
|
+
</span>
|
|
719
738
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
>
|
|
723
|
-
{percent + '%'}
|
|
724
|
-
</text>
|
|
725
|
-
)}
|
|
739
|
+
</div>
|
|
740
|
+
</foreignObject>
|
|
726
741
|
</>
|
|
727
742
|
)
|
|
728
743
|
);
|
|
@@ -759,7 +774,7 @@ const Label = ({
|
|
|
759
774
|
arcs,
|
|
760
775
|
animation
|
|
761
776
|
}) => {
|
|
762
|
-
|
|
777
|
+
// const [labels, setLabels] = useState(null);
|
|
763
778
|
// const [opacity, setOpacity] = useState(0);
|
|
764
779
|
|
|
765
780
|
const _arcs = useMemo(
|
|
@@ -803,11 +818,11 @@ const Label = ({
|
|
|
803
818
|
// console.log('bbox: ', bbox);
|
|
804
819
|
// }
|
|
805
820
|
// }, [labels]);
|
|
806
|
-
|
|
821
|
+
|
|
807
822
|
return (
|
|
808
823
|
<g
|
|
809
|
-
|
|
810
|
-
|
|
824
|
+
// style={{ opacity }} ref={setLabels}
|
|
825
|
+
>
|
|
811
826
|
{_arcs.map(
|
|
812
827
|
(
|
|
813
828
|
{
|
|
@@ -32,7 +32,7 @@ export default memo(
|
|
|
32
32
|
const translate3d = isVertical
|
|
33
33
|
? {
|
|
34
34
|
...translateTip,
|
|
35
|
-
y: translateTip.
|
|
35
|
+
y: translateTip.y + position,
|
|
36
36
|
}
|
|
37
37
|
: {
|
|
38
38
|
...translateTip,
|
|
@@ -81,7 +81,7 @@ export default memo(
|
|
|
81
81
|
>
|
|
82
82
|
{x}
|
|
83
83
|
</dt>
|
|
84
|
-
{data.map(({
|
|
84
|
+
{data.map(({ showY, s }, index) => {
|
|
85
85
|
const { type, icon, displayName } = series.find(
|
|
86
86
|
(series) => series.name == s
|
|
87
87
|
);
|
|
@@ -105,7 +105,7 @@ export default memo(
|
|
|
105
105
|
<span style={_icon} />
|
|
106
106
|
<span style={getFontStyle(name)}>{displayName || s}</span>
|
|
107
107
|
</span>
|
|
108
|
-
<span style={getFontStyle(value)}>{
|
|
108
|
+
<span style={getFontStyle(value)}>{showY}</span>
|
|
109
109
|
</dd>
|
|
110
110
|
);
|
|
111
111
|
})}
|
package/src/formatter/legend.js
CHANGED
|
@@ -29,7 +29,7 @@ const getSelected = (selected, name) => {
|
|
|
29
29
|
|
|
30
30
|
export default ({ data, series }) => {
|
|
31
31
|
const [selected, setSelected] = useState(getInitialSelected(series));
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
const _series = useMemo(() => {
|
|
34
34
|
const tmp = new Map();
|
|
35
35
|
series.forEach((currentSeries, key) => {
|
|
@@ -55,10 +55,17 @@ export default ({ data, series }) => {
|
|
|
55
55
|
useEffect(() => {
|
|
56
56
|
setSelected(getInitialSelected(series));
|
|
57
57
|
}, [series]);
|
|
58
|
+
|
|
58
59
|
return [
|
|
59
60
|
{
|
|
60
61
|
series: _series,
|
|
61
|
-
data: _data
|
|
62
|
+
data: _data.map(d=>{
|
|
63
|
+
return {
|
|
64
|
+
...d,
|
|
65
|
+
y:parseFloat(d.y),
|
|
66
|
+
showY:d.y
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
62
69
|
},
|
|
63
70
|
onClick,
|
|
64
71
|
];
|