react-minimal-pie-chart 8.2.0 → 8.4.0

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/README.md CHANGED
@@ -21,7 +21,7 @@ Because [Recharts][recharts-github] is awesome, but when you just need a simple
21
21
 
22
22
  | | Size<br>by Bundlefobia | Benchmark Size \* | Loading time<br>on a slow 3g \* |
23
23
  | :----------------------------------------------------: | :-----------------------------------------------------------------------------------------------------: | :---------------: | :-----------------------------: |
24
- | react-minimal-pie-chart (_v8.2.0_) | [![Bundle size: React minimal pie chart][bundlephobia-badge]][bundlephobia] | 1.83 KB | ~38 ms |
24
+ | react-minimal-pie-chart (_v8.4.0_) | [![Bundle size: React minimal pie chart][bundlephobia-badge]][bundlephobia] | 1.93 KB | ~39 ms |
25
25
  | [rechart][recharts-github] (_v1.8.5_) | [![Bundle size: Recharts][recharts-bundlephobia-badge]][recharts-bundlephobia] | 96.9 KB | ~1900 ms |
26
26
  | [victory-pie][victory-pie-github] (_v34.1.3_) | [![Bundle size: Victory pie][victory-pie-bundlephobia-badge]][victory-pie-bundlephobia] | 50.5 KB | ~1100 ms |
27
27
  | [react-apexcharts][react-apexcharts-github] (_v1.3.7_) | [![Bundle size: React apec charts][react-apexcharts-bundlephobia-badge]][react-apexcharts-bundlephobia] | 114.6 KB | ~2300 ms |
@@ -78,17 +78,17 @@ import { PieChart } from 'react-minimal-pie-chart';
78
78
  | **paddingAngle** | `number` | Angle between two segments | - |
79
79
  | **rounded** | `boolean` | Round line caps of each segment | - |
