@easyv/charts 1.0.54 → 1.0.58
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.
|
@@ -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,20 +43,20 @@ 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
|
});
|
|
50
50
|
return /*#__PURE__*/React.createElement("div", {
|
|
51
51
|
className: "__easyv-tooltip",
|
|
52
|
-
style: {
|
|
52
|
+
style: _objectSpread({
|
|
53
53
|
pointerEvents: 'none',
|
|
54
54
|
transform: (0, _utils.getTranslate3d)(translate3d),
|
|
55
55
|
width: width,
|
|
56
56
|
height: height,
|
|
57
57
|
padding: (0, _utils.getMargin)(margin),
|
|
58
58
|
background: image ? '50% 50% / 100% 100% no-repeat url(' + window.appConfig.ASSETS_URL + image + ')' : 'rgba(48, 55, 66, 0.85)'
|
|
59
|
-
}
|
|
59
|
+
}, (0, _utils.getFontStyle)(font))
|
|
60
60
|
}, formatter ? formatter({
|
|
61
61
|
series: series,
|
|
62
62
|
lineHeight: lineHeight,
|
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,
|
package/package.json
CHANGED
|
@@ -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
|
{
|
package/src/formatter/legend.js
CHANGED