@semcore/d3-chart 1.7.1 → 2.0.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.
Files changed (180) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/cjs/Area.js +9 -9
  3. package/lib/cjs/Axis.js +33 -21
  4. package/lib/cjs/Axis.js.map +1 -1
  5. package/lib/cjs/Bar.js +11 -11
  6. package/lib/cjs/Bar.js.map +1 -1
  7. package/lib/cjs/Bubble.js +13 -34
  8. package/lib/cjs/Bubble.js.map +1 -1
  9. package/lib/cjs/ClipPath.js +2 -1
  10. package/lib/cjs/ClipPath.js.map +1 -1
  11. package/lib/cjs/Donut.js +8 -8
  12. package/lib/cjs/Donut.js.map +1 -1
  13. package/lib/cjs/Dots.js +9 -9
  14. package/lib/cjs/Dots.js.map +1 -1
  15. package/lib/cjs/GroupBar.js +8 -8
  16. package/lib/cjs/GroupBar.js.map +1 -1
  17. package/lib/cjs/HorizontalBar.js +11 -11
  18. package/lib/cjs/HorizontalBar.js.map +1 -1
  19. package/lib/cjs/Hover.js +4 -4
  20. package/lib/cjs/Line.js +8 -8
  21. package/lib/cjs/Plot.js +15 -1
  22. package/lib/cjs/Plot.js.map +1 -1
  23. package/lib/cjs/RadialTree.js +694 -0
  24. package/lib/cjs/RadialTree.js.map +1 -0
  25. package/lib/cjs/ResponsiveContainer.js +1 -1
  26. package/lib/cjs/ResponsiveContainer.js.map +1 -1
  27. package/lib/cjs/ScatterPlot.js +7 -7
  28. package/lib/cjs/StackBar.js +8 -8
  29. package/lib/cjs/StackBar.js.map +1 -1
  30. package/lib/cjs/StackedArea.js +8 -8
  31. package/lib/cjs/StackedArea.js.map +1 -1
  32. package/lib/cjs/Tooltip.js +11 -15
  33. package/lib/cjs/Tooltip.js.map +1 -1
  34. package/lib/cjs/Venn.js +9 -9
  35. package/lib/cjs/Venn.js.map +1 -1
  36. package/lib/cjs/color.js +122 -30
  37. package/lib/cjs/color.js.map +1 -1
  38. package/lib/cjs/createElement.js +3 -2
  39. package/lib/cjs/createElement.js.map +1 -1
  40. package/lib/cjs/index.js +8 -0
  41. package/lib/cjs/index.js.map +1 -1
  42. package/lib/cjs/style/area.shadow.css +4 -4
  43. package/lib/cjs/style/axis.shadow.css +6 -8
  44. package/lib/cjs/style/bar.shadow.css +2 -2
  45. package/lib/cjs/style/bubble.shadow.css +3 -3
  46. package/lib/cjs/style/donut.shadow.css +2 -2
  47. package/lib/cjs/style/dot.shadow.css +1 -1
  48. package/lib/cjs/style/hover.shadow.css +2 -2
  49. package/lib/cjs/style/line.shadow.css +2 -2
  50. package/lib/cjs/style/plot.shadow.css +6 -0
  51. package/lib/cjs/style/radial-tree.shadow.css +34 -0
  52. package/lib/cjs/style/scatterplot.shadow.css +2 -2
  53. package/lib/cjs/style/tooltip.shadow.css +5 -5
  54. package/lib/cjs/style/var.css +123 -30
  55. package/lib/cjs/style/venn.shadow.css +1 -1
  56. package/lib/cjs/types/Area.d.ts +47 -0
  57. package/lib/cjs/types/Axis.d.ts +64 -0
  58. package/lib/cjs/types/Bar.d.ts +48 -0
  59. package/lib/cjs/types/Bubble.d.ts +27 -0
  60. package/lib/cjs/types/ClipPath.d.ts +26 -0
  61. package/lib/cjs/types/Donut.d.ts +42 -0
  62. package/lib/cjs/types/GroupBar.d.ts +20 -0
  63. package/lib/cjs/types/HorizontalBar.d.ts +29 -0
  64. package/lib/cjs/types/Hover.d.ts +15 -0
  65. package/lib/cjs/types/Line.d.ts +50 -0
  66. package/lib/cjs/types/Plot.d.ts +16 -0
  67. package/lib/cjs/types/ResponsiveContainer.d.ts +20 -0
  68. package/lib/cjs/types/ScatterPlot.d.ts +27 -0
  69. package/lib/cjs/types/StackBar.d.ts +26 -0
  70. package/lib/cjs/types/StackedArea.d.ts +26 -0
  71. package/lib/cjs/types/Tooltip.d.ts +31 -0
  72. package/lib/cjs/types/Venn.d.ts +45 -0
  73. package/lib/cjs/types/context.d.ts +6 -0
  74. package/lib/cjs/types/index.d.ts +53 -0
  75. package/lib/cjs/utils.js +120 -55
  76. package/lib/cjs/utils.js.map +1 -1
  77. package/lib/es6/Area.js +9 -9
  78. package/lib/es6/Axis.js +33 -21
  79. package/lib/es6/Axis.js.map +1 -1
  80. package/lib/es6/Bar.js +11 -11
  81. package/lib/es6/Bar.js.map +1 -1
  82. package/lib/es6/Bubble.js +13 -34
  83. package/lib/es6/Bubble.js.map +1 -1
  84. package/lib/es6/ClipPath.js +2 -1
  85. package/lib/es6/ClipPath.js.map +1 -1
  86. package/lib/es6/Donut.js +8 -8
  87. package/lib/es6/Donut.js.map +1 -1
  88. package/lib/es6/Dots.js +9 -9
  89. package/lib/es6/Dots.js.map +1 -1
  90. package/lib/es6/GroupBar.js +8 -8
  91. package/lib/es6/GroupBar.js.map +1 -1
  92. package/lib/es6/HorizontalBar.js +11 -11
  93. package/lib/es6/HorizontalBar.js.map +1 -1
  94. package/lib/es6/Hover.js +4 -4
  95. package/lib/es6/Line.js +8 -8
  96. package/lib/es6/Plot.js +17 -1
  97. package/lib/es6/Plot.js.map +1 -1
  98. package/lib/es6/RadialTree.js +682 -0
  99. package/lib/es6/RadialTree.js.map +1 -0
  100. package/lib/es6/ResponsiveContainer.js +1 -1
  101. package/lib/es6/ResponsiveContainer.js.map +1 -1
  102. package/lib/es6/ScatterPlot.js +7 -7
  103. package/lib/es6/StackBar.js +8 -8
  104. package/lib/es6/StackBar.js.map +1 -1
  105. package/lib/es6/StackedArea.js +8 -8
  106. package/lib/es6/StackedArea.js.map +1 -1
  107. package/lib/es6/Tooltip.js +11 -15
  108. package/lib/es6/Tooltip.js.map +1 -1
  109. package/lib/es6/Venn.js +9 -9
  110. package/lib/es6/Venn.js.map +1 -1
  111. package/lib/es6/color.js +122 -30
  112. package/lib/es6/color.js.map +1 -1
  113. package/lib/es6/createElement.js +3 -2
  114. package/lib/es6/createElement.js.map +1 -1
  115. package/lib/es6/index.js +1 -0
  116. package/lib/es6/index.js.map +1 -1
  117. package/lib/es6/style/area.shadow.css +4 -4
  118. package/lib/es6/style/axis.shadow.css +6 -8
  119. package/lib/es6/style/bar.shadow.css +2 -2
  120. package/lib/es6/style/bubble.shadow.css +3 -3
  121. package/lib/es6/style/donut.shadow.css +2 -2
  122. package/lib/es6/style/dot.shadow.css +1 -1
  123. package/lib/es6/style/hover.shadow.css +2 -2
  124. package/lib/es6/style/line.shadow.css +2 -2
  125. package/lib/es6/style/plot.shadow.css +6 -0
  126. package/lib/es6/style/radial-tree.shadow.css +34 -0
  127. package/lib/es6/style/scatterplot.shadow.css +2 -2
  128. package/lib/es6/style/tooltip.shadow.css +5 -5
  129. package/lib/es6/style/var.css +123 -30
  130. package/lib/es6/style/venn.shadow.css +1 -1
  131. package/lib/es6/types/Area.d.ts +47 -0
  132. package/lib/es6/types/Axis.d.ts +64 -0
  133. package/lib/es6/types/Bar.d.ts +48 -0
  134. package/lib/es6/types/Bubble.d.ts +27 -0
  135. package/lib/es6/types/ClipPath.d.ts +26 -0
  136. package/lib/es6/types/Donut.d.ts +42 -0
  137. package/lib/es6/types/GroupBar.d.ts +20 -0
  138. package/lib/es6/types/HorizontalBar.d.ts +29 -0
  139. package/lib/es6/types/Hover.d.ts +15 -0
  140. package/lib/es6/types/Line.d.ts +50 -0
  141. package/lib/es6/types/Plot.d.ts +16 -0
  142. package/lib/es6/types/ResponsiveContainer.d.ts +20 -0
  143. package/lib/es6/types/ScatterPlot.d.ts +27 -0
  144. package/lib/es6/types/StackBar.d.ts +26 -0
  145. package/lib/es6/types/StackedArea.d.ts +26 -0
  146. package/lib/es6/types/Tooltip.d.ts +31 -0
  147. package/lib/es6/types/Venn.d.ts +45 -0
  148. package/lib/es6/types/context.d.ts +6 -0
  149. package/lib/es6/types/index.d.ts +53 -0
  150. package/lib/es6/utils.js +95 -44
  151. package/lib/es6/utils.js.map +1 -1
  152. package/lib/types/RadialTree.d.ts +202 -0
  153. package/lib/types/index.d.ts +6 -0
  154. package/lib/types/utils.d.ts +27 -0
  155. package/package.json +22 -10
  156. package/src/Axis.jsx +11 -1
  157. package/src/Bubble.jsx +1 -21
  158. package/src/ClipPath.jsx +1 -0
  159. package/src/Donut.jsx +7 -9
  160. package/src/Plot.jsx +2 -0
  161. package/src/RadialTree.tsx +767 -0
  162. package/src/createElement.jsx +3 -1
  163. package/src/index.js +1 -0
  164. package/src/style/area.shadow.css +4 -4
  165. package/src/style/axis.shadow.css +6 -8
  166. package/src/style/bar.shadow.css +2 -2
  167. package/src/style/bubble.shadow.css +3 -3
  168. package/src/style/donut.shadow.css +2 -2
  169. package/src/style/dot.shadow.css +1 -1
  170. package/src/style/hover.shadow.css +2 -2
  171. package/src/style/line.shadow.css +2 -2
  172. package/src/style/plot.shadow.css +6 -0
  173. package/src/style/radial-tree.shadow.css +34 -0
  174. package/src/style/scatterplot.shadow.css +2 -2
  175. package/src/style/tooltip.shadow.css +5 -5
  176. package/src/style/var.css +123 -30
  177. package/src/style/venn.shadow.css +1 -1
  178. package/src/types/index.d.ts +6 -0
  179. package/src/utils.ts +227 -0
  180. package/src/utils.js +0 -147
