@semcore/d3-chart 2.8.19 → 2.9.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/CHANGELOG.md +6 -0
- package/lib/cjs/Area.js +10 -10
- package/lib/cjs/Axis.js +14 -14
- package/lib/cjs/Bar.js +9 -9
- package/lib/cjs/Bubble.js +11 -11
- package/lib/cjs/Donut.js +8 -8
- package/lib/cjs/Dots.js +10 -10
- package/lib/cjs/HorizontalBar.js +9 -9
- package/lib/cjs/Hover.js +4 -4
- package/lib/cjs/Line.js +9 -9
- package/lib/cjs/Plot.js +5 -5
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/Radar.js +885 -0
- package/lib/cjs/Radar.js.map +1 -0
- package/lib/cjs/RadialTree.js +13 -13
- package/lib/cjs/ReferenceLine.js +10 -10
- package/lib/cjs/ScatterPlot.js +8 -8
- package/lib/cjs/Tooltip.js +8 -8
- package/lib/cjs/Venn.js +8 -8
- package/lib/cjs/a11y/PlotA11yModule.js +3 -3
- package/lib/cjs/a11y/PlotA11yView.js +4 -4
- package/lib/cjs/index.js +16 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/radar.shadow.css +73 -0
- package/lib/cjs/types/Radar.js +2 -0
- package/lib/cjs/types/Radar.js.map +1 -0
- package/lib/cjs/types/index.d.js +21 -0
- package/lib/cjs/types/index.d.js.map +1 -1
- package/lib/cjs/utils.js +2 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/Area.js +10 -10
- package/lib/es6/Axis.js +14 -14
- package/lib/es6/Bar.js +9 -9
- package/lib/es6/Bubble.js +11 -11
- package/lib/es6/Donut.js +8 -8
- package/lib/es6/Dots.js +10 -10
- package/lib/es6/HorizontalBar.js +9 -9
- package/lib/es6/Hover.js +4 -4
- package/lib/es6/Line.js +9 -9
- package/lib/es6/Plot.js +5 -5
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/Radar.js +880 -0
- package/lib/es6/Radar.js.map +1 -0
- package/lib/es6/RadialTree.js +13 -13
- package/lib/es6/ReferenceLine.js +10 -10
- package/lib/es6/ScatterPlot.js +8 -8
- package/lib/es6/Tooltip.js +8 -8
- package/lib/es6/Venn.js +8 -8
- package/lib/es6/a11y/PlotA11yModule.js +3 -3
- package/lib/es6/a11y/PlotA11yView.js +4 -4
- package/lib/es6/index.js +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/radar.shadow.css +73 -0
- package/lib/es6/types/Radar.js +2 -0
- package/lib/es6/types/Radar.js.map +1 -0
- package/lib/es6/types/index.d.js +2 -0
- package/lib/es6/types/index.d.js.map +1 -1
- package/lib/es6/utils.js +2 -1
- package/lib/es6/utils.js.map +1 -1
- package/lib/types/index.d.ts +3 -0
- package/lib/types/types/Radar.d.ts +89 -0
- package/package.json +3 -2
package/lib/es6/Radar.js
ADDED
|
@@ -0,0 +1,880 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
8
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
9
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
10
|
+
import React, { cloneElement } from 'react';
|
|
11
|
+
import { Component, sstyled } from '@semcore/core';
|
|
12
|
+
import uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';
|
|
13
|
+
import getOriginChildren from '@semcore/utils/lib/getOriginChildren';
|
|
14
|
+
import trottle from '@semcore/utils/lib/rafTrottle';
|
|
15
|
+
import canUseDOM from '@semcore/utils/lib/canUseDOM';
|
|
16
|
+
import { polygonContains } from 'd3-polygon';
|
|
17
|
+
import { line, lineRadial, curveLinearClosed, arc } from 'd3-shape';
|
|
18
|
+
import createElement from './createElement';
|
|
19
|
+
import { CONSTANT, eventToPoint, measureText } from './utils';
|
|
20
|
+
|
|
21
|
+
/*__reshadow-styles__:"./style/radar.shadow.css"*/
|
|
22
|
+
var style = (
|
|
23
|
+
/*__reshadow_css_start__*/
|
|
24
|
+
_sstyled.insert(
|
|
25
|
+
/*__inner_css_start__*/
|
|
26
|
+
".___SAxisLine_5kuve_gg_,.___SAxisTick_5kuve_gg_,.___SAxis_5kuve_gg_{stroke:var(--intergalactic-chart-grid-line, #e0e1e9);stroke-width:1;fill:transparent}.___SAxisLine_5kuve_gg_,.___SAxisTick_5kuve_gg_{stroke-dasharray:2}.___SAxisLine_5kuve_gg_.__active_5kuve_gg_{stroke:var(--intergalactic-chart-grid-y-accent-hover-line, #a9abb6)}.___SAxisLabel_5kuve_gg_{text-anchor:middle;dominant-baseline:central;font-size:12px}.___SAxisLabel_5kuve_gg_.__xDirection_5kuve_gg_{text-anchor:var(--xDirection_5kuve)}.___SAxisLabel_5kuve_gg_.__yDirection_5kuve_gg_{dominant-baseline:var(--yDirection_5kuve)}.___SPolygonDot_5kuve_gg_,.___SPolygon_5kuve_gg_{fill:var(--intergalactic-chart-palette-order-1, #2bb3ff)}.___SPolygon_5kuve_gg_{opacity:.2}.___SPolygon_5kuve_gg_.__color_5kuve_gg_{fill:var(--color_5kuve)}.___SPolygonDot_5kuve_gg_{stroke-width:2px;stroke:var(--intergalactic-chart-grid-border, #ffffff);r:6px}.___SPolygonDot_5kuve_gg_.__transparent_5kuve_gg_{opacity:.3}.___SPolygonDot_5kuve_gg_.__color_5kuve_gg_{fill:var(--color_5kuve)}.___SPolygonLine_5kuve_gg_{stroke:var(--intergalactic-chart-palette-order-1, #2bb3ff);stroke-width:3;fill:transparent}.___SPolygonLine_5kuve_gg_.__transparent_5kuve_gg_{opacity:.3}.___SPolygonLine_5kuve_gg_.__color_5kuve_gg_{stroke:var(--color_5kuve)}.___SPieRect_5kuve_gg_{fill:var(--intergalactic-chart-grid-bar-chart-hover, rgba(196, 199, 207, 0.3))}"
|
|
27
|
+
/*__inner_css_end__*/
|
|
28
|
+
, "5kuve_gg_")
|
|
29
|
+
/*__reshadow_css_end__*/
|
|
30
|
+
, {
|
|
31
|
+
"__SAxis": "___SAxis_5kuve_gg_",
|
|
32
|
+
"__SAxisLine": "___SAxisLine_5kuve_gg_",
|
|
33
|
+
"__SAxisTick": "___SAxisTick_5kuve_gg_",
|
|
34
|
+
"_active": "__active_5kuve_gg_",
|
|
35
|
+
"__SAxisLabel": "___SAxisLabel_5kuve_gg_",
|
|
36
|
+
"_xDirection": "__xDirection_5kuve_gg_",
|
|
37
|
+
"--xDirection": "--xDirection_5kuve",
|
|
38
|
+
"_yDirection": "__yDirection_5kuve_gg_",
|
|
39
|
+
"--yDirection": "--yDirection_5kuve",
|
|
40
|
+
"__SPolygon": "___SPolygon_5kuve_gg_",
|
|
41
|
+
"_color": "__color_5kuve_gg_",
|
|
42
|
+
"--color": "--color_5kuve",
|
|
43
|
+
"__SPolygonDot": "___SPolygonDot_5kuve_gg_",
|
|
44
|
+
"_transparent": "__transparent_5kuve_gg_",
|
|
45
|
+
"__SPolygonLine": "___SPolygonLine_5kuve_gg_",
|
|
46
|
+
"__SPieRect": "___SPieRect_5kuve_gg_"
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function getAngle(i, range, func, total) {
|
|
50
|
+
var angle = (total - i) * 2 * Math.PI / total;
|
|
51
|
+
return range * (1 - func(angle)) - range;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getRadianPosition(i, range, total) {
|
|
55
|
+
return [getAngle(i, range, Math.sin, total), getAngle(i, range, Math.cos, total)];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getLabelDirection(i, total) {
|
|
59
|
+
var angle = -Math.PI / 2 + i / total * (Math.PI * 2);
|
|
60
|
+
return [Math.abs(angle) === Math.PI / 2 ? 'middle' : angle < Math.PI / 2 ? 'start' : 'end', angle === Math.PI / 2 ? 'mathematical' : angle === -Math.PI / 2 ? 'alphabetic' : 'middle'];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function computeTextWidth(texts, textSize) {
|
|
64
|
+
var defaultWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
|
|
65
|
+
var defaultHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
|
|
66
|
+
var widths = texts.map(function (text) {
|
|
67
|
+
if (typeof text === 'string') {
|
|
68
|
+
return measureText(text, textSize);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if ( /*#__PURE__*/React.isValidElement(text)) {
|
|
72
|
+
var _text$props, _text$props2;
|
|
73
|
+
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
return Math.max(((_text$props = text.props) === null || _text$props === void 0 ? void 0 : _text$props.width) || defaultWidth, ((_text$props2 = text.props) === null || _text$props2 === void 0 ? void 0 : _text$props2.height) || defaultHeight);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return defaultWidth;
|
|
79
|
+
});
|
|
80
|
+
return Math.max.apply(Math, _toConsumableArray(widths));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getTicks(tickSize, radius) {
|
|
84
|
+
var ticks = 0;
|
|
85
|
+
|
|
86
|
+
while (Math.trunc(radius / (tickSize / 2)) > ticks) {
|
|
87
|
+
ticks += 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return _toConsumableArray(Array(ticks).keys()).reduce(function (ticks, t, i, total) {
|
|
91
|
+
if (i) ticks.push(i / total.length);
|
|
92
|
+
return ticks;
|
|
93
|
+
}, []);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function pieContains(_ref10, _ref11) {
|
|
97
|
+
var _ref12 = _slicedToArray(_ref10, 3),
|
|
98
|
+
startAngle = _ref12[0],
|
|
99
|
+
endAngle = _ref12[1],
|
|
100
|
+
radius = _ref12[2];
|
|
101
|
+
|
|
102
|
+
var _ref13 = _slicedToArray(_ref11, 2),
|
|
103
|
+
x = _ref13[0],
|
|
104
|
+
y = _ref13[1];
|
|
105
|
+
|
|
106
|
+
var distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
|
|
107
|
+
if (distance > radius) return false;
|
|
108
|
+
var angle = Math.atan2(y, x) + Math.PI / 2;
|
|
109
|
+
|
|
110
|
+
if (angle < 0) {
|
|
111
|
+
// angle from 0 to 6.28...
|
|
112
|
+
angle += 2 * Math.PI;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (startAngle < 0) {
|
|
116
|
+
if (angle < endAngle) {
|
|
117
|
+
angle += Math.abs(startAngle);
|
|
118
|
+
} else {
|
|
119
|
+
angle += Math.abs(startAngle) - Math.PI * 2;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
endAngle += Math.abs(startAngle);
|
|
123
|
+
startAngle = 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return angle > startAngle && angle < endAngle;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function getLabelOffsetPosition(xDirection, yDirection, width, height) {
|
|
130
|
+
var xOffset = 0;
|
|
131
|
+
var yOffset = 0;
|
|
132
|
+
|
|
133
|
+
switch ("".concat(xDirection, "-").concat(yDirection)) {
|
|
134
|
+
case 'middle-alphabetic':
|
|
135
|
+
yOffset = height / 2;
|
|
136
|
+
break;
|
|
137
|
+
|
|
138
|
+
case 'start-middle':
|
|
139
|
+
xOffset = -width / 2;
|
|
140
|
+
break;
|
|
141
|
+
|
|
142
|
+
case 'middle-mathematical':
|
|
143
|
+
yOffset = -height / 2;
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
case 'end-middle':
|
|
147
|
+
xOffset = width / 2;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return [xOffset + width / 2, yOffset + height / 2];
|
|
152
|
+
}
|
|
153
|
+
var MINIMUM_OFFSET = 5;
|
|
154
|
+
|
|
155
|
+
var RadarRoot = /*#__PURE__*/function (_Component) {
|
|
156
|
+
_inherits(RadarRoot, _Component);
|
|
157
|
+
|
|
158
|
+
var _super = _createSuper(RadarRoot);
|
|
159
|
+
|
|
160
|
+
function RadarRoot() {
|
|
161
|
+
var _this;
|
|
162
|
+
|
|
163
|
+
_classCallCheck(this, RadarRoot);
|
|
164
|
+
|
|
165
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
166
|
+
args[_key] = arguments[_key];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
170
|
+
|
|
171
|
+
_defineProperty(_assertThisInitialized(_this), "computeOffset", 0);
|
|
172
|
+
|
|
173
|
+
_defineProperty(_assertThisInitialized(_this), "categoriesKey", null);
|
|
174
|
+
|
|
175
|
+
return _this;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
_createClass(RadarRoot, [{
|
|
179
|
+
key: "id",
|
|
180
|
+
get: function get() {
|
|
181
|
+
var _this$asProps = this.asProps,
|
|
182
|
+
id = _this$asProps.id,
|
|
183
|
+
uid = _this$asProps.uid;
|
|
184
|
+
return id || uid;
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
key: "offset",
|
|
188
|
+
get: function get() {
|
|
189
|
+
var offset = this.asProps.offset;
|
|
190
|
+
return offset !== null && offset !== void 0 ? offset : this.computeOffset;
|
|
191
|
+
}
|
|
192
|
+
}, {
|
|
193
|
+
key: "textSize",
|
|
194
|
+
get: function get() {
|
|
195
|
+
var textSize = this.asProps.textSize;
|
|
196
|
+
return textSize !== null && textSize !== void 0 ? textSize : 12;
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "getAxisProps",
|
|
200
|
+
value: function getAxisProps() {
|
|
201
|
+
return {
|
|
202
|
+
offset: this.offset,
|
|
203
|
+
textSize: this.textSize,
|
|
204
|
+
type: this.asProps.type
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "getPolygonProps",
|
|
209
|
+
value: function getPolygonProps(_ref14) {
|
|
210
|
+
var dataKey = _ref14.dataKey;
|
|
211
|
+
var _this$asProps2 = this.asProps,
|
|
212
|
+
data = _this$asProps2.data,
|
|
213
|
+
scale = _this$asProps2.scale;
|
|
214
|
+
return {
|
|
215
|
+
offset: this.offset,
|
|
216
|
+
data: data[dataKey] || [],
|
|
217
|
+
scale: scale
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "getHoverProps",
|
|
222
|
+
value: function getHoverProps() {
|
|
223
|
+
return {
|
|
224
|
+
type: this.asProps.type,
|
|
225
|
+
offset: this.offset,
|
|
226
|
+
categories: this.asProps.data[this.categoriesKey]
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}, {
|
|
230
|
+
key: "render",
|
|
231
|
+
value: function render() {
|
|
232
|
+
var _ref;
|
|
233
|
+
|
|
234
|
+
var SRadar = this.Element;
|
|
235
|
+
var _this$asProps3 = this.asProps,
|
|
236
|
+
Children = _this$asProps3.Children,
|
|
237
|
+
style = _this$asProps3.style,
|
|
238
|
+
size = _this$asProps3.size,
|
|
239
|
+
data = _this$asProps3.data,
|
|
240
|
+
offset = _this$asProps3.offset;
|
|
241
|
+
|
|
242
|
+
var _size = _slicedToArray(size, 2),
|
|
243
|
+
width = _size[0],
|
|
244
|
+
height = _size[1];
|
|
245
|
+
|
|
246
|
+
var dataKey;
|
|
247
|
+
React.Children.toArray(getOriginChildren(Children)).forEach(function (child) {
|
|
248
|
+
if ( /*#__PURE__*/React.isValidElement(child) && child.type === Radar.Axis) {
|
|
249
|
+
dataKey = child.props.dataKey;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (dataKey) {
|
|
254
|
+
if (offset === undefined) {
|
|
255
|
+
// +5 because font might not be loaded and just in case)
|
|
256
|
+
this.computeOffset = computeTextWidth(data[dataKey], this.textSize) + MINIMUM_OFFSET;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
this.categoriesKey = dataKey;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return _ref = sstyled(style), /*#__PURE__*/React.createElement(SRadar, _ref.cn("SRadar", {
|
|
263
|
+
"aria-hidden": true,
|
|
264
|
+
"id": this.id,
|
|
265
|
+
"render": 'g',
|
|
266
|
+
"childrenPosition": 'inside',
|
|
267
|
+
"transform": "translate(".concat(width / 2, ",").concat(height / 2, ")")
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
}]);
|
|
271
|
+
|
|
272
|
+
return RadarRoot;
|
|
273
|
+
}(Component);
|
|
274
|
+
|
|
275
|
+
_defineProperty(RadarRoot, "displayName", 'Line');
|
|
276
|
+
|
|
277
|
+
_defineProperty(RadarRoot, "style", style);
|
|
278
|
+
|
|
279
|
+
_defineProperty(RadarRoot, "enhance", [uniqueIDEnhancement()]);
|
|
280
|
+
|
|
281
|
+
_defineProperty(RadarRoot, "defaultProps", {
|
|
282
|
+
type: 'polygon'
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
var PolygonRoot = /*#__PURE__*/function (_Component2) {
|
|
286
|
+
_inherits(PolygonRoot, _Component2);
|
|
287
|
+
|
|
288
|
+
var _super2 = _createSuper(PolygonRoot);
|
|
289
|
+
|
|
290
|
+
function PolygonRoot() {
|
|
291
|
+
_classCallCheck(this, PolygonRoot);
|
|
292
|
+
|
|
293
|
+
return _super2.apply(this, arguments);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
_createClass(PolygonRoot, [{
|
|
297
|
+
key: "getDotsProps",
|
|
298
|
+
value: function getDotsProps() {
|
|
299
|
+
var _this$asProps4 = this.asProps,
|
|
300
|
+
data = _this$asProps4.data,
|
|
301
|
+
scale = _this$asProps4.scale,
|
|
302
|
+
color = _this$asProps4.color,
|
|
303
|
+
transparent = _this$asProps4.transparent;
|
|
304
|
+
return {
|
|
305
|
+
data: data,
|
|
306
|
+
scale: scale,
|
|
307
|
+
color: color,
|
|
308
|
+
transparent: transparent
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
}, {
|
|
312
|
+
key: "getLineProps",
|
|
313
|
+
value: function getLineProps() {
|
|
314
|
+
var _this$asProps5 = this.asProps,
|
|
315
|
+
d3 = _this$asProps5.d3,
|
|
316
|
+
data = _this$asProps5.data,
|
|
317
|
+
color = _this$asProps5.color,
|
|
318
|
+
transparent = _this$asProps5.transparent;
|
|
319
|
+
return {
|
|
320
|
+
data: data,
|
|
321
|
+
color: color,
|
|
322
|
+
transparent: transparent,
|
|
323
|
+
d3: d3
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
}, {
|
|
327
|
+
key: "render",
|
|
328
|
+
value: function render() {
|
|
329
|
+
var _ref2;
|
|
330
|
+
|
|
331
|
+
var _this$asProps6 = this.asProps,
|
|
332
|
+
SPolygon = _this$asProps6.Element,
|
|
333
|
+
styles = _this$asProps6.styles,
|
|
334
|
+
d3 = _this$asProps6.d3,
|
|
335
|
+
data = _this$asProps6.data,
|
|
336
|
+
color = _this$asProps6.color,
|
|
337
|
+
fill = _this$asProps6.fill;
|
|
338
|
+
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(SPolygon, _ref2.cn("SPolygon", {
|
|
339
|
+
"render": 'path',
|
|
340
|
+
"d": d3(data),
|
|
341
|
+
"color": fill || color
|
|
342
|
+
}));
|
|
343
|
+
}
|
|
344
|
+
}]);
|
|
345
|
+
|
|
346
|
+
return PolygonRoot;
|
|
347
|
+
}(Component);
|
|
348
|
+
|
|
349
|
+
_defineProperty(PolygonRoot, "displayName", 'Polygon');
|
|
350
|
+
|
|
351
|
+
_defineProperty(PolygonRoot, "style", style);
|
|
352
|
+
|
|
353
|
+
_defineProperty(PolygonRoot, "defaultProps", function (_ref18) {
|
|
354
|
+
var scale = _ref18.scale,
|
|
355
|
+
_ref18$curve = _ref18.curve,
|
|
356
|
+
curve = _ref18$curve === void 0 ? curveLinearClosed : _ref18$curve,
|
|
357
|
+
size = _ref18.size,
|
|
358
|
+
offset = _ref18.offset;
|
|
359
|
+
scale.range([0, Math.min(size[0], size[1]) / 2 - offset]);
|
|
360
|
+
return {
|
|
361
|
+
d3: lineRadial().curve(curve).radius(function (d) {
|
|
362
|
+
return scale(d || 0);
|
|
363
|
+
}).angle(function (d, i, data) {
|
|
364
|
+
return i / data.length * 2 * Math.PI;
|
|
365
|
+
})
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
function PolygonLine(props) {
|
|
370
|
+
var _ref3;
|
|
371
|
+
|
|
372
|
+
var SPolygonLine = props.Element,
|
|
373
|
+
styles = props.styles,
|
|
374
|
+
d3 = props.d3,
|
|
375
|
+
color = props.color,
|
|
376
|
+
data = props.data,
|
|
377
|
+
transparent = props.transparent;
|
|
378
|
+
return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(SPolygonLine, _ref3.cn("SPolygonLine", {
|
|
379
|
+
"render": 'path',
|
|
380
|
+
"d": d3(data),
|
|
381
|
+
"color": color,
|
|
382
|
+
"transparent": transparent
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function PolygonDots(props) {
|
|
387
|
+
var SPolygonDot = props.Element,
|
|
388
|
+
styles = props.styles,
|
|
389
|
+
color = props.color,
|
|
390
|
+
data = props.data,
|
|
391
|
+
scale = props.scale,
|
|
392
|
+
transparent = props.transparent;
|
|
393
|
+
return data.map(function (value, i) {
|
|
394
|
+
var _ref4;
|
|
395
|
+
|
|
396
|
+
if (value === null || value === undefined) return;
|
|
397
|
+
var radius = scale(value);
|
|
398
|
+
|
|
399
|
+
var _getRadianPosition = getRadianPosition(i, radius, data.length),
|
|
400
|
+
_getRadianPosition2 = _slicedToArray(_getRadianPosition, 2),
|
|
401
|
+
cx = _getRadianPosition2[0],
|
|
402
|
+
cy = _getRadianPosition2[1];
|
|
403
|
+
|
|
404
|
+
return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SPolygonDot, _ref4.cn("SPolygonDot", {
|
|
405
|
+
"key": i,
|
|
406
|
+
"render": 'circle',
|
|
407
|
+
"cx": cx,
|
|
408
|
+
"cy": cy,
|
|
409
|
+
"color": color,
|
|
410
|
+
"transparent": transparent
|
|
411
|
+
}));
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
var AxisRoot = /*#__PURE__*/function (_Component3) {
|
|
416
|
+
_inherits(AxisRoot, _Component3);
|
|
417
|
+
|
|
418
|
+
var _super3 = _createSuper(AxisRoot);
|
|
419
|
+
|
|
420
|
+
function AxisRoot() {
|
|
421
|
+
var _this2;
|
|
422
|
+
|
|
423
|
+
_classCallCheck(this, AxisRoot);
|
|
424
|
+
|
|
425
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
426
|
+
args[_key2] = arguments[_key2];
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
_this2 = _super3.call.apply(_super3, [this].concat(args));
|
|
430
|
+
|
|
431
|
+
_defineProperty(_assertThisInitialized(_this2), "unsubscribeTooltipVisible", null);
|
|
432
|
+
|
|
433
|
+
_defineProperty(_assertThisInitialized(_this2), "state", {
|
|
434
|
+
activeLineIndex: null
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
_defineProperty(_assertThisInitialized(_this2), "handlerTooltipVisible", function (visible, _ref15) {
|
|
438
|
+
var index = _ref15.index;
|
|
439
|
+
|
|
440
|
+
_this2.setState({
|
|
441
|
+
activeLineIndex: index
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
return _this2;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
_createClass(AxisRoot, [{
|
|
449
|
+
key: "createLineRadial",
|
|
450
|
+
value: function createLineRadial(radius, total) {
|
|
451
|
+
return lineRadial().curve(curveLinearClosed).radius(function () {
|
|
452
|
+
return radius;
|
|
453
|
+
}).angle(function (d, i) {
|
|
454
|
+
return i / total * 2 * Math.PI;
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}, {
|
|
458
|
+
key: "getTicksProps",
|
|
459
|
+
value: function getTicksProps(_ref16) {
|
|
460
|
+
var _ref16$tickSize = _ref16.tickSize,
|
|
461
|
+
tickSize = _ref16$tickSize === void 0 ? 100 : _ref16$tickSize;
|
|
462
|
+
var _this$asProps7 = this.asProps,
|
|
463
|
+
data = _this$asProps7.data,
|
|
464
|
+
offset = _this$asProps7.offset,
|
|
465
|
+
categories = _this$asProps7.categories,
|
|
466
|
+
size = _this$asProps7.size,
|
|
467
|
+
type = _this$asProps7.type;
|
|
468
|
+
var radius = Math.min(size[0], size[1]) / 2 - offset;
|
|
469
|
+
return {
|
|
470
|
+
type: type,
|
|
471
|
+
data: data,
|
|
472
|
+
categories: categories,
|
|
473
|
+
ticks: getTicks(tickSize, radius),
|
|
474
|
+
offset: offset,
|
|
475
|
+
d3: this.createLineRadial(radius, categories.length)
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
479
|
+
key: "getLabelsProps",
|
|
480
|
+
value: function getLabelsProps(_ref17) {
|
|
481
|
+
var _ref17$labelOffset = _ref17.labelOffset,
|
|
482
|
+
labelOffset = _ref17$labelOffset === void 0 ? 10 : _ref17$labelOffset;
|
|
483
|
+
var _this$asProps8 = this.asProps,
|
|
484
|
+
offset = _this$asProps8.offset,
|
|
485
|
+
categories = _this$asProps8.categories,
|
|
486
|
+
textSize = _this$asProps8.textSize;
|
|
487
|
+
return {
|
|
488
|
+
categories: categories,
|
|
489
|
+
textSize: textSize,
|
|
490
|
+
offset: offset - labelOffset
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
}, {
|
|
494
|
+
key: "componentDidMount",
|
|
495
|
+
value: function componentDidMount() {
|
|
496
|
+
var eventEmitter = this.asProps.eventEmitter;
|
|
497
|
+
this.unsubscribeTooltipVisible = eventEmitter.subscribe('onTooltipVisible', this.handlerTooltipVisible);
|
|
498
|
+
}
|
|
499
|
+
}, {
|
|
500
|
+
key: "componentWillUnmount",
|
|
501
|
+
value: function componentWillUnmount() {
|
|
502
|
+
if (this.unsubscribeTooltipVisible) {
|
|
503
|
+
this.unsubscribeTooltipVisible();
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}, {
|
|
507
|
+
key: "render",
|
|
508
|
+
value: function render() {
|
|
509
|
+
var _ref5;
|
|
510
|
+
|
|
511
|
+
var _this$asProps9 = this.asProps,
|
|
512
|
+
SAxis = _this$asProps9.Element,
|
|
513
|
+
styles = _this$asProps9.styles,
|
|
514
|
+
categories = _this$asProps9.categories,
|
|
515
|
+
size = _this$asProps9.size,
|
|
516
|
+
offset = _this$asProps9.offset,
|
|
517
|
+
type = _this$asProps9.type;
|
|
518
|
+
var activeLineIndex = this.state.activeLineIndex;
|
|
519
|
+
var radius = Math.min(size[0], size[1]) / 2 - offset;
|
|
520
|
+
var total = categories.length;
|
|
521
|
+
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, type === 'circle' ? /*#__PURE__*/React.createElement(SAxis, _ref5.cn("SAxis", {
|
|
522
|
+
"render": 'circle',
|
|
523
|
+
"cx": 0,
|
|
524
|
+
"cy": 0,
|
|
525
|
+
"r": radius
|
|
526
|
+
})) : /*#__PURE__*/React.createElement(SAxis, _ref5.cn("SAxis", {
|
|
527
|
+
"render": 'path',
|
|
528
|
+
"d": this.createLineRadial(radius, total)(categories)
|
|
529
|
+
})), categories.map(function (category, i) {
|
|
530
|
+
var _getRadianPosition3 = getRadianPosition(i, radius, total),
|
|
531
|
+
_getRadianPosition4 = _slicedToArray(_getRadianPosition3, 2),
|
|
532
|
+
x = _getRadianPosition4[0],
|
|
533
|
+
y = _getRadianPosition4[1];
|
|
534
|
+
|
|
535
|
+
var _sstyled$cn = sstyled(styles).cn('SAxisLine', {
|
|
536
|
+
active: activeLineIndex === i
|
|
537
|
+
}),
|
|
538
|
+
className = _sstyled$cn.className;
|
|
539
|
+
|
|
540
|
+
return /*#__PURE__*/React.createElement("line", {
|
|
541
|
+
key: i,
|
|
542
|
+
x1: 0,
|
|
543
|
+
y1: 0,
|
|
544
|
+
x2: x,
|
|
545
|
+
y2: y,
|
|
546
|
+
className: className
|
|
547
|
+
});
|
|
548
|
+
}));
|
|
549
|
+
}
|
|
550
|
+
}]);
|
|
551
|
+
|
|
552
|
+
return AxisRoot;
|
|
553
|
+
}(Component);
|
|
554
|
+
|
|
555
|
+
_defineProperty(AxisRoot, "displayName", 'Polygon');
|
|
556
|
+
|
|
557
|
+
_defineProperty(AxisRoot, "style", style);
|
|
558
|
+
|
|
559
|
+
_defineProperty(AxisRoot, "defaultProps", function (_ref19) {
|
|
560
|
+
var data = _ref19.data,
|
|
561
|
+
dataKey = _ref19.dataKey;
|
|
562
|
+
var categories = data[dataKey];
|
|
563
|
+
return {
|
|
564
|
+
categories: categories
|
|
565
|
+
};
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
function AxisTicks(props) {
|
|
569
|
+
var SAxisTick = props.Element,
|
|
570
|
+
styles = props.styles,
|
|
571
|
+
size = props.size,
|
|
572
|
+
ticks = props.ticks,
|
|
573
|
+
d3 = props.d3,
|
|
574
|
+
categories = props.categories,
|
|
575
|
+
offset = props.offset,
|
|
576
|
+
type = props.type;
|
|
577
|
+
var radius = Math.min(size[0], size[1]) / 2 - offset;
|
|
578
|
+
return ticks.map(function (tick, i) {
|
|
579
|
+
var _ref6;
|
|
580
|
+
|
|
581
|
+
d3.radius(function () {
|
|
582
|
+
return radius * tick;
|
|
583
|
+
});
|
|
584
|
+
return _ref6 = sstyled(styles), type === 'circle' ? /*#__PURE__*/React.createElement(SAxisTick, _ref6.cn("SAxisTick", {
|
|
585
|
+
"key": i,
|
|
586
|
+
"render": 'circle',
|
|
587
|
+
"cx": 0,
|
|
588
|
+
"cy": 0,
|
|
589
|
+
"r": radius * tick
|
|
590
|
+
})) : /*#__PURE__*/React.createElement(SAxisTick, _ref6.cn("SAxisTick", {
|
|
591
|
+
"render": 'path',
|
|
592
|
+
"key": i,
|
|
593
|
+
"d": d3(categories)
|
|
594
|
+
}));
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function AxisLabels(props) {
|
|
599
|
+
var SAxisLabel = props.Element,
|
|
600
|
+
styles = props.styles,
|
|
601
|
+
textSize = props.textSize,
|
|
602
|
+
size = props.size,
|
|
603
|
+
offset = props.offset,
|
|
604
|
+
categories = props.categories;
|
|
605
|
+
var radius = Math.min(size[0], size[1]) / 2 - offset;
|
|
606
|
+
return categories.map(function (category, i) {
|
|
607
|
+
var _getRadianPosition5 = getRadianPosition(i, radius, categories.length),
|
|
608
|
+
_getRadianPosition6 = _slicedToArray(_getRadianPosition5, 2),
|
|
609
|
+
x = _getRadianPosition6[0],
|
|
610
|
+
y = _getRadianPosition6[1];
|
|
611
|
+
|
|
612
|
+
var _getLabelDirection = getLabelDirection(i, categories.length),
|
|
613
|
+
_getLabelDirection2 = _slicedToArray(_getLabelDirection, 2),
|
|
614
|
+
xDirection = _getLabelDirection2[0],
|
|
615
|
+
yDirection = _getLabelDirection2[1];
|
|
616
|
+
|
|
617
|
+
if (typeof category === 'string') {
|
|
618
|
+
var _ref7;
|
|
619
|
+
|
|
620
|
+
var lines = category.split('\n');
|
|
621
|
+
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SAxisLabel, _ref7.cn("SAxisLabel", {
|
|
622
|
+
"key": i,
|
|
623
|
+
"render": 'text',
|
|
624
|
+
"childrenPosition": 'inside',
|
|
625
|
+
"x": x,
|
|
626
|
+
"y": y,
|
|
627
|
+
"xDirection": xDirection,
|
|
628
|
+
"yDirection": yDirection
|
|
629
|
+
}), lines.map(function (lineText, lineIndex) {
|
|
630
|
+
return /*#__PURE__*/React.createElement("tspan", {
|
|
631
|
+
x: x,
|
|
632
|
+
y: y + (lineIndex - (lines.length - 1) / 2) * textSize,
|
|
633
|
+
key: "#".concat(lineIndex, "-").concat(lineText)
|
|
634
|
+
}, lineText);
|
|
635
|
+
}));
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if ( /*#__PURE__*/React.isValidElement(category)) {
|
|
639
|
+
var _category$props = category === null || category === void 0 ? void 0 : category.props,
|
|
640
|
+
_category$props$width = _category$props.width,
|
|
641
|
+
width = _category$props$width === void 0 ? 0 : _category$props$width,
|
|
642
|
+
_category$props$heigh = _category$props.height,
|
|
643
|
+
height = _category$props$heigh === void 0 ? 0 : _category$props$heigh;
|
|
644
|
+
|
|
645
|
+
var _getLabelOffsetPositi = getLabelOffsetPosition(xDirection, yDirection, width, height),
|
|
646
|
+
_getLabelOffsetPositi2 = _slicedToArray(_getLabelOffsetPositi, 2),
|
|
647
|
+
xOffset = _getLabelOffsetPositi2[0],
|
|
648
|
+
yOffset = _getLabelOffsetPositi2[1];
|
|
649
|
+
|
|
650
|
+
return /*#__PURE__*/cloneElement(category, {
|
|
651
|
+
key: i,
|
|
652
|
+
x: x - xOffset,
|
|
653
|
+
y: y - yOffset
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
var Hover = /*#__PURE__*/function (_Component4) {
|
|
660
|
+
_inherits(Hover, _Component4);
|
|
661
|
+
|
|
662
|
+
var _super4 = _createSuper(Hover);
|
|
663
|
+
|
|
664
|
+
function Hover() {
|
|
665
|
+
var _this3;
|
|
666
|
+
|
|
667
|
+
_classCallCheck(this, Hover);
|
|
668
|
+
|
|
669
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
670
|
+
args[_key3] = arguments[_key3];
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
_this3 = _super4.call.apply(_super4, [this].concat(args));
|
|
674
|
+
|
|
675
|
+
_defineProperty(_assertThisInitialized(_this3), "state", {
|
|
676
|
+
index: null
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
_defineProperty(_assertThisInitialized(_this3), "virtualElement", canUseDOM() ? document.createElement('div') : {});
|
|
680
|
+
|
|
681
|
+
_defineProperty(_assertThisInitialized(_this3), "unsubscribeMouseMoveRoot", null);
|
|
682
|
+
|
|
683
|
+
_defineProperty(_assertThisInitialized(_this3), "unsubscribeMouseLeaveRoot", null);
|
|
684
|
+
|
|
685
|
+
_defineProperty(_assertThisInitialized(_this3), "handlerMouseMoveRoot", trottle(function (e) {
|
|
686
|
+
var _this3$asProps = _this3.asProps,
|
|
687
|
+
eventEmitter = _this3$asProps.eventEmitter,
|
|
688
|
+
size = _this3$asProps.size,
|
|
689
|
+
rootRef = _this3$asProps.rootRef;
|
|
690
|
+
var point = eventToPoint(e, rootRef.current);
|
|
691
|
+
var diam = Math.min(size[0], size[1]);
|
|
692
|
+
var centerX = point[0] - diam / 2;
|
|
693
|
+
var centerY = point[1] - diam / 2;
|
|
694
|
+
var clientX = e.clientX,
|
|
695
|
+
clientY = e.clientY; // @ts-ignore
|
|
696
|
+
|
|
697
|
+
_this3.virtualElement.getBoundingClientRect = _this3.generateGetBoundingClientRect(clientX, clientY);
|
|
698
|
+
_this3.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;
|
|
699
|
+
|
|
700
|
+
var index = _this3.getIndex([centerX, centerY]);
|
|
701
|
+
|
|
702
|
+
_this3.setState({
|
|
703
|
+
index: index
|
|
704
|
+
}, function () {
|
|
705
|
+
eventEmitter.emit('onTooltipVisible', index !== null, {
|
|
706
|
+
index: index
|
|
707
|
+
}, _this3.virtualElement);
|
|
708
|
+
});
|
|
709
|
+
}));
|
|
710
|
+
|
|
711
|
+
_defineProperty(_assertThisInitialized(_this3), "handlerMouseLeaveRoot", trottle(function () {
|
|
712
|
+
_this3.setState({
|
|
713
|
+
index: null
|
|
714
|
+
}, function () {
|
|
715
|
+
_this3.asProps.eventEmitter.emit('onTooltipVisible', false, {
|
|
716
|
+
index: null
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
}));
|
|
720
|
+
|
|
721
|
+
return _this3;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
_createClass(Hover, [{
|
|
725
|
+
key: "generateGetBoundingClientRect",
|
|
726
|
+
value: function generateGetBoundingClientRect() {
|
|
727
|
+
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
728
|
+
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
729
|
+
return function () {
|
|
730
|
+
return {
|
|
731
|
+
width: 0,
|
|
732
|
+
height: 0,
|
|
733
|
+
top: y,
|
|
734
|
+
right: x,
|
|
735
|
+
bottom: y,
|
|
736
|
+
left: x
|
|
737
|
+
};
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
}, {
|
|
741
|
+
key: "getPolygon",
|
|
742
|
+
value: function getPolygon(index) {
|
|
743
|
+
var _this$asProps10 = this.asProps,
|
|
744
|
+
categories = _this$asProps10.categories,
|
|
745
|
+
size = _this$asProps10.size,
|
|
746
|
+
offset = _this$asProps10.offset;
|
|
747
|
+
var total = categories.length;
|
|
748
|
+
var diam = Math.min(size[0], size[1]);
|
|
749
|
+
var radius = diam / 2 - offset;
|
|
750
|
+
var prevIndex = (index - 1 + total) % total;
|
|
751
|
+
var nextIndex = (index + 1 + total) % total;
|
|
752
|
+
|
|
753
|
+
var _getRadianPosition7 = getRadianPosition(prevIndex, radius, total),
|
|
754
|
+
_getRadianPosition8 = _slicedToArray(_getRadianPosition7, 2),
|
|
755
|
+
prevX1 = _getRadianPosition8[0],
|
|
756
|
+
prevY1 = _getRadianPosition8[1];
|
|
757
|
+
|
|
758
|
+
var _getRadianPosition9 = getRadianPosition(index, radius, total),
|
|
759
|
+
_getRadianPosition10 = _slicedToArray(_getRadianPosition9, 2),
|
|
760
|
+
x = _getRadianPosition10[0],
|
|
761
|
+
y = _getRadianPosition10[1];
|
|
762
|
+
|
|
763
|
+
var _getRadianPosition11 = getRadianPosition(nextIndex, radius, total),
|
|
764
|
+
_getRadianPosition12 = _slicedToArray(_getRadianPosition11, 2),
|
|
765
|
+
nextX1 = _getRadianPosition12[0],
|
|
766
|
+
nextY1 = _getRadianPosition12[1];
|
|
767
|
+
|
|
768
|
+
return [[0, 0], [(prevX1 + x) / 2, (prevY1 + y) / 2], [x, y], [(nextX1 + x) / 2, (nextY1 + y) / 2]];
|
|
769
|
+
}
|
|
770
|
+
}, {
|
|
771
|
+
key: "getPie",
|
|
772
|
+
value: function getPie(index) {
|
|
773
|
+
var _this$asProps11 = this.asProps,
|
|
774
|
+
categories = _this$asProps11.categories,
|
|
775
|
+
size = _this$asProps11.size,
|
|
776
|
+
offset = _this$asProps11.offset;
|
|
777
|
+
var angle = Math.PI * 2 / categories.length;
|
|
778
|
+
var radius = Math.min(size[0], size[1]) / 2 - offset;
|
|
779
|
+
return [index * angle - angle / 2, (index + 1) * angle - angle / 2, radius];
|
|
780
|
+
}
|
|
781
|
+
}, {
|
|
782
|
+
key: "getIndex",
|
|
783
|
+
value: function getIndex(point) {
|
|
784
|
+
var _this4 = this;
|
|
785
|
+
|
|
786
|
+
var _this$asProps12 = this.asProps,
|
|
787
|
+
categories = _this$asProps12.categories,
|
|
788
|
+
type = _this$asProps12.type;
|
|
789
|
+
var index;
|
|
790
|
+
|
|
791
|
+
if (type === 'circle') {
|
|
792
|
+
index = categories.findIndex(function (c, i) {
|
|
793
|
+
return pieContains(_this4.getPie(i), point);
|
|
794
|
+
});
|
|
795
|
+
} else {
|
|
796
|
+
index = categories.findIndex(function (c, i) {
|
|
797
|
+
return polygonContains(_this4.getPolygon(i), point);
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
return index === -1 ? null : index;
|
|
802
|
+
}
|
|
803
|
+
}, {
|
|
804
|
+
key: "componentDidMount",
|
|
805
|
+
value: function componentDidMount() {
|
|
806
|
+
var _this5 = this;
|
|
807
|
+
|
|
808
|
+
var eventEmitter = this.asProps.eventEmitter;
|
|
809
|
+
this.unsubscribeMouseMoveRoot = eventEmitter.subscribe('onMouseMoveRoot', function (e) {
|
|
810
|
+
e.persist();
|
|
811
|
+
|
|
812
|
+
_this5.handlerMouseMoveRoot(e);
|
|
813
|
+
});
|
|
814
|
+
this.unsubscribeMouseLeaveRoot = eventEmitter.subscribe('onMouseLeaveRoot', this.handlerMouseLeaveRoot);
|
|
815
|
+
}
|
|
816
|
+
}, {
|
|
817
|
+
key: "componentWillUnmount",
|
|
818
|
+
value: function componentWillUnmount() {
|
|
819
|
+
if (this.unsubscribeMouseMoveRoot) {
|
|
820
|
+
this.unsubscribeMouseMoveRoot();
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (this.unsubscribeMouseLeaveRoot) {
|
|
824
|
+
this.unsubscribeMouseLeaveRoot();
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}, {
|
|
828
|
+
key: "render",
|
|
829
|
+
value: function render() {
|
|
830
|
+
var _this$asProps13 = this.asProps,
|
|
831
|
+
styles = _this$asProps13.styles,
|
|
832
|
+
type = _this$asProps13.type;
|
|
833
|
+
var index = this.state.index;
|
|
834
|
+
var SPieRect = this.Element;
|
|
835
|
+
|
|
836
|
+
if (index !== null) {
|
|
837
|
+
if (type === 'circle') {
|
|
838
|
+
var _ref8;
|
|
839
|
+
|
|
840
|
+
var _this$getPie = this.getPie(index),
|
|
841
|
+
_this$getPie2 = _slicedToArray(_this$getPie, 3),
|
|
842
|
+
startAngle = _this$getPie2[0],
|
|
843
|
+
endAngle = _this$getPie2[1],
|
|
844
|
+
radius = _this$getPie2[2];
|
|
845
|
+
|
|
846
|
+
var circle = arc().innerRadius(0).outerRadius(radius).startAngle(startAngle).endAngle(endAngle);
|
|
847
|
+
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(SPieRect, _ref8.cn("SPieRect", {
|
|
848
|
+
"render": 'path',
|
|
849
|
+
"d": circle()
|
|
850
|
+
}));
|
|
851
|
+
} else {
|
|
852
|
+
var _ref9;
|
|
853
|
+
|
|
854
|
+
return _ref9 = sstyled(styles), /*#__PURE__*/React.createElement(SPieRect, _ref9.cn("SPieRect", {
|
|
855
|
+
"render": 'path',
|
|
856
|
+
"d": line()(this.getPolygon(index))
|
|
857
|
+
}));
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}]);
|
|
862
|
+
|
|
863
|
+
return Hover;
|
|
864
|
+
}(Component);
|
|
865
|
+
|
|
866
|
+
var Axis = createElement(AxisRoot, {
|
|
867
|
+
Ticks: AxisTicks,
|
|
868
|
+
Labels: AxisLabels
|
|
869
|
+
});
|
|
870
|
+
var Polygon = createElement(PolygonRoot, {
|
|
871
|
+
Line: PolygonLine,
|
|
872
|
+
Dots: PolygonDots
|
|
873
|
+
});
|
|
874
|
+
var Radar = createElement(RadarRoot, {
|
|
875
|
+
Axis: Axis,
|
|
876
|
+
Polygon: Polygon,
|
|
877
|
+
Hover: Hover
|
|
878
|
+
});
|
|
879
|
+
export default Radar;
|
|
880
|
+
//# sourceMappingURL=Radar.js.map
|