80
80
  | **segmentsShift** | `number`</br>or:</br>`(segmentIndex) => number` | Translates segments radially. If `number` set, provide shift value relative to `viewBoxSize` space. If `function`, return a value for each segment.</br>_(`radius` prop might be adjusted to prevent segments from overflowing chart's boundaries)_ | - |
81
- | **segmentsStyle** | `CSSObject`</br>or:</br>`(segmentIndex) => CSSObject` | Style object assigned to each segment. If `function`, return a value for each segment | - |
81
+ | **segmentsStyle** | `CSSObject`</br>or:</br>`(segmentIndex) => CSSObject` | Style object assigned to each segment. If `function`, return a value for each segment. *(Warning: SVG only supports [its own CSS props][svg-css])*. | - |
82
82
  | **segmentsTabIndex** | `number` | [`tabindex` attribute](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/tabindex) assigned to segments | - |
83
- | [**label**][label-props-docs] | `(labelRenderProps) => string \| number \| ReactElement` | A function returning a label value or the SVG element to be rendered as label | - |
83
+ | [**label**][label-props-docs] | `(labelRenderProps) => string \| number \| ReactElement` | A function returning a label value or the [SVG element][svg-elements] to be rendered as label | - |
84
84
  | **labelPosition** | `number` (%) | Label position from origin. Percentage of chart's radius _(50 === middle point)_ | 50 |
85
- | **labelStyle** | `CSSObject`</br>or:</br>`(segmentIndex) => CSSObject` | Style object assigned to each label. If `function` set, return style for each label | - |
85
+ | **labelStyle** | `CSSObject`</br>or:</br>`(segmentIndex) => CSSObject` | Style object assigned to each label. If `function` set, return style for each label. *(Warning: SVG only supports [its own CSS props][svg-css])*. | - |
86
86
  | **animate** | `boolean` | Animate segments on component mount | - |
87
87
  | **animationDuration** | `number` | Animation duration in ms | 500 |
88
88
  | **animationEasing** | `string` | A [CSS easing function](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function) | ease-out |
89
89
  | **reveal** | `number` (%) | Turn on CSS animation and reveal just a percentage of each segment | - |
90
90
  | **background** | `string` | Segments' background color | - |
91
- | **children** | `ReactElement` (svg) | Elements rendered as children of SVG element (eg. SVG `defs` and gradient elements) | - |
91
+ | **children** | `ReactElement` (svg) | Elements rendered as children of [SVG element][svg-elements] (eg. SVG `defs` and gradient elements) | - |
92
92
  | **radius** | `number` (user units) | Radius of the pie (relative to `viewBoxSize` space) | 50 |
93
93
  | **center** | `[number, number]` | x and y coordinates of center (relative to `viewBoxSize` space) | [50, 50] |
94
94
  | **viewBoxSize** | `[number, number]` | `width` and `height` of SVG `viewBox` attribute | [100, 100] |
@@ -101,6 +101,12 @@ import { PieChart } from 'react-minimal-pie-chart';
101
101
  | | `.oOo.oOo.oOo.oOo.oOo.oOo.oOo.` | | |
102
102
  <!-- prettier-ignore-end -->
103
103
 
104
+ Prop types are exposed for convenience:
105
+
106
+ ```ts
107
+ import type { PieChartProps } from 'react-minimal-pie-chart';
108
+ ```
109
+
104
110
  ### About `data` prop
105
111
 
106
112
  `data` prop expects an array of chart entries as follows:
@@ -205,11 +211,9 @@ This library uses the `stroke-dasharray` + `stroke-dashoffset` animation strateg
205
211
 
206
212
  - Consider moving storybook deployment to CI
207
213
  - Consider using `transform` to mutate segments/labels positions
208
- - Consider exposing a reduced chart variation including just a subset of the features
209
214
  - Consider abstracting React bindings to re-use business logic with other frameworks
210
- - Remove `defaultProps` in favour of JS default arguments
211
215
  - Provide a way to supply `svg` element with any extra prop
212
- - Consider removing `import type` declaration from generated type definition files (if possible) to ensure Typescript 3.0+ backward compatibility
216
+ - Find a better solution to assign default props
213
217
 
214
218
  ## Contributors
215
219
 
@@ -253,8 +257,8 @@ Thanks to you all ([emoji key](https://github.com/kentcdodds/all-contributors#em
253
257
 
254
258
  <!-- ALL-CONTRIBUTORS-LIST:END -->
255
259
 
256
- [ci-badge]: https://travis-ci.com/toomuchdesign/react-minimal-pie-chart.svg?branch=master
257
- [ci]: https://travis-ci.com/toomuchdesign/react-minimal-pie-chart
260
+ [ci-badge]: https://github.com/toomuchdesign/react-minimal-pie-chart/actions/workflows/ci.yml/badge.svg
261
+ [ci]: https://github.com/toomuchdesign/react-minimal-pie-chart/actions/workflows/ci.yml
258
262
  [coveralls-badge]: https://coveralls.io/repos/github/toomuchdesign/react-minimal-pie-chart/badge.svg?branch=master
259
263
  [coveralls]: https://coveralls.io/github/toomuchdesign/react-minimal-pie-chart?branch=master
260
264
  [npm]: https://www.npmjs.com/package/react-minimal-pie-chart
@@ -279,6 +283,8 @@ Thanks to you all ([emoji key](https://github.com/kentcdodds/all-contributors#em
279
283
  [demo-interaction-2-source]: https://github.com/toomuchdesign/react-minimal-pie-chart/blob/v8.0.0/stories/InteractionTabStory.tsx
280
284
  [demo-tooltip]: https://toomuchdesign.github.io/react-minimal-pie-chart/index.html?path=/story/misc--tooltip-integration
281
285
  [demo-tooltip-source]: https://github.com/toomuchdesign/react-minimal-pie-chart/blob/master/stories/Tooltip.tsx
282
- [demo-label-source]: https://github.com/toomuchdesign/react-minimal-pie-chart/blob/v8.0.0/stories/index.js#L80
286
+ [demo-label-source]: https://github.com/toomuchdesign/react-minimal-pie-chart/blob/v8.2.0/stories/index.tsx#L81
283
287
  [data-props-docs]: #about-data-prop
284
288
  [label-props-docs]: #custom-labels-with-label-render-prop
289
+ [svg-elements]: https://developer.mozilla.org/en-US/docs/Web/SVG/Element
290
+ [svg-css]: https://css-tricks.com/svg-properties-and-css/#aa-properties-shared-between-css-and-svg
package/dist/index.js CHANGED
@@ -2,11 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactMinimalPieChart = {}, global.React));
5
- }(this, (function (exports, React) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
5
+ })(this, (function (exports, React) { 'use strict';
10
6
 
11
7
  function degreesToRadians(degrees) {
12
8
  return degrees * Math.PI / 180;
@@ -35,24 +31,33 @@
35
31
  function functionProp(prop, payload) {
36
32
  return typeof prop === 'function' ? prop(payload) : prop;
37
33
  }
34
+ function makePropsWithDefaults(props, defaultProps) {
35
+ var result = Object.assign({}, defaultProps, props);
36
+
37
+ // @NOTE Object.assign doesn't default properties with undefined value (like React defaultProps does)
38
+ for (var key in defaultProps) {
39
+ if (props[key] === undefined) {
40
+ result[key] = defaultProps[key];
41
+ }
42
+ }
43
+ return result;
44
+ }
38
45
 
39
46
  function sumValues(data) {
40
47
  var sum = 0;
41
-
42
48
  for (var i = 0; i < data.length; i++) {
43
49
  sum += data[i].value;
44
50
  }
45
-
46
51
  return sum;
47
- } // Append "percentage", "degrees" and "startAngle" to each data entry
48
-
52
+ }
49
53
 
54
+ // Append "percentage", "degrees" and "startAngle" to each data entry
50
55
  function extendData(_ref) {
51
56
  var data = _ref.data,
52
- totalAngle = _ref.lengthAngle,
53
- totalValue = _ref.totalValue,
54
- paddingAngle = _ref.paddingAngle,
55
- chartStartAngle = _ref.startAngle;
57
+ totalAngle = _ref.lengthAngle,
58
+ totalValue = _ref.totalValue,
59
+ paddingAngle = _ref.paddingAngle,
60
+ chartStartAngle = _ref.startAngle;
56
61
  var total = totalValue || sumValues(data);
57
62
  var normalizedTotalAngle = valueBetween(totalAngle, -360, 360);
58
63
  var numberOfPaddings = Math.abs(normalizedTotalAngle) === 360 ? data.length : data.length - 1;
@@ -60,8 +65,9 @@
60
65
  var degreesTakenByPadding = singlePaddingDegrees * numberOfPaddings;
61
66
  var degreesTakenByPaths = normalizedTotalAngle - degreesTakenByPadding;
62
67
  var lastSegmentEnd = 0;
63
- var extendedData = []; // @NOTE: Shall we evaluate percentage accordingly to dataEntry.value's sign?
68
+ var extendedData = [];
64
69
 
70
+ // @NOTE: Shall we evaluate percentage accordingly to dataEntry.value's sign?
65
71
  for (var i = 0; i < data.length; i++) {
66
72
  var dataEntry = data[i];
67
73
  var valueInPercentage = total === 0 ? 0 : dataEntry.value / total * 100;
@@ -74,7 +80,6 @@
74
80
  degrees: degrees
75
81
  }, dataEntry));
76
82
  }
77
-
78
83
  return extendedData;
79
84
  }
80
85
 
@@ -83,86 +88,67 @@
83
88
  var target = {};
84
89
  var sourceKeys = Object.keys(source);
85
90
  var key, i;
86
-
87
91
  for (i = 0; i < sourceKeys.length; i++) {
88
92
  key = sourceKeys[i];
89
93
  if (excluded.indexOf(key) >= 0) continue;
90
94
  target[key] = source[key];
91
95
  }
92
-
93
96
  return target;
94
97
  }
95
98
 
96
99
  function ReactMinimalPieChartLabel(_ref) {
97
- _ref.dataEntry;
98
- _ref.dataIndex;
99
- var props = _objectWithoutPropertiesLoose(_ref, ["dataEntry", "dataIndex"]);
100
+ var renderLabel = _ref.renderLabel,
101
+ labelProps = _ref.labelProps;
102
+ var label = renderLabel(labelProps);
100
103
 
101
- return /*#__PURE__*/React__default['default'].createElement("text", Object.assign({
102
- dominantBaseline: "central"
103
- }, props));
104
+ // Default label
105
+ if (typeof label === 'string' || typeof label === 'number') {
106
+ labelProps.dataEntry;
107
+ labelProps.dataIndex;
108
+ var props = _objectWithoutPropertiesLoose(labelProps, ["dataEntry", "dataIndex"]);
109
+ return /*#__PURE__*/React.createElement("text", Object.assign({
110
+ dominantBaseline: "central"
111
+ }, props), label);
112
+ }
113
+ if (React.isValidElement(label)) {
114
+ return label;
115
+ }
116
+ return null;
104
117
  }
105
118
 
106
119
  function round(number) {
107
120
  var divisor = 1e14; // 14 decimals
108
-
109
121
  return Math.round((number + Number.EPSILON) * divisor) / divisor;
110
122
  }
111
-
112
123
  function evaluateTextAnchorPosition(_ref) {
113
124
  var labelPosition = _ref.labelPosition,
114
- lineWidth = _ref.lineWidth,
115
- labelHorizontalShift = _ref.labelHorizontalShift;
116
- var dx = round(labelHorizontalShift); // Label in the vertical center
117
-
125
+ lineWidth = _ref.lineWidth,
126
+ labelHorizontalShift = _ref.labelHorizontalShift;
127
+ var dx = round(labelHorizontalShift);
128
+ // Label in the vertical center
118
129
  if (dx === 0) {
119
130
  return 'middle';
120
- } // Outward label
121
-
122
-
131
+ }
132
+ // Outward label
123
133
  if (labelPosition > 100) {
124
134
  return dx > 0 ? 'start' : 'end';
125
- } // Inward label
126
-
127
-
135
+ }
136
+ // Inward label
128
137
  var innerRadius = 100 - lineWidth;