@@ -0,0 +1,694 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
16
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
+
18
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
19
+
20
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
21
+
22
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
+
24
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
+
26
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
+
28
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
+
30
+ var _core = require("@semcore/core");
31
+
32
+ var _react = _interopRequireDefault(require("react"));
33
+
34
+ var _createElement = _interopRequireDefault(require("./createElement"));
35
+
36
+ var _uniqueID = _interopRequireDefault(require("@semcore/utils/lib/uniqueID"));
37
+
38
+ var _d3Transition = require("d3-transition");
39
+
40
+ var _color = require("@semcore/utils/lib/color");
41
+
42
+ var _utils = require("./utils");
43
+
44
+ var _assignProps = _interopRequireDefault(require("@semcore/utils/lib/assignProps"));
45
+
46
+ var _getOriginChildren = _interopRequireDefault(require("@semcore/utils/lib/getOriginChildren"));
47
+
48
+ var _excluded = ["data"];
49
+
50
+ 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; }
51
+
52
+ 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; }
53
+
54
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
55
+
56
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
57
+
58
+ /*__reshadow-styles__:"./style/radial-tree.shadow.css"*/
59
+ var style = (
60
+ /*__reshadow_css_start__*/
61
+ _core.sstyled.insert(
62
+ /*__inner_css_start__*/
63
+ ".___SRadian_1lwpb_gg_{cursor:pointer;fill:#008ff8}.___SLine_1lwpb_gg_{stroke:#008ff8}.___SLine_1lwpb_gg_.__color_1lwpb_gg_{stroke:var(--color_1uem4n7)}.___SCap_1lwpb_gg_{transition:r .1s}.___SLabel_1lwpb_gg_{fill:var(--color_1uem4n7);cursor:var(--text-cursor_1uem4n7);transform-origin:var(--transform-origin_1uem4n7)}.___SRadian_1lwpb_gg_:hover .___SLabel_1lwpb_gg_{fill:var(--color-hovered_1uem4n7)}@media (prefers-reduced-motion){.___SLineCap_1lwpb_gg_{transition:none}}"
64
+ /*__inner_css_end__*/
65
+ , "1uem4n7_gg_")
66
+ /*__reshadow_css_end__*/
67
+ , {
68
+ "__SRadian": "___SRadian_1lwpb_gg_",
69
+ "__SLine": "___SLine_1lwpb_gg_",
70
+ "_color": "__color_1lwpb_gg_",
71
+ "--color": "--color_1uem4n7",
72
+ "__SCap": "___SCap_1lwpb_gg_",
73
+ "__SLabel": "___SLabel_1lwpb_gg_",
74
+ "--text-cursor": "--text-cursor_1uem4n7",
75
+ "--transform-origin": "--transform-origin_1uem4n7",
76
+ "--color-hovered": "--color-hovered_1uem4n7",
77
+ "__SLineCap": "___SLineCap_1lwpb_gg_"
78
+ });
79
+ var baseAngle = -Math.PI / 2; // The top vertical line
80
+
81
+ var RadialTreeBase = /*#__PURE__*/function (_Component) {
82
+ (0, _inherits2["default"])(RadialTreeBase, _Component);
83
+
84
+ var _super = _createSuper(RadialTreeBase);
85
+
86
+ function RadialTreeBase(props) {
87
+ var _this;
88
+
89
+ (0, _classCallCheck2["default"])(this, RadialTreeBase);
90
+ _this = _super.call(this, props);
91
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "Element", void 0);
92
+ _this.handleRadianClick = _this.handleRadianClick.bind((0, _assertThisInitialized2["default"])(_this));
93
+ return _this;
94
+ }
95
+
96
+ (0, _createClass2["default"])(RadialTreeBase, [{
97
+ key: "uncontrolledProps",
98
+ value: function uncontrolledProps() {
99
+ return {
100
+ activeKey: null
101
+ };
102
+ }
103
+ }, {
104
+ key: "runAppearAnimation",
105
+ value: function runAppearAnimation() {
106
+ var _this$asProps = this.asProps,
107
+ duration = _this$asProps.duration,
108
+ uid = _this$asProps.uid;
109
+ var preferReduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)')?.matches;
110
+ /** using `!(>)` instead of `<=` to get true on NaN and non numbers stuff */
111
+
112
+ if (!(duration > 0)) return;
113
+ if (preferReduceMotion) return;
114
+ var circlesAnimation = (0, _d3Transition.transition)().selection().selectAll("[data-radial-animation=".concat(uid, "-cap-circle]"));
115
+ var iconsAnimation = (0, _d3Transition.transition)().selection().selectAll("[data-radial-animation=".concat(uid, "-cap-icon]"));
116
+ var linesAnimation = (0, _d3Transition.transition)().selection().selectAll("[data-radial-animation=".concat(uid, "-line]"));
117
+ var labelsAnimation = (0, _d3Transition.transition)().selection().selectAll("[data-radial-animation=".concat(uid, "-label]"));
118
+ var circlesNodes = circlesAnimation.nodes();
119
+ var iconsNodes = iconsAnimation.nodes();
120
+ var linesNodes = linesAnimation.nodes();
121
+ var labelsNodes = linesAnimation.nodes();
122
+
123
+ if (circlesNodes.length > 0) {
124
+ var attrs = circlesNodes.map(function (node) {
125
+ var cx = node.cx?.baseVal?.value;
126
+ var cy = node.cy?.baseVal?.value;
127
+ var radianIndex = parseInt(node.dataset.radianIndex, 10);
128
+ var lineNode = linesNodes[radianIndex];
129
+ return {
130
+ from: {
131
+ cx: lineNode.x1?.baseVal?.value,
132
+ cy: lineNode.y1?.baseVal?.value
133
+ },
134
+ to: {
135
+ cx: cx,
136
+ cy: cy
137
+ }
138
+ };
139
+ });
140
+ circlesAnimation.attr('opacity', 0).attr('cx', function (_, index) {
141
+ return attrs[index].from?.cx;
142
+ }).attr('cy', function (_, index) {
143
+ return attrs[index].from?.cy;
144
+ });
145
+ circlesAnimation.transition().duration(duration).attr('opacity', 1).attr('cx', function (_, index) {
146
+ return attrs[index].to?.cx;
147
+ }).attr('cy', function (_, index) {
148
+ return attrs[index].to?.cy;
149
+ });
150
+ }
151
+
152
+ if (iconsNodes.length > 0) {
153
+ var _attrs = iconsNodes.map(function (node) {
154
+ var x = node.x?.baseVal?.value;
155
+ var y = node.y?.baseVal?.value;
156
+ var width = node.width?.baseVal?.value;
157
+ var height = node.height?.baseVal?.value;
158
+ var radianIndex = parseInt(node.dataset.radianIndex, 10);
159
+ var lineNode = linesNodes[radianIndex];
160
+ return {
161
+ from: {
162
+ x: lineNode.x1?.baseVal?.value - width / 2,
163
+ y: lineNode.y1?.baseVal?.value - height / 2
164
+ },
165
+ to: {
166
+ x: x,
167
+ y: y
168
+ }
169
+ };
170
+ });
171
+
172
+ iconsAnimation.attr('opacity', 0).attr('x', function (_, index) {
173
+ return _attrs[index].from?.x;
174
+ }).attr('y', function (_, index) {
175
+ return _attrs[index].from?.y;
176
+ });
177
+ iconsAnimation.transition().duration(duration).attr('opacity', 1).attr('x', function (_, index) {
178
+ return _attrs[index].to?.x;
179
+ }).attr('y', function (_, index) {
180
+ return _attrs[index].to?.y;
181
+ });
182
+ }
183
+
184
+ if (linesNodes.length > 0) {
185
+ var _attrs2 = linesNodes.map(function (node) {
186
+ var x2 = node.x2?.baseVal?.value;
187
+ var y2 = node.y2?.baseVal?.value;
188
+ return {
189
+ from: {
190
+ x2: node.x1?.baseVal?.value,
191
+ y2: node.y1?.baseVal?.value
192
+ },
193
+ to: {
194
+ x2: x2,
195
+ y2: y2
196
+ }
197
+ };
198
+ });
199
+
200
+ linesAnimation.attr('opacity', 0).attr('x2', function (_, index) {
201
+ return _attrs2[index].from?.x2;
202
+ }).attr('y2', function (_, index) {
203
+ return _attrs2[index].from?.y2;
204
+ });
205
+ linesAnimation.transition().duration(duration).attr('opacity', 1).attr('x2', function (_, index) {
206
+ return _attrs2[index].to?.x2;
207
+ }).attr('y2', function (_, index) {
208
+ return _attrs2[index].to?.y2;
209
+ });
210
+ }
211
+
212
+ if (labelsNodes.length > 0) {
213
+ labelsAnimation.attr('opacity', 0);
214
+ labelsAnimation.transition().duration(duration).attr('opacity', 1);
215
+ }
216
+ }
217
+ }, {
218
+ key: "componentDidUpdate",
219
+ value: function componentDidUpdate(prevProps) {
220
+ if (prevProps.$rootProps.data?.length !== this.asProps.data?.length) {
221
+ this.runAppearAnimation();
222
+ }
223
+ }
224
+ }, {
225
+ key: "componentDidMount",
226
+ value: function componentDidMount() {
227
+ this.runAppearAnimation();
228
+ }
229
+ }, {
230
+ key: "handleRadianClick",
231
+ value: function handleRadianClick(key) {
232
+ var _this2 = this;
233
+
234
+ return function (event) {
235
+ var newKey = key !== _this2.asProps.activeKey ? key : null;
236
+
237
+ _this2.handlers.activeKey(newKey, event);
238
+ };
239
+ }
240
+ }, {
241
+ key: "computeTextWidth",
242
+ value: function computeTextWidth() {
243
+ var _this$asProps2 = this.asProps,
244
+ data = _this$asProps2.data,
245
+ textSize = _this$asProps2.textSize;
246
+ var widths = data.map(function (_ref9) {
247
+ var label = _ref9.label;
248
+ return (0, _utils.measureText)(label, textSize);
249
+ });
250
+ return Math.max.apply(Math, (0, _toConsumableArray2["default"])(widths));
251
+ }
252
+ }, {
253
+ key: "getTitleProps",
254
+ value: function getTitleProps() {
255
+ var _this$asProps3 = this.asProps,
256
+ uid = _this$asProps3.uid,
257
+ size = _this$asProps3.size,
258
+ textSize = _this$asProps3.textSize;
259
+
260
+ var _size = (0, _slicedToArray2["default"])(size, 2),
261
+ width = _size[0],
262
+ height = _size[1];
263
+
264
+ var center = [width / 2, height / 2];
265
+ var x = center[0],
266
+ y = center[1];
267
+ return (0, _defineProperty2["default"])({
268
+ x: x,
269
+ y: y,
270
+ textSize: textSize * 1.5
271
+ }, 'data-radial-animation', "".concat(uid, "-label"));
272
+ }
273
+ }, {
274
+ key: "getRadianProps",
275
+ value: function getRadianProps() {
276
+ var _this$asProps4 = this.asProps,
277
+ data = _this$asProps4.data,
278
+ restRootProps = (0, _objectWithoutProperties2["default"])(_this$asProps4, _excluded);
279
+ var textWidth = this.computeTextWidth();
280
+ return _objectSpread(_objectSpread({}, restRootProps), {}, {
281
+ radiansCount: data.length,
282
+ data: data,
283
+ textWidth: textWidth,
284
+ onRadianClick: this.handleRadianClick
285
+ });
286
+ }
287
+ }, {
288
+ key: "render",
289
+ value: function render() {
290
+ var _ref;
291
+
292
+ var SRadialTree = this.Element;
293
+ var Children = this.asProps.Children;
294
+ return _ref = (0, _core.sstyled)(this.asProps.styles), /*#__PURE__*/_react["default"].createElement(SRadialTree, _ref.cn("SRadialTree", {
295
+ "render": "g"
296
+ }), /*#__PURE__*/_react["default"].createElement(Children, _ref.cn("Children", {})));
297
+ }
298
+ }]);
299
+ return RadialTreeBase;
300
+ }(_core.Component);
301
+
302
+ (0, _defineProperty2["default"])(RadialTreeBase, "displayName", 'RadialTree');
303
+ (0, _defineProperty2["default"])(RadialTreeBase, "style", style);
304
+ (0, _defineProperty2["default"])(RadialTreeBase, "enhance", [(0, _uniqueID["default"])()]);
305
+ (0, _defineProperty2["default"])(RadialTreeBase, "defaultProps", {
306
+ angleOffset: 0,
307
+ duration: 300,
308
+ centralMargin: 50,
309
+ labelMargin: 2,
310
+ iconColor: '#fff',
311
+ capSize: 8,
312
+ iconSize: 8,
313
+ textSize: 14,
314
+ defaultActiveKey: null
315
+ });
316
+
317
+ var RadialTreeRadian = /*#__PURE__*/function (_Component2) {
318
+ (0, _inherits2["default"])(RadialTreeRadian, _Component2);
319
+
320
+ var _super2 = _createSuper(RadialTreeRadian);
321
+
322
+ function RadialTreeRadian(props) {
323
+ var _this3;
324
+
325
+ (0, _classCallCheck2["default"])(this, RadialTreeRadian);
326
+ _this3 = _super2.call(this, props);
327
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "Element", void 0);
328
+ _this3.renderRadian = _this3.renderRadian.bind((0, _assertThisInitialized2["default"])(_this3));
329
+ return _this3;
330
+ }
331
+
332
+ (0, _createClass2["default"])(RadialTreeRadian, [{
333
+ key: "getInteractiveAreaProps",
334
+ value: function getInteractiveAreaProps(_ref11, index) {
335
+ var $rootProps = _ref11.$rootProps;
336
+ var data = $rootProps.data[index];
337
+
338
+ var _this$computeRadianPo = this.computeRadianPosition(data, index),
339
+ xStart = _this$computeRadianPo.xStart,
340
+ yStart = _this$computeRadianPo.yStart,
341
+ xLabelCenter = _this$computeRadianPo.xLabelCenter,
342
+ yLabelCenter = _this$computeRadianPo.yLabelCenter,
343
+ capSize = _this$computeRadianPo.capSize;
344
+
345
+ return {
346
+ x1: xStart,
347
+ y1: yStart,
348
+ x2: xLabelCenter,
349
+ y2: yLabelCenter,
350
+ strokeWidth: capSize * 3
351
+ };
352
+ }
353
+ }, {
354
+ key: "getLineProps",
355
+ value: function getLineProps(_ref12, index) {
356
+ var _ref13;
357
+
358
+ var $rootProps = _ref12.$rootProps;
359
+ var data = $rootProps.data[index];
360
+
361
+ var _this$computeRadianPo2 = this.computeRadianPosition(data, index),
362
+ xStart = _this$computeRadianPo2.xStart,
363
+ yStart = _this$computeRadianPo2.yStart,
364
+ xEnd = _this$computeRadianPo2.xEnd,
365
+ yEnd = _this$computeRadianPo2.yEnd;
366
+
367
+ var uid = this.asProps.uid;
368
+ var color = data.color ?? this.asProps.color;
369
+ return _ref13 = {
370
+ x1: xStart,
371
+ y1: yStart,
372
+ x2: xEnd,
373
+ y2: yEnd,
374
+ stroke: color
375
+ }, (0, _defineProperty2["default"])(_ref13, 'data-radial-animation', "".concat(uid, "-line")), (0, _defineProperty2["default"])(_ref13, 'data-radian-index', index), _ref13;
376
+ }
377
+ }, {
378
+ key: "getCapProps",
379
+ value: function getCapProps(_ref14, index) {
380
+ var _ref15;
381
+
382
+ var $rootProps = _ref14.$rootProps;
383
+ var data = $rootProps.data[index];
384
+
385
+ var _this$computeRadianPo3 = this.computeRadianPosition(data, index),
386
+ xEnd = _this$computeRadianPo3.xEnd,
387
+ yEnd = _this$computeRadianPo3.yEnd,
388
+ capSize = _this$computeRadianPo3.capSize;
389
+
390
+ var uid = this.asProps.uid;
391
+ var color = data.color ?? this.asProps.color;
392
+ return _ref15 = {
393
+ x: xEnd,
394
+ y: yEnd,
395
+ radius: capSize,
396
+ color: color
397
+ }, (0, _defineProperty2["default"])(_ref15, 'data-radial-animation', "".concat(uid, "-cap-circle")), (0, _defineProperty2["default"])(_ref15, 'data-radian-index', index), _ref15;
398
+ }
399
+ }, {
400
+ key: "getIconProps",
401
+ value: function getIconProps(_ref16, index) {
402
+ var _ref17;
403
+
404
+ var $rootProps = _ref16.$rootProps;
405
+ var data = $rootProps.data[index];
406
+
407
+ var _this$computeRadianPo4 = this.computeRadianPosition(data, index),
408
+ xEnd = _this$computeRadianPo4.xEnd,
409
+ yEnd = _this$computeRadianPo4.yEnd,
410
+ isActive = _this$computeRadianPo4.isActive;
411
+
412
+ var uid = this.asProps.uid;
413
+ var iconColor = data.iconColor ?? this.asProps.iconColor;
414
+ var iconSize = data.iconSize ?? this.asProps.iconSize;
415
+ var icon = data.icon ?? this.asProps.icon;
416
+ return _ref17 = {
417
+ x: xEnd - iconSize / 2,
418
+ y: yEnd - iconSize / 2,
419
+ iconSize: iconSize,
420
+ color: iconColor ?? '#fff'
421
+ }, (0, _defineProperty2["default"])(_ref17, 'data-radial-animation', "".concat(uid, "-cap-icon")), (0, _defineProperty2["default"])(_ref17, 'data-radian-index', index), (0, _defineProperty2["default"])(_ref17, "icon", icon), (0, _defineProperty2["default"])(_ref17, "isActive", isActive), _ref17;
422
+ }
423
+ }, {
424
+ key: "getLabelProps",
425
+ value: function getLabelProps(_ref18, index) {
426
+ var _ref19;
427
+
428
+ var $rootProps = _ref18.$rootProps;
429
+ var data = $rootProps.data[index];
430
+
431
+ var _this$computeRadianPo5 = this.computeRadianPosition(data, index),
432
+ xLabelCenter = _this$computeRadianPo5.xLabelCenter,
433
+ yLabelCenter = _this$computeRadianPo5.yLabelCenter,
434
+ labelAngle = _this$computeRadianPo5.labelAngle,
435
+ isHorizontal = _this$computeRadianPo5.isHorizontal;
436
+
437
+ var _this$asProps5 = this.asProps,
438
+ uid = _this$asProps5.uid,
439
+ textSize = _this$asProps5.textSize;
440
+ var label = data.label;
441
+ var color = data.color ?? this.asProps.color;
442
+ return _ref19 = {
443
+ x: xLabelCenter,
444
+ y: yLabelCenter,
445
+ angle: labelAngle
446
+ }, (0, _defineProperty2["default"])(_ref19, 'data-radial-animation', "".concat(uid, "-label")), (0, _defineProperty2["default"])(_ref19, 'data-radian-index', index), (0, _defineProperty2["default"])(_ref19, "label", label), (0, _defineProperty2["default"])(_ref19, "color", color), (0, _defineProperty2["default"])(_ref19, "isHorizontal", isHorizontal), (0, _defineProperty2["default"])(_ref19, "textSize", textSize), _ref19;
447
+ }
448
+ }, {
449
+ key: "getRadianKey",
450
+ value: function getRadianKey(data, index) {
451
+ return data.key ?? "radian-".concat(index);
452
+ }
453
+ }, {
454
+ key: "computeRadianPosition",
455
+ value: function computeRadianPosition(data, index) {
456
+ var _this$asProps6 = this.asProps,
457
+ centralMargin = _this$asProps6.centralMargin,
458
+ angleOffset = _this$asProps6.angleOffset,
459
+ activeKey = _this$asProps6.activeKey,
460
+ size = _this$asProps6.size,
461
+ radiansCount = _this$asProps6.radiansCount,
462
+ textWidth = _this$asProps6.textWidth;
463
+
464
+ var _size2 = (0, _slicedToArray2["default"])(size, 2),
465
+ width = _size2[0],
466
+ height = _size2[1];
467
+
468
+ var key = this.getRadianKey(data, index);
469
+ var isActive = activeKey === key;
470
+ var baseCapSize = data.capSize ?? this.asProps.capSize;
471
+ var capSize = baseCapSize * (isActive ? 1 : 0.5);
472
+ var minDemSize = Math.min(width, height) / 2;
473
+ var length = Math.max(minDemSize - textWidth - baseCapSize - centralMargin, 10);
474
+ var angle = baseAngle + angleOffset + index / radiansCount * (Math.PI * 2);
475
+ var isHorizontal = angle - baseAngle > 1 / 6 * Math.PI && angle - baseAngle < 5 / 6 * Math.PI || angle - baseAngle > 7 / 6 * Math.PI && angle - baseAngle < 11 / 6 * Math.PI;
476
+ var topAngle = -Math.PI / 2;
477
+ var labelAngle = (angle - topAngle) % Math.PI + topAngle;
478
+ var center = [width / 2, height / 2];
479
+ var xCenter = center[0],
480
+ yCenter = center[1];
481
+ var start = [xCenter + Math.cos(angle) * centralMargin, yCenter + Math.sin(angle) * centralMargin];
482
+ var end = [xCenter + Math.cos(angle) * (centralMargin + length), yCenter + Math.sin(angle) * (centralMargin + length)];
483
+ var xStart = start[0],
484
+ yStart = start[1];
485
+ var xEnd = end[0],
486
+ yEnd = end[1];
487
+ var labelCenter = [xCenter + Math.cos(angle) * (centralMargin + length + baseCapSize + textWidth / 2), yCenter + Math.sin(angle) * (centralMargin + length + baseCapSize + textWidth / 2)];
488
+ var xLabelCenter = labelCenter[0],
489
+ yLabelCenter = labelCenter[1];
490
+ return {
491
+ xStart: xStart,
492
+ yStart: yStart,
493
+ xEnd: xEnd,
494
+ yEnd: yEnd,
495
+ xLabelCenter: xLabelCenter,
496
+ yLabelCenter: yLabelCenter,
497
+ labelAngle: labelAngle,
498
+ isHorizontal: isHorizontal,
499
+ capSize: capSize,
500
+ isActive: isActive
501
+ };
502
+ }
503
+ }, {
504
+ key: "renderRadian",
505
+ value: function renderRadian(data, index) {
506
+ var _ref2;
507
+
508
+ var _this$asProps7 = this.asProps,
509
+ styles = _this$asProps7.styles,
510
+ Children = _this$asProps7.Children,
511
+ onRadianClick = _this$asProps7.onRadianClick;
512
+ var key = this.getRadianKey(data, index);
513
+ var SRadian = 'g';
514
+ var children = (0, _getOriginChildren["default"])(Children);
515
+
516
+ if (typeof children === 'function') {
517
+ var _child = this.asProps.children;
518
+ var mergedProps = (0, _assignProps["default"])(children(this.asProps), this.asProps);
519
+ children = mergedProps.children;
520
+ mergedProps.children = _child;
521
+ } // hidden from publicly typed export
522
+
523
+
524
+ var InteractiveArea = RadialTree.Radian.InteractiveArea;
525
+ return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SRadian, _ref2.cn("SRadian", {
526
+ "key": key,
527
+ "onClick": onRadianClick(key)
528
+ }), /*#__PURE__*/_react["default"].createElement(InteractiveArea, _ref2.cn("InteractiveArea", {})), children);
529
+ }
530
+ }, {
531
+ key: "render",
532
+ value: function render() {
533
+ var _ref3,
534
+ _this4 = this;
535
+
536
+ var data = this.asProps.data;
537
+ var SRadianList = 'g';
538
+ return _ref3 = (0, _core.sstyled)(this.asProps.styles), /*#__PURE__*/_react["default"].createElement(SRadianList, _ref3.cn("SRadianList", {}), data.map(function (data, index) {
539
+ return _this4.renderRadian(data, index);
540
+ }));
541
+ }
542
+ }]);
543
+ return RadialTreeRadian;
544
+ }(_core.Component);
545
+
546
+ (0, _defineProperty2["default"])(RadialTreeRadian, "displayName", 'RadialTreeRadian');
547
+ (0, _defineProperty2["default"])(RadialTreeRadian, "style", style);
548
+ (0, _defineProperty2["default"])(RadialTreeRadian, "defaultProps", {
549
+ centralMargin: 50,
550
+ labelMargin: 2,
551
+ iconColor: '#fff',
552
+ capSize: 16,
553
+ iconSize: 16,
554
+ textSize: 14
555
+ });
556
+
557
+ var InteractiveArea = function InteractiveArea(_ref20) {
558
+ var _ref4;
559
+
560
+ var SInteractiveArea = _ref20.Element,
561
+ styles = _ref20.styles;
562
+ return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SInteractiveArea, _ref4.cn("SInteractiveArea", {
563
+ "stroke": "transparent",
564
+ "render": "line"
565
+ }));
566
+ };
567
+
568
+ var Line = function Line(_ref21) {
569
+ var _ref5;
570
+
571
+ var SLine = _ref21.Element,
572
+ styles = _ref21.styles,
573
+ stroke = _ref21.stroke;
574
+ return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SLine, _ref5.cn("SLine", {
575
+ "render": "line",
576
+ "stroke": stroke
577
+ }));
578
+ };
579
+
580
+ var Cap = function Cap(_ref22) {
581
+ var _ref6;
582
+
583
+ var SCap = _ref22.Element,
584
+ styles = _ref22.styles,
585
+ x = _ref22.x,
586
+ y = _ref22.y,
587
+ radius = _ref22.radius,
588
+ color = _ref22.color;
589
+ return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SCap, _ref6.cn("SCap", {
590
+ "render": "circle",
591
+ "cx": x,
592
+ "cy": y,
593
+ "r": radius,
594
+ "fill": color
595
+ }));
596
+ };
597
+
598
+ var Icon = function Icon(_ref23) {
599
+ var _ref7;
600
+
601
+ var SIcon = _ref23.Element,
602
+ styles = _ref23.styles,
603
+ isActive = _ref23.isActive,
604
+ tag = _ref23.tag,
605
+ x = _ref23.x,
606
+ y = _ref23.y,
607
+ iconSize = _ref23.iconSize;
608
+ if (!(isActive && tag)) return null;
609
+ var width = iconSize;
610
+ var height = iconSize;
611
+ return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SIcon, _ref7.cn("SIcon", {
612
+ "x": x,
613
+ "y": y,
614
+ "width": width,
615
+ "height": height,
616
+ "render": tag
617
+ }));
618
+ };
619
+
620
+ var Label = function Label(_ref24) {
621
+ var SLabel = _ref24.Element,
622
+ Children = _ref24.Children,
623
+ styles = _ref24.styles,
624
+ label = _ref24.label,
625
+ color = _ref24.color,
626
+ isHorizontal = _ref24.isHorizontal,
627
+ x = _ref24.x,
628
+ y = _ref24.y,
629
+ textSize = _ref24.textSize,
630
+ angle = _ref24.angle;
631
+ var lines = String(label).split('\n');
632
+ var linesCount = lines.length;
633
+ var SLabelLine = 'tspan';
634
+ var sstyles = (0, _core.sstyled)(styles);
635
+ var sLabelStyles = sstyles.cn('SLabel', {
636
+ color: color,
637
+ 'color-hovered': (0, _color.shade)(color, -0.12),
638
+ 'text-cursor': isHorizontal ? 'text' : 'vertical-text',
639
+ 'transform-origin': "".concat(x.toFixed(2), "px ").concat(y.toFixed(2), "px")
640
+ });
641
+ return /*#__PURE__*/_react["default"].createElement(SLabel, {
642
+ render: "text",
643
+ textAnchor: "middle",
644
+ dominantBaseline: "central",
645
+ className: sLabelStyles.className,
646
+ style: sLabelStyles.style,
647
+ x: x.toFixed(2),
648
+ y: y.toFixed(2),
649
+ transform: "rotate(".concat((angle / Math.PI * 180).toFixed(2), ")")
650
+ }, lines.map(function (lineText, lineIndex) {
651
+ return /*#__PURE__*/_react["default"].createElement(SLabelLine, {
652
+ x: x,
653
+ y: y + (lineIndex - (linesCount - 1) / 2) * textSize,
654
+ key: "#".concat(lineIndex, "-").concat(lineText)
655
+ }, lineText);
656
+ }), /*#__PURE__*/_react["default"].createElement(Children, null));
657
+ };
658
+
659
+ var Radian = (0, _createElement["default"])(RadialTreeRadian, {
660
+ InteractiveArea: InteractiveArea,
661
+ Line: Line,
662
+ Cap: Cap,
663
+ Icon: Icon,
664
+ Label: Label
665
+ });
666
+
667
+ var Title = function Title(_ref25) {
668
+ var _ref8;
669
+
670
+ var STitle = _ref25.Element,
671
+ Children = _ref25.Children,
672
+ styles = _ref25.styles,
673
+ textSize = _ref25.textSize,
674
+ color = _ref25.color,
675
+ x = _ref25.x,
676
+ y = _ref25.y;
677
+ return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STitle, _ref8.cn("STitle", {
678
+ "render": "text",
679
+ "textAnchor": "middle",
680
+ "dominantBaseline": "central",
681
+ "fontSize": textSize,
682
+ "fill": color,
683
+ "x": x,
684
+ "y": y
685
+ }), /*#__PURE__*/_react["default"].createElement(Children, _ref8.cn("Children", {})));
686
+ };
687
+
688
+ var RadialTree = (0, _createElement["default"])(RadialTreeBase, {
689
+ Title: Title,
690
+ Radian: Radian
691
+ });
692
+ var _default = RadialTree;
693
+ exports["default"] = _default;
694
+ //# sourceMappingURL=RadialTree.js.map