@easyv/charts 1.0.58 → 1.0.62

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.
@@ -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: y,
112
+ value: showY,
112
113
  config: label
113
114
  }, attr)));
114
115
  }));
@@ -763,7 +763,7 @@ var Current = function Current(_ref9) {
763
763
  }, text)), //百分比值
764
764
  showPercent && /*#__PURE__*/_react["default"].createElement("span", {
765
765
  style: _objectSpread(_objectSpread({
766
- transform: "translate(" + translatePercentX + "px," + translatePercentY + ")"
766
+ transform: "translate(" + translatePercentX + "px," + translatePercentY + "px)"
767
767
  }, (0, _utils.getFontStyle)(percentFont)), {}, {
768
768
  margin: gap / 2 + "px 0"
769
769
  })
@@ -972,6 +972,7 @@ var RingLabel = function RingLabel(_ref12) {
972
972
  type = _ref13$series$color.type,
973
973
  pure = _ref13$series$color.pure,
974
974
  stops = _ref13$series$color.linear.stops,
975
+ realData = _ref13.data,
975
976
  displayName = _ref13.displayName,
976
977
  value = _ref13.value,
977
978
  percent = _ref13.percent,
@@ -1035,7 +1036,7 @@ var RingLabel = function RingLabel(_ref12) {
1035
1036
  dx: valueDx(_showName, mode),
1036
1037
  dy: valueDy(_showName, mode, directionY),
1037
1038
  style: (0, _utils.getFontStyle)(valueFont, 'svg')
1038
- }, value), showSuffix && /*#__PURE__*/_react["default"].createElement("tspan", {
1039
+ }, realData.y), showSuffix && /*#__PURE__*/_react["default"].createElement("tspan", {
1039
1040
  style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont, 'svg')), {}, {
1040
1041
  fontSize: suffixFontSize
1041
1042
  }),
@@ -22,6 +22,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
22
22
  x = _ref.tickName,
23
23
  data = _ref.data,
24
24
  series = _ref.series,
25
+ config = _ref.config,
25
26
  _ref$config$tip = _ref.config.tip,
26
27
  _ref$config$tip$data = _ref$config$tip.data,
27
28
  xAxis = _ref$config$tip$data.xAxis,
@@ -29,11 +30,13 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
29
30
  align = _ref$config$tip$data$.align,
30
31
  font = _ref$config$tip$data$.font,
31
32
  translateXAxis = _ref$config$tip$data$.translate,
32
- lineHeight = _ref$config$tip$data.lineHeight,
33
33
  dataConfig = _ref$config$tip$data.data,
34
34
  _ref$config$tip$data$2 = _ref$config$tip$data.data,
35
+ lineHeight = _ref$config$tip$data$2.lineHeight,
36
+ iconSize = _ref$config$tip$data$2.iconSize,
35
37
  name = _ref$config$tip$data$2.name,
36
38
  value = _ref$config$tip$data$2.value,
39
+ suffix = _ref$config$tip$data$2.suffix,
37
40
  image = _ref$config$tip.image,
38
41
  margin = _ref$config$tip.margin,
39
42
  _ref$config$tip$size = _ref$config$tip.size,
@@ -59,7 +62,6 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
59
62
  }, (0, _utils.getFontStyle)(font))
