@easyv/charts 1.4.28 → 1.4.30

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