129
-
130
138
  if (labelPosition < innerRadius) {
131
139
  return dx > 0 ? 'end' : 'start';
132
- } // Overlying label
133
-
134
-
135
- return 'middle';
136
- }
137
-
138
- function renderLabelElement(renderLabel, labelProps) {
139
- var label = renderLabel(labelProps);
140
-
141
- if (typeof label === 'string' || typeof label === 'number') {
142
- return /*#__PURE__*/React__default['default'].createElement(ReactMinimalPieChartLabel, Object.assign({
143
- key: "label-" + (labelProps.dataEntry.key || labelProps.dataIndex)
144
- }, labelProps), label);
145
140
  }
146
-
147
- if (React__default['default'].isValidElement(label)) {
148
- return label;
149
- }
150
-
151
- return null;
141
+ // Overlying label
142
+ return 'middle';
152
143
  }
153
-
154
- function renderLabels(data, props) {
144
+ function makeLabelRenderProps(data, props) {
155
145
  return data.map(function (dataEntry, index) {
156
146
  var _functionProp;
157
-
158
147
  var segmentsShift = (_functionProp = functionProp(props.segmentsShift, index)) != null ? _functionProp : 0;
159
148
  var distanceFromCenter = extractPercentage(props.radius, props.labelPosition) + segmentsShift;
160
-
161
149
  var _shiftVectorAlongAngl = shiftVectorAlongAngle(bisectorAngle(dataEntry.startAngle, dataEntry.degrees), distanceFromCenter),
162
- dx = _shiftVectorAlongAngl.dx,
163
- dy = _shiftVectorAlongAngl.dy; // This object is passed as argument to the "label" function prop
164
-
165
-
150
+ dx = _shiftVectorAlongAngl.dx,
151
+ dy = _shiftVectorAlongAngl.dy; // This object is passed as argument to the "label" function prop
166
152
  var labelRenderProps = {
167
153
  x: props.center[0],
168
154
  y: props.center[1],
@@ -177,10 +163,23 @@
177
163
  dataIndex: index,
178
164
  style: functionProp(props.labelStyle, index)
179
165
  };
180
- return props.label && renderLabelElement(props.label, labelRenderProps);
166
+ return labelRenderProps;
181
167
  });
182
168
  }
169
+ function renderLabels(data, props) {
170
+ var label = props.label;
171
+ if (label) {
172
+ return makeLabelRenderProps(data, props).map(function (labelRenderProps, index) {
173
+ return /*#__PURE__*/React.createElement(ReactMinimalPieChartLabel, {
174
+ key: "label-" + (labelRenderProps.dataEntry.key || index),
175
+ renderLabel: label,
176
+ labelProps: labelRenderProps
177
+ });
178
+ });
179
+ }
180
+ }
183
181
 
182
+ // from http://stackoverflow.com/a/18473154
184
183
  var partialCircle = function partialCircle(cx, cy, r, start, end) {
185
184
  var length = end - start;
186
185
  if (length === 0) return [];
@@ -192,96 +191,90 @@
192
191
  var sweep = length < 0 ? '0' : '1';
193
192
  return [['M', fromX, fromY], ['A', r, r, 0, large, sweep, toX, toY]];
194
193
  };
195
-
196
194
  var svgPartialCircle = partialCircle;
197
195
 
196
+ var partialCircle$1 = svgPartialCircle;
197
+
198
198
  function makePathCommands(cx, cy, startAngle, lengthAngle, radius) {
199
199
  var patchedLengthAngle = valueBetween(lengthAngle, -359.999, 359.999);
200
- return svgPartialCircle(cx, cy, // center X and Y
200
+ return partialCircle$1(cx, cy,
201
+ // center X and Y
201
202
  radius, degreesToRadians(startAngle), degreesToRadians(startAngle + patchedLengthAngle)).map(function (command) {
202
203
  return command.join(' ');
203
204
  }).join(' ');
204
205
  }
205
206
  function ReactMinimalPieChartPath(_ref) {
206
207
  var cx = _ref.cx,
207
- cy = _ref.cy,
208
- lengthAngle = _ref.lengthAngle,
209
- lineWidth = _ref.lineWidth,
210
- radius = _ref.radius,
211
- _ref$shift = _ref.shift,
212
- shift = _ref$shift === void 0 ? 0 : _ref$shift,
213
- reveal = _ref.reveal,
214
- rounded = _ref.rounded,
215
- startAngle = _ref.startAngle,
216
- title = _ref.title,
217
- props = _objectWithoutPropertiesLoose(_ref, ["cx", "cy", "lengthAngle", "lineWidth", "radius", "shift", "reveal", "rounded", "startAngle", "title"]);
218
-
219
- var pathRadius = radius - lineWidth / 2; //@NOTE This shift might be rendered as a translation in future
220
-
208
+ cy = _ref.cy,
209
+ lengthAngle = _ref.lengthAngle,
210
+ lineWidth = _ref.lineWidth,
211
+ radius = _ref.radius,
212
+ _ref$shift = _ref.shift,
213
+ shift = _ref$shift === void 0 ? 0 : _ref$shift,
214
+ reveal = _ref.reveal,
215
+ rounded = _ref.rounded,
216
+ startAngle = _ref.startAngle,
217
+ title = _ref.title,
218
+ props = _objectWithoutPropertiesLoose(_ref, ["cx", "cy", "lengthAngle", "lineWidth", "radius", "shift", "reveal", "rounded", "startAngle", "title"]);
219
+ var pathRadius = radius - lineWidth / 2;
220
+ //@NOTE This shift might be rendered as a translation in future
221
221
  var _shiftVectorAlongAngl = shiftVectorAlongAngle(bisectorAngle(startAngle, lengthAngle), shift),
222
- dx = _shiftVectorAlongAngl.dx,
223
- dy = _shiftVectorAlongAngl.dy;
224
-
222
+ dx = _shiftVectorAlongAngl.dx,
223
+ dy = _shiftVectorAlongAngl.dy;
225
224
  var pathCommands = makePathCommands(cx + dx, cy + dy, startAngle, lengthAngle, pathRadius);
226
225
  var strokeDasharray;
227
- var strokeDashoffset; // Animate/hide paths with "stroke-dasharray" + "stroke-dashoffset"
228
- // https://css-tricks.com/svg-line-animation-works/
226
+ var strokeDashoffset;
229
227
 
228
+ // Animate/hide paths with "stroke-dasharray" + "stroke-dashoffset"
229
+ // https://css-tricks.com/svg-line-animation-works/
230
230
  if (isNumber(reveal)) {
231
231
  var pathLength = degreesToRadians(pathRadius) * lengthAngle;
232
232
  strokeDasharray = Math.abs(pathLength);
233
233
  strokeDashoffset = strokeDasharray - extractPercentage(strokeDasharray, reveal);
234
234
  }
235
-
236
- return /*#__PURE__*/React__default['default'].createElement("path", Object.assign({
235
+ return /*#__PURE__*/React.createElement("path", Object.assign({
237
236
  d: pathCommands,
238
237
  fill: "none",
239
238
  strokeWidth: lineWidth,
240
239
  strokeDasharray: strokeDasharray,
241
240
  strokeDashoffset: strokeDashoffset,
242
241
  strokeLinecap: rounded ? 'round' : undefined
243
- }, props), title && /*#__PURE__*/React__default['default'].createElement("title", null, title));
242
+ }, props), title && /*#__PURE__*/React.createElement("title", null, title));
244
243
  }
245
244
 
246
245
  function combineSegmentTransitionsStyle(duration, easing, customStyle) {
247
246
  // Merge chart's animation CSS transition with "transition" found to customStyle
248
247
  var transition = "stroke-dashoffset " + duration + "ms " + easing;
249
-
250
248
  if (customStyle && customStyle.transition) {
251
249
  transition = transition + "," + customStyle.transition;
252
250
  }
253
-
254
251
  return {
255
252
  transition: transition
256
253
  };
257
254
  }
258
-
259
255
  function getRevealValue(props) {
260
256
  //@NOTE When animation is on, chart has to be fully revealed when reveal is not set
261
257
  if (props.animate && !isNumber(props.reveal)) {
262
258
  return 100;
263
259
  }
264
-
265
260
  return props.reveal;
266
261
  }
267
-
268
262
  function makeEventHandler(eventHandler, payload) {
269
263
  return eventHandler && function (e) {
270
264
  eventHandler(e, payload);
271
265
  };
272
266
  }
273
-
274
267
  function renderSegments(data, props, revealOverride) {
275
268
  // @NOTE this should go in Path component. Here for performance reasons
276
269
  var reveal = revealOverride != null ? revealOverride : getRevealValue(props);
277
270
  var radius = props.radius,
278
- _props$center = props.center,
279
- cx = _props$center[0],
280
- cy = _props$center[1];
271
+ _props$center = props.center,
272
+ cx = _props$center[0],
273
+ cy = _props$center[1];
281
274
  var lineWidth = extractPercentage(radius, props.lineWidth);
282
275
  var paths = data.map(function (dataEntry, index) {
283
276
  var segmentsStyle = functionProp(props.segmentsStyle, index);
284
- return /*#__PURE__*/React__default['default'].createElement(ReactMinimalPieChartPath, {
277
+ return /*#__PURE__*/React.createElement(ReactMinimalPieChartPath, {
285
278
  cx: cx,
286
279
  cy: cy,
287
280
  key: dataEntry.key || index,
@@ -304,9 +297,8 @@
304
297
  onMouseOut: makeEventHandler(props.onMouseOut, index)
305
298
  });
306
299
  });
307
-
308
300
  if (props.background) {
309
- paths.unshift( /*#__PURE__*/React__default['default'].createElement(ReactMinimalPieChartPath, {
301
+ paths.unshift( /*#__PURE__*/React.createElement(ReactMinimalPieChartPath, {
310
302
  cx: cx,
311
303
  cy: cy,
312
304
  key: "bg",
@@ -318,7 +310,6 @@
318
310
  stroke: props.background
319
311
  }));
320
312
  }
321
-
322
313
  return paths;
323
314
  }
324
315
 
@@ -335,46 +326,31 @@
335
326
  startAngle: 0,
336
327
  viewBoxSize: [100, 100]
337
328
  };
338
- function ReactMinimalPieChart(props) {
329
+ function ReactMinimalPieChart(originalProps) {
330
+ var props = makePropsWithDefaults(originalProps,
331
+ // @ts-expect-error: defaultProps.data is typed as BaseDataEntry
332
+ defaultProps);
339
333
  var _useState = React.useState(props.animate ? 0 : null),
340
- revealOverride = _useState[0],
341
- setRevealOverride = _useState[1];
342
-
334
+ revealOverride = _useState[0],
335
+ setRevealOverride = _useState[1];
343
336
  React.useEffect(function () {
344
337
  if (props.animate) {
345
- return startInitialAnimation();
346
- }
347
-
348
- function startInitialAnimation() {
349
- var animationTimerId;
350
- var animationRAFId;
351
- animationTimerId = setTimeout(function () {
352
- animationTimerId = null;
353
- animationRAFId = requestAnimationFrame(function () {
354
- animationRAFId = null;
355
- setRevealOverride(null); // Start animation
356
- });
357
- });
358
- return function () {
359
- animationTimerId && clearTimeout(animationTimerId);
360
- animationRAFId && cancelAnimationFrame(animationRAFId);
361
- };
338
+ // Trigger initial animation
339
+ setRevealOverride(null);
362
340
  }
363
341
  }, []);
364
342
  var extendedData = extendData(props);
365
- return /*#__PURE__*/React__default['default'].createElement("svg", {
343
+ return /*#__PURE__*/React.createElement("svg", {
366
344
  viewBox: "0 0 " + props.viewBoxSize[0] + " " + props.viewBoxSize[1],
367
345
  width: "100%",
368
346
  height: "100%",
369
347
  className: props.className,
370
348
  style: props.style
371
- }, renderSegments(extendedData, props, revealOverride), props.label && renderLabels(extendedData, props), props.children);
349
+ }, renderSegments(extendedData, props, revealOverride), renderLabels(extendedData, props), props.children);
372
350
  }
373
- ReactMinimalPieChart.defaultProps = defaultProps;
374
351
 
375
352
  exports.PieChart = ReactMinimalPieChart;
353
+ exports.pieChartDefaultProps = defaultProps;
376
354
 
377
- Object.defineProperty(exports, '__esModule', { value: true });
378
-
379
- })));
355
+ }));
380
356
  //# sourceMappingURL=index.js.map