60
63
  }, formatter ? formatter({
61
64
  series: series,
62
- lineHeight: lineHeight,
63
65
  x: {
64
66
  x: x,
65
67
  config: xAxis
@@ -81,7 +83,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
81
83
  transform: (0, _utils.getTranslate3d)(translateXAxis)
82
84
  }, font)
83
85
  }, x), data.map(function (_ref2, index) {
84
- var y = _ref2.y,
86
+ var showY = _ref2.showY,
85
87
  s = _ref2.s;
86
88
 
87
89
  var _series$find = series.find(function (series) {
@@ -91,10 +93,20 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
91
93
  icon = _series$find.icon,
92
94
  displayName = _series$find.displayName;
93
95
 
96
+ var showSuffix = suffix.show,
97
+ content = suffix.content,
98
+ suffiixFont = suffix.font,
99
+ suffixTranslate = suffix.translate;
100
+ var tmp = new Map();
101
+ Object.values(content).forEach(function (item) {
102
+ tmp.set(item['suffix'].name, item['suffix'].suffix);
103
+ });
104
+
94
105
  var _icon = (0, _utils.getIcon)(type, icon);
95
106
 
96
107
  return /*#__PURE__*/React.createElement("dd", {
97
108
  style: {
109
+ border: '1px solid yellow',
98
110
  display: 'flex',
99
111
  justifyContent: 'space-between',
100
112
  lineHeight: lineHeight + 'px'
@@ -102,17 +114,25 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
102
114
  key: index
103
115
  }, /*#__PURE__*/React.createElement("span", {
104
116
  style: {
117
+ border: '1px solid red',
105
118
  display: 'flex',
106
119
  alignItems: 'center',
107
120
  gap: icon.iconGap
108
121
  }
109
122
  }, /*#__PURE__*/React.createElement("span", {
110
- style: _icon
123
+ style: _objectSpread(_objectSpread({}, _icon), {}, {
124
+ width: iconSize + 'px',
125
+ height: iconSize + 'px'
126
+ })
111
127
  }), /*#__PURE__*/React.createElement("span", {
112
128
  style: (0, _utils.getFontStyle)(name)
113
129
  }, displayName || s)), /*#__PURE__*/React.createElement("span", {
114
130
  style: (0, _utils.getFontStyle)(value)
115
- }, y));
131
+ }, showY, showSuffix && /*#__PURE__*/React.createElement("span", {
132
+ style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(suffiixFont)), {}, {
133
+ transform: (0, _utils.getTranslate3d)(suffixTranslate)
134
+ })
135
+ }, tmp.get(s))));
116
136
  })));
117
137
  });
118
138
 
@@ -19,7 +19,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
19
19
 
20
20
  var pieLegendFormatter = function pieLegendFormatter(_ref, _ref2) {
21
21
  var displayName = _ref.displayName,
22
- value = _ref.value,
22
+ data = _ref.data,
23
23
  percent = _ref.percent,
24
24
  _ref$series = _ref.series,
25
25
  seriesColor = _ref$series.color,
@@ -71,7 +71,7 @@ var pieLegendFormatter = function pieLegendFormatter(_ref, _ref2) {
71
71
  alignItems: 'center',
72
72
  justifyContent: 'flex-start'
73
73
  })
74
- }, showValue && /*#__PURE__*/React.createElement("span", null, value), showSuffix && /*#__PURE__*/React.createElement("span", {
74
+ }, showValue && /*#__PURE__*/React.createElement("span", null, data.y), showSuffix && /*#__PURE__*/React.createElement("span", {
75
75
  style: {
76
76
  fontSize: fontSize,
77
77
  transform: 'translate3d(' + x + 'px, ' + y + 'px, 0px)'
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.0.58",
3
+ "version": "1.0.62",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -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={y} config={label} {...attr} />}
86
+ {showLabel && <Label value={showY} config={label} {...attr} />}
88
87
  </g>
89
88
  );
90
89
  }
@@ -340,7 +340,7 @@ const Component = memo(
340
340
  outerRadius,
341
341
  }));
342
342
  }, [data, arcsFunc, chart, legendPrecision]);
