@easyv/charts 1.4.25 → 1.4.28

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.
Files changed (91) hide show
  1. package/.babelrc +8 -8
  2. package/.husky/commit-msg +3 -3
  3. package/CHANGELOG.md +18 -18
  4. package/commitlint.config.js +1 -1
  5. package/lib/components/AnimateData.js +8 -16
  6. package/lib/components/Axis.js +86 -133
  7. package/lib/components/Background.js +18 -26
  8. package/lib/components/Band.js +72 -98
  9. package/lib/components/BaseLine.js +33 -46
  10. package/lib/components/Brush.js +29 -46
  11. package/lib/components/Carousel.js +13 -40
  12. package/lib/components/CartesianChart.js +98 -146
  13. package/lib/components/Chart.js +23 -36
  14. package/lib/components/ChartContainer.js +18 -27
  15. package/lib/components/ConicalGradient.js +56 -89
  16. package/lib/components/Control.js +12 -28
  17. package/lib/components/ExtentData.js +9 -17
  18. package/lib/components/FilterData.js +16 -27
  19. package/lib/components/Indicator.js +23 -30
  20. package/lib/components/Label.js +96 -126
  21. package/lib/components/Legend.js +41 -66
  22. package/lib/components/Lighter.js +21 -50
  23. package/lib/components/Line.js +39 -59
  24. package/lib/components/LinearGradient.js +16 -22
  25. package/lib/components/Mapping.js +9 -34
  26. package/lib/components/Marquee.js +14 -30
  27. package/lib/components/PieChart.js +468 -489
  28. package/lib/components/StackData.js +8 -18
  29. package/lib/components/StereoBar.js +65 -105
  30. package/lib/components/TextOverflow.js +8 -21
  31. package/lib/components/Tooltip.js +41 -55
  32. package/lib/components/index.js +7 -28
  33. package/lib/components/pieTooltip.js +133 -0
  34. package/lib/context/index.js +0 -2
  35. package/lib/css/index.module.css +42 -42
  36. package/lib/css/piechart.module.css +26 -26
  37. package/lib/element/ConicGradient.js +29 -35
  38. package/lib/element/Line.js +9 -13
  39. package/lib/element/index.js +0 -2
  40. package/lib/formatter/index.js +0 -2
  41. package/lib/formatter/legend.js +30 -41
  42. package/lib/hooks/index.js +0 -9
  43. package/lib/hooks/useAiData.js +12 -20
  44. package/lib/hooks/useAnimateData.js +8 -21
  45. package/lib/hooks/useAxes.js +67 -117
  46. package/lib/hooks/useCarouselAxisX.js +27 -60
  47. package/lib/hooks/useExtentData.js +14 -46
  48. package/lib/hooks/useFilterData.js +13 -34
  49. package/lib/hooks/useStackData.js +12 -35
  50. package/lib/hooks/useTooltip.js +36 -53
  51. package/lib/index.js +0 -15
  52. package/lib/utils/index.js +95 -247
  53. package/package.json +55 -55
  54. package/src/components/Background.tsx +61 -61
  55. package/src/components/Band.tsx +274 -274
  56. package/src/components/Brush.js +159 -159
  57. package/src/components/CartesianChart.js +1 -1
  58. package/src/components/Chart.js +99 -99
  59. package/src/components/ChartContainer.tsx +71 -71
  60. package/src/components/ConicalGradient.js +258 -258
  61. package/src/components/Control.jsx +51 -51
  62. package/src/components/ExtentData.js +17 -17
  63. package/src/components/Indicator.js +61 -61
  64. package/src/components/Label.js +275 -275
  65. package/src/components/Legend.js +165 -165
  66. package/src/components/Lighter.jsx +173 -173
  67. package/src/components/Line.js +150 -150
  68. package/src/components/LinearGradient.js +29 -29
  69. package/src/components/Marquee.tsx +1 -1
  70. package/src/components/PieChart.js +404 -260
  71. package/src/components/PieTooltip.jsx +134 -0
  72. package/src/components/StereoBar.tsx +307 -307
  73. package/src/components/index.js +59 -57
  74. package/src/context/index.js +2 -2
  75. package/src/css/index.module.css +42 -42
  76. package/src/css/piechart.module.css +26 -26
  77. package/src/element/ConicGradient.jsx +55 -55
  78. package/src/element/Line.tsx +33 -33
  79. package/src/element/index.ts +3 -3
  80. package/src/formatter/index.js +1 -1
  81. package/src/formatter/legend.js +92 -92
  82. package/src/hooks/index.js +20 -20
  83. package/src/hooks/useAnimateData.ts +67 -67
  84. package/src/hooks/useCarouselAxisX.js +1 -1
  85. package/src/hooks/useFilterData.js +72 -72
  86. package/src/hooks/useStackData.js +101 -101
  87. package/src/hooks/useTooltip.ts +100 -100
  88. package/src/index.js +6 -6
  89. package/src/types/index.d.ts +67 -67
  90. package/src/utils/index.js +757 -757
  91. package/tsconfig.json +23 -23
