@easyv/charts 1.3.32 → 1.3.34

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.
@@ -83,7 +83,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
83
83
  var dataset = e.currentTarget.dataset;
84
84
  var name = dataset.name;
85
85
  filterData && interactive && filterData(name);
86
- }, [interactive, filterData]); //木然判断数据都为零时做的,此处并不严谨,待想到好方法在进一步解决
86
+ }, [interactive, filterData]);
87
87
 
88
88
  if (judge == 0) {
89
89
  _series.forEach(function (d) {
@@ -727,7 +727,9 @@ var Current = function Current(_ref9) {
727
727
  showName = _ref9$config$name.show,
728
728
  nameColor = _ref9$config$name.sameColor,
729
729
  nameFont = _ref9$config$name.font,
730
- textBreak = _ref9$config$name.textBreak,
730
+ maxWidth = _ref9$config$name.maxWidth,
731
+ textOverflow = _ref9$config$name.textOverflow,
732
+ speed = _ref9$config$name.speed,
731
733
  _ref9$config$percent = _ref9$config.percent,
732
734
  showPercent = _ref9$config$percent.show,
733
735
  percentColor = _ref9$config$percent.sameColor,
@@ -776,17 +778,6 @@ var Current = function Current(_ref9) {
776
778
  percent = currentData.percent;
777
779
  var nameTemp = displayName ? displayName : fieldName; //类目名
778
780
 
779
- var nameList = [];
780
-
781
- if (textBreak) {
782
- //如果限制了首行字符,则切割组件
783
- while (nameTemp.length > textBreak) {
784
- nameList.push(nameTemp.slice(0, textBreak));
785
- nameTemp = nameTemp.slice(textBreak);
786
- }
787
- }
788
-
789
- nameList.push(nameTemp);
790
781
  var foreignStyle = {
791
782
  //foreignObject标签样式,
792
783
  width: width,
@@ -809,20 +800,19 @@ var Current = function Current(_ref9) {
809
800
  style: foreignStyle
810
801
  }, /*#__PURE__*/_react["default"].createElement("div", {
811
802
  style: boxStyle
812
- }, //类目名称
813
- showName && /*#__PURE__*/_react["default"].createElement("div", {
814
- style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(nameFont)), {}, {
803
+ }, showName && /*#__PURE__*/_react["default"].createElement(_.TextOverflow, {
804
+ type: textOverflow,
805
+ value: nameTemp,
806
+ speed: speed,
807
+ style: _objectSpread(_objectSpread({
808
+ maxWidth: maxWidth,
809
+ display: textOverflow == "marquee" ? "flex" : "bolck",
810
+ justifyContent: "center"
811
+ }, (0, _utils.getFontStyle)(nameFont)), {}, {
815
812
  margin: gap / 2 + 'px 0',
816
- display: 'flex',
817
- flexDirection: 'column',
818
- alignItems: 'center',
819
813
  color: nameColor ? seriesColor : nameFont.color
820
814
  })
821
- }, nameList.map(function (d, i) {
822
- return /*#__PURE__*/_react["default"].createElement("span", {
823
- key: i
824
- }, d);
825
- })), //真实值
815
+ }), //真实值
826
816
  showValue && /*#__PURE__*/_react["default"].createElement("span", {
827
817
  style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont)), {}, {
828
818
  transform: 'translate(' + translateValueX + 'px,' + translateValueY + 'px)',
@@ -860,6 +850,9 @@ var Label = function Label(_ref10) {
860
850
  _ref10$config$name = _ref10$config.name,
861
851
  showName = _ref10$config$name.show,
862
852
  nameFont = _ref10$config$name.font,
853
+ maxWidth = _ref10$config$name.maxWidth,
854
+ textOverflow = _ref10$config$name.textOverflow,
855
+ speed = _ref10$config$name.speed,
863
856
  _ref10$config$value = _ref10$config.value,
864
857
  showValue = _ref10$config$value.show,
865
858
  valueFont = _ref10$config$value.font,
@@ -870,14 +863,10 @@ var Label = function Label(_ref10) {
870
863
  _ref10$config$value$s2 = _ref10$config$value$s.translate,
871
864
  suffixTranslateX = _ref10$config$value$s2.x,
872
865
  suffixTranslateY = _ref10$config$value$s2.y,
873
- _ref10$config$value$s3 = _ref10$config$value.sameColor,
874
- valueSameColor = _ref10$config$value$s3 === void 0 ? false : _ref10$config$value$s3,
875
866
  _ref10$config$percent = _ref10$config.percent,
876
867
  showPercent = _ref10$config$percent.show,
877
868
  percentFont = _ref10$config$percent.font,
878
869
  precision = _ref10$config$percent.precision,
879
- _ref10$config$percent2 = _ref10$config$percent.sameColor,
880
- percentSameColor = _ref10$config$percent2 === void 0 ? false : _ref10$config$percent2,
881
870
  arcs = _ref10.arcs,
882
871
  judge = _ref10.judge,
883
872
  animation = _ref10.animation;
@@ -934,6 +923,7 @@ var Label = function Label(_ref10) {
934
923
 
935
924
  var _showValue = showValue && (value || showSuffix);
936
925
 
926
+ var nameStyle = (0, _utils.getFontStyle)(nameFont);
937
927
  return show && (_showName || showPercent || showValue) && /*#__PURE__*/_react["default"].createElement("g", {
938
928
  key: index
939
929
  }, /*#__PURE__*/_react["default"].createElement("path", {
@@ -944,34 +934,43 @@ var Label = function Label(_ref10) {
944
934
  d: 'M' + x1 + ', ' + y1 + 'L' + x2 + ', ' + y2 + 'L' + x3 + ', ' + y2,
945
935
  stroke: lineColor ? lineColor : type == 'pure' ? pure : stops[0].color,
946
936
  fill: "none"
947
- }), /*#__PURE__*/_react["default"].createElement("text", {
948
- className: animation ? _piechartModule["default"]['label-text'] : '',
949
- style: {
950
- animationDelay: "".concat(animation ? (actualIndex + 1) * 2000 - 800 : 0, "ms")
951
- },
937
+ }), /*#__PURE__*/_react["default"].createElement("foreignObject", {
938
+ width: "1",
939
+ height: "1",
952
940
  x: _x,
953
941
  y: y2 + translateY,
954
- dominantBaseline: "middle",
955
- textAnchor: x3 >= 0 ? 'start' : 'end'
956
- }, _showName && /*#__PURE__*/_react["default"].createElement("tspan", {
957
- style: (0, _utils.getFontStyle)(nameFont, 'svg')
958
- }, displayName + (showValue || showPercent ? ':' : '')), showValue && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("tspan", {
959
- x: !!(_showName && mode == 'vertical') ? _x : '',
960
- dx: valueDx(_showName, mode),
961
- dy: !!(_showName && mode == 'vertical') ? '1.5em' : '',
962
- style: (0, _utils.getFontStyle)(valueFont, 'svg')
963
- }, data.y), showSuffix && /*#__PURE__*/_react["default"].createElement("tspan", {
964
- style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont, 'svg')), {}, {
965
- fontSize: suffixFontSize
966
- }),
967
- dx: suffixTranslateX,
968
- dy: suffixTranslateY
969
- }, text)), showPercent && /*#__PURE__*/_react["default"].createElement("tspan", {
970
- x: percentX(_showName, _showValue, mode, _x),
971
- dx: percentDx(_showName, _showValue, mode),
972
- dy: percentDy(_showName, _showValue, mode) + (_showValue && showSuffix ? suffixTranslateY * -1 : ''),
973
- style: (0, _utils.getFontStyle)(percentFont, 'svg')
974
- }, (_showValue ? '(' : '') + percent + '%' + (_showValue ? ')' : ''))));
942
+ style: {
943
+ overflow: "visible"
944
+ }
945
+ }, /*#__PURE__*/_react["default"].createElement("div", {
946
+ className: animation ? _piechartModule["default"]['label-text'] : "",
947
+ style: {
948
+ transform: "translate(0,-50%)",
949
+ whiteSpace: "nowrap",
950
+ "float": x3 >= 0 ? "left" : "right",
951
+ width: "max-content"
952
+ }
953
+ }, _showName && /*#__PURE__*/_react["default"].createElement(_.TextOverflow, {
954
+ type: textOverflow,
955
+ value: displayName + (showValue || showPercent ? ":" : ""),
956
+ speed: speed,
957
+ style: _objectSpread(_objectSpread({
958
+ maxWidth: maxWidth
959
+ }, nameStyle), {}, {
960
+ "float": mode == "horizontal" ? "left" : "none"
961
+ })
962
+ }), showValue && /*#__PURE__*/_react["default"].createElement("span", {
963
+ style: (0, _utils.getFontStyle)(valueFont)
964
+ }, data.y, showSuffix && /*#__PURE__*/_react["default"].createElement("span", {
965
+ style: {
966
+ position: "relative",
967
+ fontSize: suffixFontSize,
968
+ marginLeft: suffixTranslateX,
969
+ top: suffixTranslateY
970
+ }
971
+ }, text)), showPercent && /*#__PURE__*/_react["default"].createElement("span", {
972
+ style: (0, _utils.getFontStyle)(percentFont)
973
+ }, (_showValue ? '(' : '') + percent + '%' + (_showValue ? ')' : '')))));
975
974
  }));
976
975
  };
