@easyv/charts 1.3.14 → 1.3.16
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/Legend.js
CHANGED
|
@@ -93,13 +93,15 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
93
93
|
gridTemplateColumns: 'repeat(' + Math.min(gridTemplateColumns, length) + ', 1fr)'
|
|
94
94
|
}
|
|
95
95
|
}, _series.map(function (series, index) {
|
|
96
|
+
var _series$config, _series$config$line;
|
|
97
|
+
|
|
96
98
|
var type = series.type,
|
|
97
99
|
name = series.name,
|
|
98
100
|
displayName = series.displayName,
|
|
99
101
|
icon = series.icon,
|
|
100
102
|
selected = series.selected;
|
|
101
103
|
|
|
102
|
-
var _icon = (0, _utils.getIcon)(type, icon);
|
|
104
|
+
var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 ? void 0 : (_series$config = series.config) === null || _series$config === void 0 ? void 0 : (_series$config$line = _series$config.line) === null || _series$config$line === void 0 ? void 0 : _series$config$line.type);
|
|
103
105
|
|
|
104
106
|
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
105
107
|
key: index,
|
|
@@ -435,8 +435,9 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
435
435
|
|
|
436
436
|
var _series = (0, _toConsumableArray2["default"])(series.values());
|
|
437
437
|
|
|
438
|
+
if (_series.length < arcs.length) console.warn("请检查数据中是否存在相同的s");
|
|
438
439
|
return arcs.map(function (arc, index) {
|
|
439
|
-
return getArc(radius, arc, _series[index]);
|
|
440
|
+
return getArc(radius, arc, _series[index % _series.length]);
|
|
440
441
|
});
|
|
441
442
|
}, [series, arcs, radius]);
|
|
442
443
|
|
package/lib/utils/index.js
CHANGED
|
@@ -124,10 +124,15 @@ var getColorList = function getColorList(_ref3) {
|
|
|
124
124
|
exports.getColorList = getColorList;
|
|
125
125
|
|
|
126
126
|
var getIcon = function getIcon(type, icon) {
|
|
127
|
+
var lineType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "solid";
|
|
128
|
+
|
|
127
129
|
switch (type) {
|
|
128
130
|
case 'area':
|
|
129
131
|
case 'line':
|
|
130
|
-
|
|
132
|
+
var color = icon.background;
|
|
133
|
+
return icon ? _objectSpread(_objectSpread(_objectSpread({}, defaultLineIcon), icon), {}, {
|
|
134
|
+
background: lineType == "solid" ? color : "linear-gradient(90deg, ".concat(color, ", ").concat(color, " 66%, transparent 66%) 0 0/33% 100% repeat")
|
|
135
|
+
}) : defaultLineIcon;
|
|
131
136
|
|
|
132
137
|
default:
|
|
133
138
|
return icon ? _objectSpread(_objectSpread({}, defaultIcon), icon) : defaultIcon;
|
|
@@ -828,7 +833,7 @@ var getDataWithPercent = function getDataWithPercent() {
|
|
|
828
833
|
}
|
|
829
834
|
|
|
830
835
|
var sum = valueList.reduce(function (acc, val) {
|
|
831
|
-
return acc + val.
|
|
836
|
+
return acc + val.value;
|
|
832
837
|
}, 0);
|
|
833
838
|
|
|
834
839
|
if (sum === 0) {
|
|
@@ -837,7 +842,7 @@ var getDataWithPercent = function getDataWithPercent() {
|
|
|
837
842
|
|
|
838
843
|
var digits = Math.pow(10, precision);
|
|
839
844
|
var votesPerQuota = valueList.map(function (val) {
|
|
840
|
-
return val.
|
|
845
|
+
return val.value / sum * digits * 100;
|
|
841
846
|
});
|
|
842
847
|
var targetSeats = digits * 100;
|
|
843
848
|
var seats = votesPerQuota.map(function (votes) {
|
package/package.json
CHANGED
package/src/components/Legend.js
CHANGED
|
@@ -30,9 +30,7 @@ export default memo(
|
|
|
30
30
|
formatter,
|
|
31
31
|
}) => {
|
|
32
32
|
if (!show) return null;
|
|
33
|
-
|
|
34
33
|
const _series = sortPie(series, order);
|
|
35
|
-
|
|
36
34
|
const [_alignment, position] = alignment.split(' ');
|
|
37
35
|
const length = _series.length;
|
|
38
36
|
|
|
@@ -66,7 +64,7 @@ export default memo(
|
|
|
66
64
|
>
|
|
67
65
|
{_series.map((series, index) => {
|
|
68
66
|
const { type, name, displayName, icon, selected } = series;
|
|
69
|
-
const _icon = getIcon(type, icon);
|
|
67
|
+
const _icon = getIcon(type, icon, series?.config?.line?.type);
|
|
70
68
|
return (
|
|
71
69
|
<li
|
|
72
70
|
key={index}
|
|
@@ -175,22 +175,24 @@ const getArc = (
|
|
|
175
175
|
...rest
|
|
176
176
|
},
|
|
177
177
|
series
|
|
178
|
-
) =>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
178
|
+
) => {
|
|
179
|
+
return {
|
|
180
|
+
...rest,
|
|
181
|
+
type: 'pie',
|
|
182
|
+
fieldName: series.fieldName,
|
|
183
|
+
displayName: series.displayName || rest.data.s,
|
|
184
|
+
series: series,
|
|
185
|
+
innerRadius: innerRadius * radius,
|
|
186
|
+
outerRadius: outerRadius * radius,
|
|
187
|
+
arc: arc()
|
|
188
|
+
.innerRadius(innerRadius * radius)
|
|
189
|
+
.outerRadius(outerRadius * radius)
|
|
190
|
+
.cornerRadius(cornerRadius)
|
|
191
|
+
.startAngle(startAngle)
|
|
192
|
+
.endAngle(endAngle)
|
|
193
|
+
.padAngle(padAngle),
|
|
194
|
+
}
|
|
195
|
+
};
|
|
194
196
|
|
|
195
197
|
const getCircleScale = ({ count, color, width, length } = tick, radius) => {
|
|
196
198
|
let data = [],
|
|
@@ -353,7 +355,8 @@ const Component = memo(
|
|
|
353
355
|
const seriesLength = series.size;
|
|
354
356
|
if (!seriesLength) return [];
|
|
355
357
|
const _series = [...series.values()];
|
|
356
|
-
|
|
358
|
+
if(_series.length<arcs.length) console.warn("请检查数据中是否存在相同的s")
|
|
359
|
+
return arcs.map((arc, index) => getArc(radius, arc, _series[index%_series.length]));
|
|
357
360
|
}, [series, arcs, radius]);
|
|
358
361
|
const onClick = useCallback(
|
|
359
362
|
(e) =>
|
package/src/utils/index.js
CHANGED
|
@@ -80,14 +80,16 @@ const getColorList = ({ type, pure, linear: { stops, angle, opacity } }) => {
|
|
|
80
80
|
}
|
|
81
81
|
return stops.map(({ color, offset }) => ({ color, offset: offset / 100 }));
|
|
82
82
|
};
|
|
83
|
-
const getIcon = (type, icon) => {
|
|
83
|
+
const getIcon = (type, icon, lineType="solid") => {
|
|
84
84
|
switch (type) {
|
|
85
85
|
case 'area':
|
|
86
86
|
case 'line':
|
|
87
|
+
let color = icon.background;
|
|
87
88
|
return icon
|
|
88
89
|
? {
|
|
89
90
|
...defaultLineIcon,
|
|
90
91
|
...icon,
|
|
92
|
+
background:lineType=="solid"?color:`linear-gradient(90deg, ${color}, ${color} 66%, transparent 66%) 0 0/33% 100% repeat`
|
|
91
93
|
}
|
|
92
94
|
: defaultLineIcon;
|
|
93
95
|
default:
|
|
@@ -661,14 +663,14 @@ const getDataWithPercent = (data = [], precision = 0) => {
|
|
|
661
663
|
return 0;
|
|
662
664
|
}
|
|
663
665
|
const sum = valueList.reduce( function (acc, val) {
|
|
664
|
-
return acc + val.
|
|
666
|
+
return acc + val.value;
|
|
665
667
|
}, 0);
|
|
666
668
|
if (sum === 0) {
|
|
667
669
|
return 0;
|
|
668
670
|
}
|
|
669
671
|
const digits = Math.pow(10, precision);
|
|
670
672
|
const votesPerQuota = valueList.map(function (val) {
|
|
671
|
-
return val.
|
|
673
|
+
return val.value / sum * digits * 100;
|
|
672
674
|
});
|
|
673
675
|
const targetSeats = digits * 100;
|
|
674
676
|
const seats = votesPerQuota.map(function (votes) {
|