@@ -1,37 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.band = band;
9
8
  exports.sortPie = exports.seriesYOrZ = exports.resetStacks = exports.reduceConfig = exports.isValidHttpUrl = exports.identity = exports.getTranslate3d = exports.getTranslate2d = exports.getTicksOfAxis = exports.getTickCoord = exports.getStacks = exports.getSeriesInfo = exports.getMousePos = exports.getMargin = exports.getIcon = exports.getGridCoord = exports.getFontStyle = exports.getDomPath = exports.getDataWithPercent = exports.getCurrentStack = exports.getColorList = exports.getChildren = exports.getBreakWord = exports.getBandwidth = exports.getBandSeriesStepAndWidth = exports.getBandBackground = exports.filterChildren = exports.dateFormat = exports.dataYOrZ = void 0;
10
-
11
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
-
13
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
14
-
15
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
16
-
17
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
-
19
13
  var _utils = require("@easyv/utils");
20
-
21
14
  var _utils2 = require("@easyv/utils/lib/common/utils");
22
-
23
15
  var _d3v = require("d3v7");
24
-
25
16
  var _server = require("react-dom/server");
26
-
27
17
  var _svgPoints = require("svg-points");
28
-
29
18
  var _excluded = ["backgroundSize"];
30
-
31
19
  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; }
32
-
33
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; }
34
-
35
21
  var defaultSize = 10;
36
22
  var defaultBackground = '#000000';