977
976
 
@@ -990,6 +989,9 @@ var RingLabel = function RingLabel(_ref12) {
990
989
  _ref12$config$name = _ref12$config.name,
991
990
  showName = _ref12$config$name.show,
992
991
  nameFont = _ref12$config$name.font,
992
+ maxWidth = _ref12$config$name.maxWidth,
993
+ textOverflow = _ref12$config$name.textOverflow,
994
+ speed = _ref12$config$name.speed,
993
995
  _ref12$config$value = _ref12$config.value,
994
996
  showValue = _ref12$config$value.show,
995
997
  valueFont = _ref12$config$value.font,
@@ -1000,14 +1002,10 @@ var RingLabel = function RingLabel(_ref12) {
1000
1002
  _ref12$config$value$s2 = _ref12$config$value$s.translate,
1001
1003
  suffixTranslateX = _ref12$config$value$s2.x,
1002
1004
  suffixTranslateY = _ref12$config$value$s2.y,
1003
- _ref12$config$value$s3 = _ref12$config$value.sameColor,
1004
- valueSameColor = _ref12$config$value$s3 === void 0 ? false : _ref12$config$value$s3,
1005
1005
  _ref12$config$percent = _ref12$config.percent,
1006
1006
  showPercent = _ref12$config$percent.show,
1007
1007
  percentFont = _ref12$config$percent.font,
1008
1008
  precision = _ref12$config$percent.precision,
1009
- _ref12$config$percent2 = _ref12$config$percent.sameColor,
1010
- percentSameColor = _ref12$config$percent2 === void 0 ? false : _ref12$config$percent2,
1011
1009
  judge = _ref12.judge,
1012
1010
  arcs = _ref12.arcs;
1013
1011
 
@@ -1074,35 +1072,44 @@ var RingLabel = function RingLabel(_ref12) {
1074
1072
  d: 'M' + x1 + ', ' + y1 + 'L' + x2 + ', ' + y2 + 'L' + x3 + ', ' + y2,
1075
1073
  stroke: lineColor ? lineColor : type == 'pure' ? pure : stops[0].color,
1076
1074
  fill: "none"
1077
- }), /*#__PURE__*/_react["default"].createElement("text", {
1075
+ }), /*#__PURE__*/_react["default"].createElement("foreignObject", {
1076
+ width: "1",
1077
+ height: "1",
1078
+ x: _x,
1079
+ y: y2 + translateY,
1080
+ style: {
1081
+ overflow: "visible"
1082
+ }
1083
+ }, /*#__PURE__*/_react["default"].createElement("div", {
1078
1084
  className: _piechartModule["default"]['label-text'],
1079
1085
  style: {
1086
+ transform: "translate(0,-50%)",
1087
+ whiteSpace: "nowrap",
1088
+ "float": x3 >= 0 ? "left" : "right",
1089
+ width: "max-content",
1080
1090
  animationDelay: "".concat((actualIndex + 1) * 2000 - 800, "ms")
1081
- },
1082
- x: mode == 'horizontal' ? _x : x2,
1083
- y: y2 + translateY,
1084
- dominantBaseline: "middle",
1085
- textAnchor: x3 >= 0 ? 'start' : 'end'
1086
- }, _showName && /*#__PURE__*/_react["default"].createElement("tspan", {
1087
- dy: nameDy(_showValue, showPercent, mode, directionY),
1088
- style: (0, _utils.getFontStyle)(nameFont, 'svg')
1089
- }, displayName + (showValue || showPercent ? ':' : '')), _showValue && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("tspan", {
1090
- x: _showName ? mode == 'horizontal' ? '' : x2 : '',
1091
- dx: valueDx(_showName, mode),
1092
- dy: valueDy(_showName, mode, directionY),
1093
- style: (0, _utils.getFontStyle)(valueFont, 'svg')
1094
- }, realData.y), showSuffix && /*#__PURE__*/_react["default"].createElement("tspan", {
1095
- style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont, 'svg')), {}, {
1096
- fontSize: suffixFontSize
1097
- }),
1098
- dx: suffixTranslateX,
1099
- dy: suffixTranslateY
1100
- }, text)), showPercent && /*#__PURE__*/_react["default"].createElement("tspan", {
1101
- x: _showName ? _showValue ? '' : mode == 'vertical' ? x2 : '' : '',
1102
- dx: percentDx(_showName, _showValue, mode),
1103
- dy: percentDy_(_showName, _showValue, mode, directionY) + (_showValue && showSuffix ? suffixTranslateY * -1 : ''),
1104
- style: (0, _utils.getFontStyle)(percentFont, 'svg')
1105
- }, (_showValue ? '(' : '') + percent + '%' + (_showValue ? ')' : ''))));
1091
+ }
1092
+ }, _showName && /*#__PURE__*/_react["default"].createElement(_.TextOverflow, {
1093
+ type: textOverflow,
1094
+ value: displayName + (showValue || showPercent ? ":" : ""),
1095
+ speed: speed,
1096
+ style: _objectSpread(_objectSpread({
1097
+ maxWidth: maxWidth
1098
+ }, (0, _utils.getFontStyle)(nameFont)), {}, {
1099
+ "float": mode == "horizontal" ? "left" : "none"
1100
+ })
1101
+ }), showValue && /*#__PURE__*/_react["default"].createElement("span", {
1102
+ style: (0, _utils.getFontStyle)(valueFont)
1103
+ }, realData.y, showSuffix && /*#__PURE__*/_react["default"].createElement("span", {
1104
+ style: {
1105
+ position: "relative",
1106
+ fontSize: suffixFontSize,
1107
+ marginLeft: suffixTranslateX,
1108
+ top: suffixTranslateY
1109
+ }
1110
+ }, text)), showPercent && /*#__PURE__*/_react["default"].createElement("span", {
1111
+ style: (0, _utils.getFontStyle)(percentFont)
1112
+ }, (_showValue ? '(' : '') + percent + '%' + (_showValue ? ')' : '')))));
1106
1113
  }));