343
-
343
+
344
344
  const _arcs = useMemo(() => {
345
345
  const seriesLength = series.size;
346
346
  if (!seriesLength) return [];
@@ -728,7 +728,7 @@ const Current = ({
728
728
  { //百分比值
729
729
  showPercent && <span
730
730
  style={{
731
- transform:"translate("+translatePercentX+"px,"+translatePercentY+")",
731
+ transform:"translate("+translatePercentX+"px,"+translatePercentY+"px)",
732
732
  ...getFontStyle(percentFont),
733
733
  margin:gap/2+"px 0"
734
734
  }}
@@ -984,6 +984,7 @@ const RingLabel =({
984
984
  linear: { stops },
985
985
  },
986
986
  },
987
+ data:realData,
987
988
  displayName,
988
989
  value,
989
990
  percent,
@@ -1047,7 +1048,7 @@ const RingLabel =({
1047
1048
  dy={valueDy(_showName, mode, directionY)}
1048
1049
  style={getFontStyle(valueFont, 'svg')}
1049
1050
  >
1050
- {value}
1051
+ {realData.y}
1051
1052
  </tspan>
1052
1053
  {showSuffix && (
1053
1054
  <tspan
@@ -11,14 +11,14 @@ export default memo(
11
11
  tickName: x,
12
12
  data,
13
13
  series,
14
+ config,
14
15
  config: {
15
16
  tip: {
16
17
  data: {
17
18
  xAxis,
18
19
  xAxis: { align, font, translate: translateXAxis },
19
- lineHeight,
20
20
  data: dataConfig,
21
- data: { name, value },
21
+ data: { lineHeight, iconSize, name, value, suffix },
22
22
  },
23
23
  image,
24
24
  margin,
@@ -31,13 +31,14 @@ export default memo(
31
31
  }) => {
32
32
  const translate3d = isVertical
33
33
  ? {
34
- ...translateTip,
35
- y: translateTip.y + position,
36
- }
34
+ ...translateTip,
35
+ y: translateTip.y + position,
36
+ }
37
37
  : {
38
- ...translateTip,
39
- x: translateTip.x + position,
40
- };
38
+ ...translateTip,
39
+ x: translateTip.x + position,
40
+ };
41
+
41
42
  return (
42
43
  <div
43
44
  className='__easyv-tooltip'
@@ -49,17 +50,16 @@ export default memo(
49
50
  padding: getMargin(margin),
50
51
  background: image
51
52
  ? '50% 50% / 100% 100% no-repeat url(' +
52
- window.appConfig.ASSETS_URL +
53
- image +
54
- ')'
53
+ window.appConfig.ASSETS_URL +
54
+ image +
55
+ ')'
55
56
  : 'rgba(48, 55, 66, 0.85)',
56
- ...getFontStyle(font)
57
+ ...getFontStyle(font)
57
58
  }}
58
59
  >
59
60
  {formatter ? (
60
61
  formatter({
61
62
  series,
62
- lineHeight,
63
63
  x: { x, config: xAxis },
64
64
  data: { data, config: dataConfig },
65
65
  })
@@ -80,15 +80,26 @@ export default memo(
80
80
  }}
81
81
  >
82
82
  {x}
83
+
83
84
  </dt>
84
- {data.map(({ y, s }, index) => {
85
+ {data.map(({ showY, s }, index) => {
85
86
  const { type, icon, displayName } = series.find(
86
87
  (series) => series.name == s
87
88
  );
89
+ const { show: showSuffix, content, font: suffiixFont, translate: suffixTranslate } = suffix
90
+ const tmp = new Map();
91
+ Object.values(content).forEach(
92
+ (item) => {
93
+ tmp.set(item['suffix'].name,
94
+ item['suffix'].suffix
95
+ );
96
+ }
97
+ );
88
98
  const _icon = getIcon(type, icon);
89
99
  return (
90
100
  <dd
91
101
  style={{
102
+ border: '1px solid yellow',
92
103
  display: 'flex',
93
104
  justifyContent: 'space-between',
94
105
  lineHeight: lineHeight + 'px',
@@ -97,15 +108,21 @@ export default memo(
97
108
  >
98
109
  <span
99
110
  style={{
111
+ border: '1px solid red',
100
112
  display: 'flex',
101
113
  alignItems: 'center',
102
114
  gap: icon.iconGap,
103
115
  }}
104
116
  >
105
- <span style={_icon} />
117
+ <span style={{ ..._icon, width: iconSize + 'px', height: iconSize + 'px' }} />
106
118
  <span style={getFontStyle(name)}>{displayName || s}</span>
107
119
  </span>
108
- <span style={getFontStyle(value)}>{y}</span>
120
+ <span style={getFontStyle(value)}>{showY}
121
+ {showSuffix && <span style={{ ...getFontStyle(suffiixFont), transform: getTranslate3d(suffixTranslate) }}>
122
+ {tmp.get(s)}
123
+ </span>
124
+ }
125
+ </span>
109
126
  </dd>
110
127
  );
111
128
  })}
@@ -0,0 +1,56 @@
1
+ import * as d3 from 'd3';
2
+
3
+ //只支持在svg中使用
4
+ //在<clipPath>标签中绘制圆环路径,在<foreignObject>中使用conic-gradient来制作角向渐变
5
+ //然后在foreignObject中调用clipPath来剪切dom元素,实现环形渐变效果
6
+ export default function ConicGradient(props){
7
+ const {
8
+ gradientId, //渐变ID,每一个环形渐变都需要使用独有的id,防止大屏中存在多个环形渐变时,出现渐变混用的情况。
9
+ colorConfig={},
10
+ circleConfig={}
11
+ } = props,
12
+ {
13
+ colorType = "linear", //渐变类型
14
+ colors = [{offset:0,color:"rgba(255,0,0,0.5)"},
15
+ {offset:50,color:"rgba(0,255,0,0.5)"},
16
+ {offset:100,color:"rgba(0,0,255,0.5)"}] //渐变颜色
17
+ } = colorConfig,
18
+ {
19
+ innerRadius = 80, //圆环内半径
20
+ outerRadius = 100, //圆环外半径
21
+ startAngle = 0, //初始角度
22
+ endAngle = 360, //结束角度
23
+ cornerRadius = 0, //圆环两端的圆角
24
+ padAngle = 0 //圆环内边距,用于多个圆环之间的间距
25
+ } = circleConfig;
26
+ const arc = d3
27
+ .arc()
28
+ .innerRadius(innerRadius)
29
+ .outerRadius(outerRadius)
30
+ .startAngle((startAngle * Math.PI) / 180)
31
+ .endAngle((endAngle * Math.PI) / 180)
32
+ .cornerRadius(cornerRadius)
33
+ .padAngle(padAngle);
34
+ return <g>
35
+ <clipPath id={""+gradientId} style={{transform:`translate(50%,50%)`}}>
36
+ <path d={arc()}></path>
37
+ </clipPath>
38
+ <foreignObject style={{
39
+ width:"100%",
40
+ height:"100%",
41
+ transform:`translate(-50%,-50%)`,
42
+ background:colorType==="pure"?
43
+ colors : `conic-gradient(${colorsToString(colors)})`,
44
+ clipPath:`url(${'#'+gradientId})`
45
+ }}></foreignObject>
46
+ </g>
47
+ }
48
+ function colorsToString(colors){
49
+ let s="";
50
+ colors.sort((a,b)=>{
51
+ return a.offset-b.offset;
52
+ }).map(d=>{
53
+ s=s+d.color+" "+d.offset+"%,";
54
+ })
55
+ return s.slice(0,-1)
56
+ }
@@ -1,7 +1,7 @@
1
1
  import css from '../css/index.module.css';
2
2
  import { getFontStyle } from '../utils';
3
3
  export const pieLegendFormatter = (
4
- { displayName, value, percent, series: { color: seriesColor, icon="" } },
4
+ { displayName, data, percent, series: { color: seriesColor, icon="" } },
5
5
  {
6
6
  name: { show: showName, font: nameFont },
7
7
  value: {
@@ -57,7 +57,7 @@ export const pieLegendFormatter = (
57
57
  justifyContent: 'flex-start',
58
58
  }}
59
59
  >
60
- {showValue && <span>{value}</span>}
60
+ {showValue && <span>{data.y}</span>}
61
61
  {showSuffix && (
62
62
  <span
63
63
  style={{
@@ -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
  ];
package/tsconfig.json CHANGED
@@ -18,6 +18,6 @@
18
18
 
19
19
  "types": ["src/types"]
20
20
  },
21
- "include": ["src"],
21
+ "include": ["src", "../南湖数据", "../Lighter.jsx"],
22
22
  "exclude": ["node_modules", "**/*.spec.ts"],
23
23
  }