37
23
  var defaultIcon = {
@@ -44,26 +30,25 @@ var defaultLineIcon = {
44
30
  height: 2,
45
31
  background: defaultBackground
46
32
  };
47
-
48
33
  var SvgBackground = function SvgBackground(_ref) {
49
34
  var _ref$fill = _ref.fill,
50
- type = _ref$fill.type,
51
- pure = _ref$fill.pure,
52
- _ref$fill$linear = _ref$fill.linear,
53
- angle = _ref$fill$linear.angle,
54
- opacity = _ref$fill$linear.opacity,
55
- stops = _ref$fill$linear.stops,
56
- _ref$pattern = _ref.pattern,
57
- _ref$pattern$path = _ref$pattern.path,
58
- path = _ref$pattern$path === void 0 ? '' : _ref$pattern$path,
59
- _ref$pattern$width = _ref$pattern.width,
60
- width = _ref$pattern$width === void 0 ? '100%' : _ref$pattern$width,
61
- _ref$pattern$height = _ref$pattern.height,
62
- height = _ref$pattern$height === void 0 ? '100%' : _ref$pattern$height,
63
- _ref$pattern$boderCol = _ref$pattern.boderColor,
64
- stroke = _ref$pattern$boderCol === void 0 ? 'transparent' : _ref$pattern$boderCol,
65
- _ref$pattern$boderWid = _ref$pattern.boderWidth,
66
- boderWidth = _ref$pattern$boderWid === void 0 ? 0 : _ref$pattern$boderWid;
35
+ type = _ref$fill.type,
36
+ pure = _ref$fill.pure,
37
+ _ref$fill$linear = _ref$fill.linear,
38
+ angle = _ref$fill$linear.angle,
39
+ opacity = _ref$fill$linear.opacity,
40
+ stops = _ref$fill$linear.stops,
41
+ _ref$pattern = _ref.pattern,
42
+ _ref$pattern$path = _ref$pattern.path,
43
+ path = _ref$pattern$path === void 0 ? '' : _ref$pattern$path,
44
+ _ref$pattern$width = _ref$pattern.width,
45
+ width = _ref$pattern$width === void 0 ? '100%' : _ref$pattern$width,
46
+ _ref$pattern$height = _ref$pattern.height,
47
+ height = _ref$pattern$height === void 0 ? '100%' : _ref$pattern$height,
48
+ _ref$pattern$boderCol = _ref$pattern.boderColor,
49
+ stroke = _ref$pattern$boderCol === void 0 ? 'transparent' : _ref$pattern$boderCol,
50
+ _ref$pattern$boderWid = _ref$pattern.boderWidth,
51
+ boderWidth = _ref$pattern$boderWid === void 0 ? 0 : _ref$pattern$boderWid;
67
52
  return /*#__PURE__*/React.createElement("svg", {
68
53
  preserveAspectRatio: "none",
69
54
  xmlns: "http://www.w3.org/2000/svg",
@@ -78,7 +63,7 @@ var SvgBackground = function SvgBackground(_ref) {
78
63
  gradientTransform: 'rotate(' + (angle + 180) + ', 0.5, 0.5)'
79
64
  }, stops.map(function (_ref2, index) {
80
65
  var offset = _ref2.offset,
81
- color = _ref2.color;
66
+ color = _ref2.color;
82
67
  return /*#__PURE__*/React.createElement("stop", {
83
68
  key: index,
84
69
  offset: offset + '%',
@@ -92,15 +77,13 @@ var SvgBackground = function SvgBackground(_ref) {
92
77
  strokeWidth: boderWidth
93
78
  }));
94
79
  };
95
-
96
80
  var getColorList = function getColorList(_ref3) {
97
81
  var type = _ref3.type,
98
- pure = _ref3.pure,
99
- _ref3$linear = _ref3.linear,
100
- stops = _ref3$linear.stops,
101
- angle = _ref3$linear.angle,
102
- opacity = _ref3$linear.opacity;
103
-
82
+ pure = _ref3.pure,
83
+ _ref3$linear = _ref3.linear,
84
+ stops = _ref3$linear.stops,
85
+ angle = _ref3$linear.angle,
86
+ opacity = _ref3$linear.opacity;
104
87
  if (type == 'pure') {
105
88
  return [{
106
89
  color: pure,
@@ -110,22 +93,18 @@ var getColorList = function getColorList(_ref3) {
110
93
  offset: 0
111
94
  }];
112
95
  }
113
-
114
96
  return stops.map(function (_ref4) {
115
97
  var color = _ref4.color,
116
- offset = _ref4.offset;
98
+ offset = _ref4.offset;
117
99
  return {
118
100
  color: color,
119
101
  offset: offset / 100
120
102
  };
121
103
  });
122
104
  };
123
-
124
105
  exports.getColorList = getColorList;
125
-
126
106
  var getIcon = function getIcon(type, icon) {
127
107
  var lineType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "solid";
128
-
129
108
  switch (type) {
130
109
  case 'area':
131
110
  case 'line':
@@ -133,14 +112,11 @@ var getIcon = function getIcon(type, icon) {
133
112
  return icon ? _objectSpread(_objectSpread(_objectSpread({}, defaultLineIcon), icon), {}, {
134
113
  background: lineType == "solid" ? color : "linear-gradient(90deg, ".concat(color, ", ").concat(color, " 66%, transparent 66%) 0 0/33% 100% repeat")
135
114
  }) : defaultLineIcon;
136
-
137
115
  default:
138
116
  return icon ? _objectSpread(_objectSpread({}, defaultIcon), icon) : defaultIcon;
139
117
  }
140
118
  };
141
-
142
119
  exports.getIcon = getIcon;
143
-
144
120
  var dateFormat = function dateFormat(date, fmt) {
145
121
  date = new Date(date);
146
122
  var o = {
@@ -163,24 +139,17 @@ var dateFormat = function dateFormat(date, fmt) {
163
139
  w: new Array('Sun.', 'Mon.', ' Tues.', 'Wed.', ' Thur.', 'Fri.', 'Sat.')[date.getDay()]
164
140
  };
165
141
  if (/(Y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
166
-
167
- for (var k in o) {
168
- if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
169
- }
170
-
142
+ for (var k in o) if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
171
143
  return fmt;
172
144
  };
173
-
174
145
  exports.dateFormat = dateFormat;
175
-
176
146
  var getBreakWord = function getBreakWord(str, breakNumber) {
177
147
  var re = new RegExp('([^]){1,' + breakNumber + '}', 'g');
178
148
  return str.match(re);
179
- }; //x轴标签逻辑
180
-
149
+ };
181
150
 
151
+ //x轴标签逻辑
182
152
  exports.getBreakWord = getBreakWord;
183
-
184
153
  var getTicksOfAxis = function getTicksOfAxis(domain, ticksCount, showLast) {
185
154
  var len = domain.length;
186
155
  if (ticksCount < 2 || ticksCount > len) return domain;
@@ -192,54 +161,45 @@ var getTicksOfAxis = function getTicksOfAxis(domain, ticksCount, showLast) {
192
161
  var lastIndex = domain.findIndex(function (d) {
193
162
  return d == ticksArr[Tlen - 1];
194
163
  });
195
-
196
164
  if (showLast) {
197
165
  len % ticksCount == 0 || len - 1 - lastIndex >= Math.round(len / Tlen / 2) ? null : ticksArr.pop();
198
166
  ticksArr.push(domain[len - 1]);
199
167
  }
200
-
201
168
  return ticksArr;
202
169
  };
203
-
204
170
  exports.getTicksOfAxis = getTicksOfAxis;
205
-
206
171
  var getTickCoord = function getTickCoord(_ref5) {
207
172
  var orientation = _ref5.orientation,
208
- coordinate = _ref5.coordinate,
209
- _ref5$tickSize = _ref5.tickSize,
210
- tickSize = _ref5$tickSize === void 0 ? 6 : _ref5$tickSize,
211
- _ref5$x = _ref5.x,
212
- x = _ref5$x === void 0 ? 0 : _ref5$x,
213
- _ref5$y = _ref5.y,
214
- y = _ref5$y === void 0 ? 0 : _ref5$y;
173
+ coordinate = _ref5.coordinate,
174
+ _ref5$tickSize = _ref5.tickSize,
175
+ tickSize = _ref5$tickSize === void 0 ? 6 : _ref5$tickSize,
176
+ _ref5$x = _ref5.x,
177
+ x = _ref5$x === void 0 ? 0 : _ref5$x,
178
+ _ref5$y = _ref5.y,
179
+ y = _ref5$y === void 0 ? 0 : _ref5$y;
215
180
  var x1, x2, y1, y2;
216
-
217
181
  switch (orientation) {
218
182
  case 'top':
219
183
  x1 = x2 = coordinate;
220
184
  y2 = y;
221
185
  y1 = y2 - tickSize;
222
186
  break;
223
-
224
187
  case 'left':
225
188
  y1 = y2 = coordinate;
226
189
  x2 = x;
227
190
  x1 = x2 - tickSize;
228
191
  break;
229
-
230
192
  case 'right':
231
193
  y1 = y2 = coordinate;
232
194
  x2 = x;
233
195
  x1 = x2 + tickSize;
234
196
  break;
235
-
236
197
  default:
237
198
  x1 = x2 = coordinate;
238
199
  y2 = y;
239
200
  y1 = y2 + tickSize;
240
201
  break;
241
202
  }
242
-
243
203
  return {
244
204
  x1: x1,
245
205
  x2: x2,
@@ -247,41 +207,34 @@ var getTickCoord = function getTickCoord(_ref5) {
247
207
  y2: y2
248
208
  };
249
209
  };
250
-
251
210
  exports.getTickCoord = getTickCoord;
252
-
253
211
  var getGridCoord = function getGridCoord(_ref6) {
254
212
  var orientation = _ref6.orientation,
255
- coordinate = _ref6.coordinate,
256
- end = _ref6.end;
213
+ coordinate = _ref6.coordinate,
214
+ end = _ref6.end;
257
215
  var x1, x2, y1, y2;
258
-
259
216
  switch (orientation) {
260
217
  case 'top':
261
218
  x1 = x2 = coordinate;
262
219
  y1 = 0;
263
220
  y2 = end;
264
221
  break;
265
-
266
222
  case 'bottom':
267
223
  x1 = x2 = coordinate;
268
224
  y1 = 0;
269
225
  y2 = end * -1;
270
226
  break;
271
-
272
227
  case 'left':
273
228
  y1 = y2 = coordinate;
274
229
  x1 = 0;
275
230
  x2 = end;
276
231
  break;
277
-
278
232
  case 'right':
279
233
  y1 = y2 = coordinate;
280
234
  x1 = 0;
281
235
  x2 = end * -1;
282
236
  break;
283
237
  }
284
-
285
238
  return {
286
239
  x1: x1,
287
240
  x2: x2,
@@ -289,16 +242,13 @@ var getGridCoord = function getGridCoord(_ref6) {
289
242
  y2: y2
290
243
  };
291
244
  };
292
-
293
245
  exports.getGridCoord = getGridCoord;
294
-
295
246
  var identity = function identity(d) {
296
247
  return d;
297
- }; //获取鼠标指针坐标
298
-
248
+ };
299
249
 
250
+ //获取鼠标指针坐标
300
251
  exports.identity = identity;
301
-
302
252
  var getMousePos = function getMousePos(evt, dom) {
303
253
  var rect = dom.getBoundingClientRect();
304
254
  return {
@@ -308,17 +258,14 @@ var getMousePos = function getMousePos(evt, dom) {
308
258
  h: rect.height
309
259
  };
310
260
  };
311
-
312
261
  exports.getMousePos = getMousePos;
313
-
314
262
  var getFontStyle = function getFontStyle(_ref7, type) {
315
263
  var color = _ref7.color,
316
- bold = _ref7.bold,
317
- italic = _ref7.italic,
318
- fontSize = _ref7.fontSize,
319
- fontFamily = _ref7.fontFamily,
320
- letterSpacing = _ref7.letterSpacing;
321
-
264
+ bold = _ref7.bold,
265
+ italic = _ref7.italic,
266
+ fontSize = _ref7.fontSize,
267
+ fontFamily = _ref7.fontFamily,
268
+ letterSpacing = _ref7.letterSpacing;
322
269
  if (type == 'svg') {
323
270
  return {
324
271
  fontSize: fontSize,
@@ -329,7 +276,6 @@ var getFontStyle = function getFontStyle(_ref7, type) {
329
276
  fontStyle: italic ? 'italic' : 'normal'
330
277
  };
331
278
  }
332
-
333
279
  return {
334
280
  fontSize: fontSize,
335
281
  fontFamily: fontFamily,
@@ -339,63 +285,54 @@ var getFontStyle = function getFontStyle(_ref7, type) {
339
285
  fontStyle: italic ? 'italic' : 'normal'
340
286
  };
341
287
  };
342
-
343
288
  exports.getFontStyle = getFontStyle;
344
-
345
289
  var getMargin = function getMargin(_ref8) {
346
290
  var marginTop = _ref8.marginTop,
347
- marginRight = _ref8.marginRight,
348
- marginBottom = _ref8.marginBottom,
349
- marginLeft = _ref8.marginLeft;
291
+ marginRight = _ref8.marginRight,
292
+ marginBottom = _ref8.marginBottom,
293
+ marginLeft = _ref8.marginLeft;
350
294
  return marginTop + 'px ' + marginRight + 'px ' + marginBottom + 'px ' + marginLeft + 'px';
351
295
  };
352
-
353
296
  exports.getMargin = getMargin;
354
-
355
297
  var getTranslate3d = function getTranslate3d(_ref9) {
356
298
  var _ref9$x = _ref9.x,
357
- x = _ref9$x === void 0 ? 0 : _ref9$x,
358
- _ref9$y = _ref9.y,
359
- y = _ref9$y === void 0 ? 0 : _ref9$y,
360
- _ref9$z = _ref9.z,
361
- z = _ref9$z === void 0 ? 0 : _ref9$z;
299
+ x = _ref9$x === void 0 ? 0 : _ref9$x,
300
+ _ref9$y = _ref9.y,
301
+ y = _ref9$y === void 0 ? 0 : _ref9$y,
302
+ _ref9$z = _ref9.z,
303
+ z = _ref9$z === void 0 ? 0 : _ref9$z;
362
304
  return 'translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)';
363
305
  };
364
-
365
306
  exports.getTranslate3d = getTranslate3d;
366
-
367
307
  var getTranslate2d = function getTranslate2d(_ref10) {
368
308
  var _ref10$x = _ref10.x,
369
- x = _ref10$x === void 0 ? 0 : _ref10$x,
370
- _ref10$y = _ref10.y,
371
- y = _ref10$y === void 0 ? 0 : _ref10$y;
309
+ x = _ref10$x === void 0 ? 0 : _ref10$x,
310
+ _ref10$y = _ref10.y,
311
+ y = _ref10$y === void 0 ? 0 : _ref10$y;
372
312
  return 'translate(' + x + ', ' + y + ')';
373
313
  };
374
-
375
314
  exports.getTranslate2d = getTranslate2d;
376
-
377
315
  function band() {
378
316
  var scale = (0, _d3v.scaleOrdinal)().unknown(undefined),
379
- domain = scale.domain,
380
- ordinalRange = scale.range,
381
- r0 = 0,
382
- r1 = 1,
383
- step,
384
- bandwidth,
385
- round = false,
386
- paddingInner = 0,
387
- paddingOuter = 0,
388
- // seriesPaddingInner = 0,
389
- // seriesPaddingOuter = 0,
390
- // seriesLength = 0,
391
- align = 0.5;
317
+ domain = scale.domain,
318
+ ordinalRange = scale.range,
319
+ r0 = 0,
320
+ r1 = 1,
321
+ step,
322
+ bandwidth,
323
+ round = false,
324
+ paddingInner = 0,
325
+ paddingOuter = 0,
326
+ // seriesPaddingInner = 0,
327
+ // seriesPaddingOuter = 0,
328
+ // seriesLength = 0,
329
+ align = 0.5;
392
330
  delete scale.unknown;
393
-
394
331
  function rescale() {
395
332
  var n = domain().length,
396
- reverse = r1 < r0,
397
- start = reverse ? r1 : r0,
398
- stop = reverse ? r0 : r1;
333
+ reverse = r1 < r0,
334
+ start = reverse ? r1 : r0,
335
+ stop = reverse ? r0 : r1;
399
336
  step = (stop - start) / Math.max(1, n - paddingOuter * 2);
400
337
  if (round) step = Math.floor(step);
401
338
  start += (stop - start - step * n) * align;
@@ -406,96 +343,74 @@ function band() {
406
343
  });
407
344
  return ordinalRange(reverse ? values.reverse() : values);
408
345
  }
409
-
410
346
  scale.domain = function (_) {
411
347
  return arguments.length ? (domain(_), rescale()) : domain();
412
348
  };
413
-
414
349
  scale.range = function (_) {
415
350
  var _ref11;
416
-
417
351
  return arguments.length ? ((_ref11 = (0, _slicedToArray2["default"])(_, 2), r0 = _ref11[0], r1 = _ref11[1]), r0 = +r0, r1 = +r1, rescale()) : [r0, r1];
418
352
  };
419
-
420
353
  scale.rangeRound = function (_) {
421
354
  var _ref12;
422
-
423
355
  return (_ref12 = (0, _slicedToArray2["default"])(_, 2), r0 = _ref12[0], r1 = _ref12[1]), r0 = +r0, r1 = +r1, round = true, rescale();
424
356
  };
425
-
426
357
  scale.bandwidth = function () {
427
358
  return bandwidth;
428
359
  };
429
-
430
360
  scale.step = function () {
431
361
  return step;
432
362
  };
433
-
434
363
  scale.seriesBandwidth = function () {
435
364
  return seriesBandwidth;
436
365
  };
437
-
438
366
  scale.seriesStep = function () {
439
367
  return seriesStep;
440
368
  };
441
-
442
369
  scale.round = function (_) {
443
370
  return arguments.length ? (round = !!_, rescale()) : round;
444
371
  };
445
-
446
372
  scale.padding = function (_) {
447
373
  return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner;
448
374
  };
449
-
450
375
  scale.paddingInner = function (_) {
451
376
  return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner;
452
377
  };
453
-
454
378
  scale.paddingOuter = function (_) {
455
379
  return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter;
456
380
  };
457
-
458
381
  scale.align = function (_) {
459
382
  return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
460
383
  };
461
-
462
384
  scale.copy = function () {
463
385
  return band(domain(), [r0, r1]).round(round).paddingInner(paddingInner).paddingOuter(paddingOuter).align(align);
464
386
  };
465
-
466
387
  return initRange.apply(rescale(), arguments);
467
388
  }
468
-
469
389
  function initRange(domain, range) {
470
390
  switch (arguments.length) {
471
391
  case 0:
472
392
  break;
473
-
474
393
  case 1:
475
394
  this.range(domain);
476
395
  break;
477
-
478
396
  default:
479
397
  this.range(range).domain(domain);
480
398
  break;
481
399
  }
482
-
483
400
  return this;
484
401
  }
485
-
486
402
  var getStacks = function getStacks(series) {
487
403
  var tmp = [];
488
404
  series.forEach(function (_ref13, name) {
489
405
  var type = _ref13.type,
490
- stack = _ref13.stack,
491
- yOrZ = _ref13.yOrZ;
406
+ stack = _ref13.stack,
407
+ yOrZ = _ref13.yOrZ;
492
408
  var current = tmp.find(function (_ref14) {
493
409
  var _type = _ref14.type,
494
- _stack = _ref14.stack,
495
- _yOrZ = _ref14.yOrZ;
410
+ _stack = _ref14.stack,
411
+ _yOrZ = _ref14.yOrZ;
496
412
  return _type == type && stack && _stack == stack && yOrZ == _yOrZ;
497
413
  });
498
-
499
414
  if (!current) {
500
415
  var common = {
501
416
  type: type,
@@ -505,7 +420,6 @@ var getStacks = function getStacks(series) {
505
420
  yOrZ: yOrZ,
506
421
  s: [name]
507
422
  };
508
-
509
423
  if (type === 'band') {
510
424
  var index = tmp.filter(function (item) {
511
425
  return item.type === 'band';
@@ -524,35 +438,27 @@ var getStacks = function getStacks(series) {
524
438
  });
525
439
  return tmp;
526
440
  };
527
-
528
441
  exports.getStacks = getStacks;
529
-
530
442
  var dataYOrZ = function dataYOrZ(data, _ref15) {
531
443
  var seriesY = _ref15.y,
532
- seriesZ = _ref15.z;
444
+ seriesZ = _ref15.z;
533
445
  var tmp = {
534
446
  y: [],
535
447
  z: []
536
448
  };
537
-
538
449
  for (var i = 0, j = data.length; i < j; i++) {
539
450
  var d = data[i];
540
-
541
451
  if (seriesY.get(d.s)) {
542
452
  tmp.y.push(d);
543
453
  continue;
544
454
  }
545
-
546
455
  if (seriesZ.get(d.s)) {
547
456
  tmp.z.push(d);
548
457
  }
549
458
  }
550
-
551
459
  return tmp;
552
460
  };
553
-
554
461
  exports.dataYOrZ = dataYOrZ;
555
-
556
462
  var seriesYOrZ = function seriesYOrZ(series) {
557
463
  var y = new Map();
558
464
  var z = new Map();
@@ -568,55 +474,43 @@ var seriesYOrZ = function seriesYOrZ(series) {
568
474
  z: z
569
475
  };
570
476
  };
571
-
572
477
  exports.seriesYOrZ = seriesYOrZ;
573
-
574
478
  var resetStacks = function resetStacks(stacks) {
575
479
  stacks.forEach(function (stack) {
576
480
  stack.positive = 0;
577
481
  stack.negative = 0;
578
482
  });
579
483
  };
580
-
581
484
  exports.resetStacks = resetStacks;
582
-
583
485
  var getCurrentStack = function getCurrentStack(stack, stackMap) {
584
486
  return stackMap.find(function (_ref16) {
585
487
  var _stack = _ref16.stack,
586
- _type = _ref16.type,
587
- _yOrZ = _ref16.yOrZ,
588
- _s = _ref16.s;
488
+ _type = _ref16.type,
489
+ _yOrZ = _ref16.yOrZ,
490
+ _s = _ref16.s;
589
491
  return _type == stack.type && _stack == stack.stack && _yOrZ == stack.yOrZ && _s.includes(stack.name);
590
492
  });
591
493
  };
592
-
593
494
  exports.getCurrentStack = getCurrentStack;
594
-
595
495
  var getBandBackground = function getBandBackground(pattern, fill) {
596
496
  if (!(pattern && pattern.path)) return (0, _utils.getColor)(fill);
597
-
598
497
  var _pattern$backgroundSi = pattern.backgroundSize,
599
- backgroundSize = _pattern$backgroundSi === void 0 ? '100% 100%' : _pattern$backgroundSi,
600
- _pattern = (0, _objectWithoutProperties2["default"])(pattern, _excluded);
601
-
498
+ backgroundSize = _pattern$backgroundSi === void 0 ? '100% 100%' : _pattern$backgroundSi,
499
+ _pattern = (0, _objectWithoutProperties2["default"])(pattern, _excluded);
602
500
  return 'center top / ' + backgroundSize + ' url("data:image/svg+xml,' + encodeURIComponent((0, _server.renderToStaticMarkup)( /*#__PURE__*/React.createElement(SvgBackground, {
603
501
  fill: fill,
604
502
  pattern: _pattern
605
503
  }))) + '")';
606
504
  };
607
-
608
505
  exports.getBandBackground = getBandBackground;
609
-
610
506
  var getBandwidth = function getBandwidth(step, paddingOuter) {
611
507
  return step * (1 - paddingOuter);
612
508
  };
613
-
614
509
  exports.getBandwidth = getBandwidth;
615
-
616
510
  var getBandSeriesStepAndWidth = function getBandSeriesStepAndWidth(_ref17) {
617
511
  var width = _ref17.width,
618
- paddingInner = _ref17.paddingInner,
619
- bandLength = _ref17.bandLength;
512
+ paddingInner = _ref17.paddingInner,
513
+ bandLength = _ref17.bandLength;
620
514
  var seriesStep = width / (bandLength == 0 ? 1 : bandLength);
621
515
  var seriesWidth = seriesStep * (1 - paddingInner);
622
516
  return {
@@ -624,26 +518,22 @@ var getBandSeriesStepAndWidth = function getBandSeriesStepAndWidth(_ref17) {
624
518
  seriesWidth: seriesWidth
625
519
  };
626
520
  };
627
-
628
521
  exports.getBandSeriesStepAndWidth = getBandSeriesStepAndWidth;
629
-
630
522
  var getSeriesInfo = function getSeriesInfo(_ref18) {
631
523
  var step = _ref18.step,
632
- _ref18$bandLength = _ref18.bandLength,
633
- bandLength = _ref18$bandLength === void 0 ? 1 : _ref18$bandLength,
634
- _ref18$paddingInner = _ref18.paddingInner,
635
- paddingInner = _ref18$paddingInner === void 0 ? 0 : _ref18$paddingInner,
636
- _ref18$paddingOuter = _ref18.paddingOuter,
637
- paddingOuter = _ref18$paddingOuter === void 0 ? 0 : _ref18$paddingOuter;
524
+ _ref18$bandLength = _ref18.bandLength,
525
+ bandLength = _ref18$bandLength === void 0 ? 1 : _ref18$bandLength,
526
+ _ref18$paddingInner = _ref18.paddingInner,
527
+ paddingInner = _ref18$paddingInner === void 0 ? 0 : _ref18$paddingInner,
528
+ _ref18$paddingOuter = _ref18.paddingOuter,
529
+ paddingOuter = _ref18$paddingOuter === void 0 ? 0 : _ref18$paddingOuter;
638
530
  if (bandLength == 0) return {
639
531
  seriesWidth: step,
640
532
  seriesStep: step,
641
533
  seriesStart: 0,
642
534
  width: step
643
535
  };
644
-
645
536
  var _step = step / (bandLength + paddingOuter * 2 + paddingInner * (bandLength - 1));
646
-
647
537
  return {
648
538
  seriesWidth: _step,
649
539
  seriesStep: (1 + paddingInner) * _step,
@@ -651,23 +541,17 @@ var getSeriesInfo = function getSeriesInfo(_ref18) {
651
541
  width: step - paddingOuter * 2 * _step
652
542
  };
653
543
  };
654
-
655
544
  exports.getSeriesInfo = getSeriesInfo;
656
-
657
545
  var isValidHttpUrl = function isValidHttpUrl(string) {
658
546
  var url;
659
-
660
547
  try {
661
548
  url = new URL(string);
662
549
  } catch (_) {
663
550
  return false;
664
551
  }
665
-
666
552
  return url.protocol === 'http:' || url.protocol === 'https:';
667
553
  };
668
-
669
554
  exports.isValidHttpUrl = isValidHttpUrl;
670
-
671
555
  var getChildren = function getChildren(svgStr) {
672
556
  var wrapper = document.createElement('div');
673
557
  wrapper.innerHTML = svgStr;
@@ -675,20 +559,15 @@ var getChildren = function getChildren(svgStr) {
675
559
  var svgDom = (0, _toConsumableArray2["default"])(childNodes).find(function (item) {
676
560
  return item.tagName === 'svg';
677
561
  });
678
-
679
562
  if (!!svgDom) {
680
563
  return (0, _toConsumableArray2["default"])(svgDom.childNodes);
681
564
  }
682
-
683
565
  return null;
684
566
  };
685
-
686
567
  exports.getChildren = getChildren;
687
-
688
568
  var filterChildren = function filterChildren(children, tagNames) {
689
569
  return children.reduce(function (prev, node) {
690
570
  var nodeName = node.nodeName;
691
-
692
571
  if (tagNames.indexOf(nodeName) > -1) {
693
572
  if (nodeName === 'g') {
694
573
  return filterChildren((0, _toConsumableArray2["default"])(node.childNodes), tagNames);
@@ -696,13 +575,10 @@ var filterChildren = function filterChildren(children, tagNames) {
696
575
  prev.push(node);
697
576
  }
698
577
  }
699
-
700
578
  return prev;
701
579
  }, []);
702
580
  };
703
-
704
581
  exports.filterChildren = filterChildren;
705
-
706
582
  var getDomPath = function getDomPath(node) {
707
583
  switch (node.nodeName) {
708
584
  case 'circle':
@@ -712,7 +588,6 @@ var getDomPath = function getDomPath(node) {
712
588
  cy: +node.getAttribute('cy') || 0,
713
589
  r: +node.getAttribute('r') || 0
714
590
  });
715
-
716
591
  case 'ellipse':
717
592
  return (0, _svgPoints.toPath)({
718
593
  type: 'ellipse',
@@ -721,7 +596,6 @@ var getDomPath = function getDomPath(node) {
721
596
  rx: +node.getAttribute('rx') || 0,
722
597
  ry: +node.getAttribute('ry') || 0
723
598
  });
724
-
725
599
  case 'line':
726
600
  return (0, _svgPoints.toPath)({
727
601
  type: 'line',
@@ -730,25 +604,21 @@ var getDomPath = function getDomPath(node) {
730
604
  y1: +node.getAttribute('y1') || 0,
731
605
  y2: +node.getAttribute('y2') || 0
732
606
  });
733
-
734
607
  case 'path':
735
608
  return (0, _svgPoints.toPath)({
736
609
  type: 'path',
737
610
  d: node.getAttribute('d') || ''
738
611
  });
739
-
740
612
  case 'polygon':
741
613
  return (0, _svgPoints.toPath)({
742
614
  type: 'polyline',
743
615
  points: node.getAttribute('points') || ''
744
616
  });
745
-
746
617
  case 'polyline':
747
618
  return (0, _svgPoints.toPath)({
748
619
  type: 'polyline',
749
620
  points: node.getAttribute('points') || ''
750
621
  });
751
-
752
622
  case 'rect':
753
623
  return (0, _svgPoints.toPath)({
754
624
  type: 'rect',
@@ -761,14 +631,11 @@ var getDomPath = function getDomPath(node) {
761
631
  });
762
632
  }
763
633
  };
764
-
765
634
  exports.getDomPath = getDomPath;
766
-
767
635
  var sortPie = function sortPie(data, order) {
768
636
  var _data = data.map(function (item) {
769
637
  return _objectSpread({}, item);
770
638
  });
771
-
772
639
  switch (order) {
773
640
  case '':
774
641
  _data.sort(function (_ref19, _ref20) {
@@ -776,33 +643,31 @@ var sortPie = function sortPie(data, order) {
776
643
  var b = _ref20.index;
777
644
  return (0, _d3v.ascending)(a, b);
778
645
  });
779
-
780
646
  break;
781
-
782
647
  case 'desc':
783
648
  _data.sort(function (_ref21, _ref22) {
784
649
  var a = _ref21.value;
785
650
  var b = _ref22.value;
786
651
  return (0, _d3v.descending)(a, b);
787
652
  });
788
-
789
653
  break;
790
-
791
654
  case 'asc':
792
655
  _data.sort(function (_ref23, _ref24) {
793
656
  var a = _ref23.value;
794
657
  var b = _ref24.value;
795
658
  return (0, _d3v.ascending)(a, b);
796
659
  });
797
-
798
660
  break;
799
661
  }
800
-
801
662
  return _data;
802
- }; // const getDataWithPercent = (data = [], precision = 0, type) => {
663
+ };
664
+
665
+ // const getDataWithPercent = (data = [], precision = 0, type) => {
803
666
  // const digits = Math.pow(10, precision);
804
667
  // const targetSeats = digits * 100;
668
+
805
669
  // const total = sum(data, (d) => d.value);
670
+
806
671
  // const votesPerQuota = data.map((d, index) => ({
807
672
  // ...d,
808
673
  // vote: Math.round((d.value / total) * digits * 100),
@@ -812,34 +677,29 @@ var sortPie = function sortPie(data, order) {
812
677
  // const remainder = targetSeats - currentSum;
813
678
  // console.log(type+":",votesPerQuota, toFixed);
814
679
  // votesPerQuota.sort(({ value: a }, { value: b }) => (a % total) - (b % total));
680
+
815
681
  // const tmp = votesPerQuota.map(({ vote, ...data }, index) => ({
816
682
  // ...data,
817
683
  // percent: toFixed((vote + (index < remainder ? 1 : 0)) / digits, precision),
818
684
  // }));
685
+
819
686
  // return tmp;
820
687
  // };
821
-
822
-
823
688
  exports.sortPie = sortPie;
824
-
825
689
  var getDataWithPercent = function getDataWithPercent() {
826
690
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
827
691
  var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
828
692
  var objData = [];
829
-
830
693
  function getPercentWithPrecision(valueList, idx, precision) {
831
694
  if (!valueList[idx]) {
832
695
  return 0;
833
696
  }
834
-
835
697
  var sum = valueList.reduce(function (acc, val) {
836
698
  return acc + val.value;
837
699
  }, 0);
838
-
839
700
  if (sum === 0) {
840
701
  return 0;
841
702
  }
842
-
843
703
  var digits = Math.pow(10, precision);
844
704
  var votesPerQuota = valueList.map(function (val) {
845
705
  return val.value / sum * digits * 100;
@@ -854,26 +714,21 @@ var getDataWithPercent = function getDataWithPercent() {
854
714
  var remainder = votesPerQuota.map(function (votes, idx) {
855
715
  return votes - seats[idx];
856
716
  });
857
-
858
717
  while (currentSum < targetSeats) {
859
718
  var max = Number.NEGATIVE_INFINITY;
860
719
  var maxId = null;
861
-
862
720
  for (var i = 0, len = remainder.length; i < len; ++i) {
863
721
  if (remainder[i] > max) {
864
722
  max = remainder[i];
865
723
  maxId = i;
866
724
  }
867
725
  }
868
-
869
726
  ++seats[maxId];
870
727
  remainder[maxId] = 0;
871
728
  ++currentSum;
872
729
  }
873
-
874
730
  return seats[idx] / digits;
875
731
  }
876
-
877
732
  data.forEach(function (d, i) {
878
733
  objData.push(_objectSpread(_objectSpread({}, d), {}, {
879
734
  percent: getPercentWithPrecision(data, i, precision)
@@ -881,25 +736,18 @@ var getDataWithPercent = function getDataWithPercent() {
881
736
  });
882
737
  return objData;
883
738
  };
884
-
885
739
  exports.getDataWithPercent = getDataWithPercent;
886
740
  var excludeTypes = ['array', 'object', 'group', 'modal', 'colors'];
887
-
888
741
  var reduceConfig = function reduceConfig() {
889
742
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
890
-
891
743
  if (!Array.isArray(config)) {
892
744
  return config;
893
745
  }
894
-
895
746
  var output = {};
896
-
897
747
  for (var i = 0, len = config.length; i < len; i++) {
898
748
  var type = config[i]._type;
899
749
  output[config[i]._name] = type && !excludeTypes.includes(type) ? config[i]._value : reduceConfig(config[i]._value);
900
750
  }
901
-
902
751
  return output;
903
752
  };
904
-
905
753
  exports.reduceConfig = reduceConfig;