1107
1114
  };
1108
1115
 
@@ -42,7 +42,8 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
42
42
  case 'break-word':
43
43
  return {
44
44
  wordBreak: 'break-all',
45
- wordWrap: 'break-word'
45
+ wordWrap: 'break-word',
46
+ whiteSpace: "normal"
46
47
  };
47
48
 
48
49
  case 'marquee':
@@ -35,7 +35,8 @@
35
35
 
36
36
  .notShowAllStyle {
37
37
  display: flex;
38
- width: 100%;
38
+ /* width: 100%; */
39
+ /* flex:1; */
39
40
  align-items: center;
40
41
  flex-direction: row;
41
42
  justify-content: space-between;
@@ -13,6 +13,8 @@ var _indexModule = _interopRequireDefault(require("../css/index.module.css"));
13
13
 
14
14
  var _utils = require("../utils");
15
15
 
16
+ var _components = require("../components");
17
+
16
18
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
19
 
18
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -28,6 +30,9 @@ var pieLegendFormatter = function pieLegendFormatter(_ref, _ref2) {
28
30
  var _ref2$name = _ref2.name,
29
31
  showName = _ref2$name.show,
30
32
  nameFont = _ref2$name.font,
33
+ textOverflow = _ref2$name.textOverflow,
34
+ speed = _ref2$name.speed,
35
+ maxWidth = _ref2$name.maxWidth,
31
36
  _ref2$value = _ref2.value,
32
37
  showValue = _ref2$value.show,
33
38
  valueFont = _ref2$value.font,
@@ -55,15 +60,17 @@ var pieLegendFormatter = function pieLegendFormatter(_ref, _ref2) {
55
60
  style: _objectSpread(_objectSpread({}, icon), {}, {
56
61
  marginRight: icon.marginRight
57
62
  })
58
- }), /*#__PURE__*/React.createElement("span", {
63
+ }), /*#__PURE__*/React.createElement("div", {
59
64
  className: showName && showValue && showPercent ? _indexModule["default"].showAllStyle : _indexModule["default"].notShowAllStyle
60
- }, showName && /*#__PURE__*/React.createElement("span", {
61
- style: _objectSpread(_objectSpread({
62
- paddingLeft: 5
63
- }, (0, _utils.getFontStyle)(nameFont)), {}, {
64
- whiteSpace: "nowrap"
65
- })
66
- }, displayName), showValue && /*#__PURE__*/React.createElement("span", {
65
+ }, showName && /*#__PURE__*/React.createElement(_components.TextOverflow, {
66
+ value: displayName,
67
+ type: textOverflow,
68
+ speed: speed,
69
+ style: _objectSpread({
70
+ width: maxWidth,
71
+ marginLeft: 5
72
+ }, (0, _utils.getFontStyle)(nameFont))
73
+ }), showValue && /*#__PURE__*/React.createElement("span", {
67
74
  style: _objectSpread(_objectSpread({
68
75
  whiteSpace: "nowrap"
69
76
  }, (0, _utils.getFontStyle)(valueFont)), {}, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.3.32",
3
+ "version": "1.3.34",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -48,12 +48,11 @@ export default memo(
48
48
  [interactive, filterData]
49
49
  );
50
50
 
51
- //木然判断数据都为零时做的,此处并不严谨,待想到好方法在进一步解决
52
- if (judge == 0) {
53
- _series.forEach((d) => {
54
- d.percent=0
55
- })
56
- }
51
+ if (judge == 0) {
52
+ _series.forEach((d) => {
53
+ d.percent=0
54
+ })
55
+ }
57
56
 
58
57
  return (
59
58
  <div
@@ -11,7 +11,7 @@ import React, {
11
11
  useLayoutEffect,
12
12
  Fragment,
13
13
  } from 'react';
14
- import { ChartContainer, Carousel, Legend, ConicalGradient, Mapping } from '.';
14
+ import { ChartContainer, Carousel, Legend, ConicalGradient, Mapping, TextOverflow } from '.';
15
15
  import { chartContext } from '../context';
16
16
  import {
17
17
  getFontStyle,
@@ -752,7 +752,7 @@ const Current = ({
752
752
  config: {
753
753
  show,
754
754
  gap,
755
- name: { show: showName, sameColor: nameColor, font: nameFont, textBreak },
755
+ name: { show: showName, sameColor: nameColor, font: nameFont, maxWidth, textOverflow, speed },
756
756
  percent: {
757
757
  show: showPercent,
758
758
  sameColor: percentColor,
@@ -784,14 +784,12 @@ const Current = ({
784
784
  const legendDataWithPercent = getDataWithPercent(data, precision);
785
785
  return sortPie(legendDataWithPercent, '');
786
786
  }, [data, precision]);
787
-
788
787
 
789
788
  //数据容错,当data都为零那么需要进行以下容错
790
789
  if (judge == 0) {
791
790
  _data.forEach((d) => {
792
- d.percent = 0, d.value = 0
793
-
794
- })
791
+ d.percent = 0, d.value = 0;
792
+ });
795
793
  }
796
794
 
797
795
  const currentData = _data[currentIndex];
@@ -800,15 +798,7 @@ const Current = ({
800
798
 
801
799
  const { displayName, fieldName, value, percent } = currentData;
802
800
  let nameTemp = displayName ? displayName : fieldName; //类目名
803
- let nameList = [];
804
- if (textBreak) {
805
- //如果限制了首行字符,则切割组件
806
- while (nameTemp.length > textBreak) {
807
- nameList.push(nameTemp.slice(0, textBreak));
808
- nameTemp = nameTemp.slice(textBreak);
809
- }
810
- }
811
- nameList.push(nameTemp);
801
+
812
802
  let foreignStyle = {
813
803
  //foreignObject标签样式,
814
804
  width,
@@ -834,25 +824,14 @@ const Current = ({
834
824
  show && (
835
825
  <foreignObject style={foreignStyle}>
836
826
  <div style={boxStyle}>
837
- {
838
- //类目名称
839
- showName && (
840
- <div
841
- style={{
842
- ...getFontStyle(nameFont),
843
- margin: gap / 2 + 'px 0',
844
- display: 'flex',
845
- flexDirection: 'column',
846
- alignItems: 'center',
847
- color: nameColor ? seriesColor : nameFont.color,
848
- }}
849
- >
850
- {nameList.map((d, i) => {
851
- return <span key={i}>{d}</span>;
852
- })}
853
- </div>
854
- )
855
- }
827
+ {showName &&<TextOverflow type={textOverflow} value={nameTemp} speed={speed} style={{
828
+ maxWidth,
829
+ display:textOverflow=="marquee"?"flex":"bolck",
830
+ justifyContent:"center",
831
+ ...getFontStyle(nameFont),
832
+ margin: gap / 2 + 'px 0',
833
+ color: nameColor ? seriesColor : nameFont.color,
834
+ }}></TextOverflow>}
856
835
  {
857
836
  //真实值
858
837
  showValue && (
@@ -923,7 +902,7 @@ const Label = ({
923
902
  mode,
924
903
  show,
925
904
  translate: { x: translateX, y: translateY },
926
- name: { show: showName, font: nameFont },
905
+ name: { show: showName, font: nameFont, maxWidth, textOverflow, speed },
927
906
  value: {
928
907
  show: showValue,
929
908
  font: valueFont,
@@ -932,14 +911,12 @@ const Label = ({
932
911
  text,
933
912
  fontSize: suffixFontSize,
934
913
  translate: { x: suffixTranslateX, y: suffixTranslateY },
935
- },
936
- sameColor: valueSameColor = false,
914
+ }
937
915
  },
938
916
  percent: {
939
917
  show: showPercent,
940
918
  font: percentFont,
941
- precision,
942
- sameColor: percentSameColor = false,
919
+ precision
943
920
  },
944
921
  },
945
922
  arcs,
@@ -996,6 +973,7 @@ const Label = ({
996
973
 
997
974
  const _showName = showName && displayName;
998
975
  const _showValue = showValue && (value || showSuffix);
976
+ const nameStyle = getFontStyle(nameFont);
999
977
 
1000
978
  return (
1001
979
  show &&
@@ -1031,64 +1009,43 @@ const Label = ({
1031
1009
  }
1032
1010
  fill='none'
1033
1011
  />
1034
- <text
1035
- className={animation ? ringCss['label-text'] : ''}
1036
- style={{
1037
- animationDelay: `${
1038
- animation ? (actualIndex + 1) * 2000 - 800 : 0
1039
- }ms`,
1040
- }}
1041
- x={_x}
1042
- y={y2 + translateY}
1043
- dominantBaseline='middle'
1044
- textAnchor={x3 >= 0 ? 'start' : 'end'}
1045
- >
1046
- {_showName && (
1047
- <tspan style={getFontStyle(nameFont, 'svg')}>
1048
- {displayName + (showValue || showPercent ? ':' : '')}
1049
- </tspan>
1050
- )}
1051
- {showValue && (
1052
- <>
1053
- <tspan
1054
- x={!!(_showName && mode == 'vertical') ? _x : ''}
1055
- dx={valueDx(_showName, mode)}
1056
- dy={!!(_showName && mode == 'vertical') ? '1.5em' : ''}
1057
- style={getFontStyle(valueFont, 'svg')}
1058
- >
1012
+ <foreignObject width="1" height="1" x={_x} y={y2+translateY} style={{overflow:"visible"}}>
1013
+ <div className={animation? ringCss['label-text']:""} style={{
1014
+ transform:"translate(0,-50%)",
1015
+ whiteSpace:"nowrap",
1016
+ float:x3>=0?"left":"right",
1017
+ width:"max-content"
1018
+ }}>
1019
+ {_showName &&<TextOverflow type={textOverflow} value={displayName+((showValue || showPercent)?":":"")} speed={speed} style={{
1020
+ maxWidth,
1021
+ ...nameStyle,
1022
+ float:mode=="horizontal"?"left":"none"
1023
+ }}></TextOverflow>}
1024
+ {
1025
+ showValue && <span style={getFontStyle(valueFont)}>
1059
1026
  {data.y}
1060
- </tspan>
1061
- {showSuffix && (
1062
- <tspan
1063
- style={{
1064
- ...getFontStyle(valueFont, 'svg'),
1065
- fontSize: suffixFontSize,
1066
- }}
1067
- dx={suffixTranslateX}
1068
- dy={suffixTranslateY}
1069
- >
1070
- {text}
1071
- </tspan>
1072
- )}
1073
- </>
1074
- )}
1075
- {showPercent && (
1076
- <tspan
1077
- x={percentX(_showName, _showValue, mode, _x)}
1078
- dx={percentDx(_showName, _showValue, mode)}
1079
- dy={
1080
- percentDy(_showName, _showValue, mode) +
1081
- (_showValue && showSuffix ? suffixTranslateY * -1 : '')
1082
- }
1083
- style={getFontStyle(percentFont, 'svg')}
1084
- >
1085
- {(_showValue ? '(' : '') +
1086
- percent +
1087
- '%' +
1088
- (_showValue ? ')' : '')}
1089
- </tspan>
1090
- )}
1091
- </text>
1027
+ {showSuffix && <span style={{
1028
+ position:"relative",
1029
+ fontSize:suffixFontSize,
1030
+ marginLeft:suffixTranslateX,
1031
+ top:suffixTranslateY
1032
+ }}>
1033
+ { text }
1034
+ </span>}
1035
+ </span>
1036
+ }
1037
+ {
1038
+ showPercent && <span style={getFontStyle(percentFont)}>
1039
+ {
1040
+ (_showValue ? '(' : '') +
1041
+ percent +
1042
+ '%' +
1043
+ (_showValue ? ')' : '')
1044
+ }
1045
+ </span>
1046
+ }
1047
+ </div>
1048
+ </foreignObject>
1092
1049
  </g>
1093
1050
  )
1094
1051
  );
@@ -1107,7 +1064,7 @@ const RingLabel = ({
1107
1064
  mode,
1108
1065
  show,
1109
1066
  translate: { x: translateX, y: translateY },
1110
- name: { show: showName, font: nameFont },
1067
+ name: { show: showName, font: nameFont, maxWidth, textOverflow, speed },
1111
1068
  value: {
1112
1069
  show: showValue,
1113
1070
  font: valueFont,
@@ -1116,14 +1073,12 @@ const RingLabel = ({
1116
1073
  text,
1117
1074
  fontSize: suffixFontSize,
1118
1075
  translate: { x: suffixTranslateX, y: suffixTranslateY },
1119
- },
1120
- sameColor: valueSameColor = false,
1076
+ }
1121
1077
  },
1122
1078
  percent: {
1123
1079
  show: showPercent,
1124
1080
  font: percentFont,
1125
- precision,
1126
- sameColor: percentSameColor = false,
1081
+ precision
1127
1082
  },
1128
1083
  },
1129
1084
  judge,
@@ -1215,73 +1170,44 @@ const RingLabel = ({
1215
1170
  }
1216
1171
  fill='none'
1217
1172
  />
1218
- <text
1219
- className={ringCss['label-text']}
1220
- style={{
1173
+ <foreignObject width="1" height="1" x={_x} y={y2+translateY} style={{overflow:"visible"}}>
1174
+ <div className={ringCss['label-text']} style={{
1175
+ transform:"translate(0,-50%)",
1176
+ whiteSpace:"nowrap",
1177
+ float:x3>=0?"left":"right",
1178
+ width:"max-content",
1221
1179
  animationDelay: `${(actualIndex + 1) * 2000 - 800}ms`,
1222
- }}
1223
- x={mode == 'horizontal' ? _x : x2}
1224
- y={y2 + translateY}
1225
- dominantBaseline='middle'
1226
- textAnchor={x3 >= 0 ? 'start' : 'end'}
1227
- >
1228
- {_showName && (
1229
- <tspan
1230
- dy={nameDy(_showValue, showPercent, mode, directionY)}
1231
- style={getFontStyle(nameFont, 'svg')}
1232
- >
1233
- {displayName + (showValue || showPercent ? ':' : '')}
1234
- </tspan>
1235
- )}
1236
- {_showValue && (
1237
- <>
1238
- <tspan
1239
- x={_showName ? (mode == 'horizontal' ? '' : x2) : ''}
1240
- dx={valueDx(_showName, mode)}
1241
- dy={valueDy(_showName, mode, directionY)}
1242
- style={getFontStyle(valueFont, 'svg')}
1243
- >
1180
+ }}>
1181
+ {_showName &&<TextOverflow type={textOverflow} value={displayName+((showValue || showPercent)?":":"")} speed={speed} style={{
1182
+ maxWidth,
1183
+ ...getFontStyle(nameFont),
1184
+ float:mode=="horizontal"?"left":"none"
1185
+ }}></TextOverflow>}
1186
+ {
1187
+ showValue && <span style={getFontStyle(valueFont)}>
1244
1188
  {realData.y}
1245
- </tspan>
1246
- {showSuffix && (
1247
- <tspan
1248
- style={{
1249
- ...getFontStyle(valueFont, 'svg'),
1250
- fontSize: suffixFontSize,
1251
- }}
1252
- dx={suffixTranslateX}
1253
- dy={suffixTranslateY}
1254
- >
1255
- {text}
1256
- </tspan>
1257
- )}
1258
- </>
1259
- )}
1260
- {showPercent && (
1261
- <tspan
1262
- x={
1263
- _showName
1264
- ? _showValue
1265
- ? ''
1266
- : mode == 'vertical'
1267
- ? x2
1268
- : ''
1269
- : ''
1270
- }
1271
- dx={percentDx(_showName, _showValue, mode)}
1272
- dy={
1273
- percentDy_(_showName, _showValue, mode, directionY) +
1274
- (_showValue && showSuffix ? suffixTranslateY * -1 : '')
1275
- }
1276
- style={getFontStyle(percentFont, 'svg')}
1277
- >
1278
- {(_showValue ? '(' : '') +
1279
- percent +
1280
- '%' +
1281
- (_showValue ? ')' : '')}
1282
- </tspan>
1283
- )}
1284
- </text>
1189
+ {showSuffix && <span style={{
1190
+ position:"relative",
1191
+ fontSize:suffixFontSize,
1192
+ marginLeft:suffixTranslateX,
1193
+ top:suffixTranslateY
1194
+ }}>
1195
+ { text }
1196
+ </span>}
1197
+ </span>
1198
+ }
1199
+ {
1200
+ showPercent && <span style={getFontStyle(percentFont)}>
1201
+ {
1202
+ (_showValue ? '(' : '') +
1203
+ percent +
1204
+ '%' +
1205
+ (_showValue ? ')' : '')
1206
+ }
1207
+ </span>
1208
+ }
1209
+ </div>
1210
+ </foreignObject>
1285
1211
  </g>
1286
1212
  )
1287
1213
  );
@@ -32,6 +32,7 @@ export default memo(forwardRef((props:flowText, ref:any) => {
32
32
  return {
33
33
  wordBreak: 'break-all',
34
34
  wordWrap: 'break-word',
35
+ whiteSpace: "normal"
35
36
  };
36
37
  case 'marquee':
37
38
  return {
@@ -35,7 +35,8 @@
35
35
 
36
36
  .notShowAllStyle {
37
37
  display: flex;
38
- width: 100%;
38
+ /* width: 100%; */
39
+ /* flex:1; */
39
40
  align-items: center;
40
41
  flex-direction: row;
41
42
  justify-content: space-between;
@@ -1,9 +1,11 @@
1
1
  import css from '../css/index.module.css';
2
2
  import { getFontStyle } from '../utils';
3
+ import { TextOverflow } from '../components';
4
+
3
5
  export const pieLegendFormatter = (
4
6
  { displayName, data, percent, series: { color: seriesColor, icon="" } },
5
7
  {
6
- name: { show: showName, font: nameFont },
8
+ name: { show: showName, font: nameFont, textOverflow, speed, maxWidth },
7
9
  value: {
8
10
  show: showValue,
9
11
  font: valueFont,
@@ -34,7 +36,7 @@ export const pieLegendFormatter = (
34
36
  return (
35
37
  <>
36
38
  {icon &&<span style={{ ...icon, marginRight: icon.marginRight }} />}
37
- <span
39
+ <div
38
40
  className={
39
41
  showName && showValue && showPercent
40
42
  ? css.showAllStyle
@@ -42,9 +44,9 @@ export const pieLegendFormatter = (
42
44
  }
43
45
  >
44
46
  {showName && (
45
- <span style={{ paddingLeft: 5, ...getFontStyle(nameFont), whiteSpace:"nowrap" }}>
46
- {displayName}
47
- </span>
47
+ <TextOverflow value={displayName} type={textOverflow} speed={speed} style={{
48
+ width:maxWidth, marginLeft: 5, ...getFontStyle(nameFont)
49
+ }}></TextOverflow>
48
50
  )}
49
51
  {showValue && (
50
52
  <span
@@ -84,7 +86,7 @@ export const pieLegendFormatter = (
84
86
  {percent + '%'}
85
87
  </span>
86
88
  )}
87
- </span>
89
+ </div>
88
90
  </>
89
91
  );
90
92
  };