1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getTransformOptions = exports.angleOf = exports.radiusOf = exports.getRadius = exports.isNonCartesian = exports.isTheta = exports.isCircular = exports.isRadar = exports.isFisheye = exports.isParallel = exports.isHelix = exports.isRadial = exports.isPolar = exports.isTranspose = void 0;
|
4 | function isTranspose(coordinate) {
|
5 | const { transformations } = coordinate.getOptions();
|
6 | const transposes = transformations
|
7 | .map(([type]) => type)
|
8 | .filter((type) => type === 'transpose');
|
9 | return transposes.length % 2 !== 0;
|
10 | }
|
11 | exports.isTranspose = isTranspose;
|
12 | function isPolar(coordinate) {
|
13 | const { transformations } = coordinate.getOptions();
|
14 | return transformations.some(([type]) => type === 'polar');
|
15 | }
|
16 | exports.isPolar = isPolar;
|
17 | function isRadial(coordinate) {
|
18 | const { transformations } = coordinate.getOptions();
|
19 | return (
|
20 |
|
21 | transformations.some(([type]) => type === 'reflect') &&
|
22 | transformations.some(([type]) => type.startsWith('transpose')));
|
23 | }
|
24 | exports.isRadial = isRadial;
|
25 | function isHelix(coordinate) {
|
26 | const { transformations } = coordinate.getOptions();
|
27 | return transformations.some(([type]) => type === 'helix');
|
28 | }
|
29 | exports.isHelix = isHelix;
|
30 | function isParallel(coordinate) {
|
31 | const { transformations } = coordinate.getOptions();
|
32 | return transformations.some(([type]) => type === 'parallel');
|
33 | }
|
34 | exports.isParallel = isParallel;
|
35 | function isFisheye(coordinate) {
|
36 | const { transformations } = coordinate.getOptions();
|
37 | return transformations.some(([type]) => type === 'fisheye');
|
38 | }
|
39 | exports.isFisheye = isFisheye;
|
40 | function isRadar(coordinate) {
|
41 | return isParallel(coordinate) && isPolar(coordinate);
|
42 | }
|
43 | exports.isRadar = isRadar;
|
44 | function isCircular(coordinate) {
|
45 | return isHelix(coordinate) || isPolar(coordinate);
|
46 | }
|
47 | exports.isCircular = isCircular;
|
48 | function isTheta(coordinate) {
|
49 | return isPolar(coordinate) && isTranspose(coordinate);
|
50 | }
|
51 | exports.isTheta = isTheta;
|
52 | function isNonCartesian(coordinate) {
|
53 | return (isPolar(coordinate) ||
|
54 | isParallel(coordinate) ||
|
55 | isRadial(coordinate) ||
|
56 | isTheta(coordinate));
|
57 | }
|
58 | exports.isNonCartesian = isNonCartesian;
|
59 | function getRadius(coordinate) {
|
60 | if (isCircular(coordinate)) {
|
61 | const [width, height] = coordinate.getSize();
|
62 | const polar = coordinate
|
63 | .getOptions()
|
64 | .transformations.find((t) => t[0] === 'polar');
|
65 |
|
66 | if (polar)
|
67 | return (Math.max(width, height) / 2) * polar[4];
|
68 | }
|
69 | return 0;
|
70 | }
|
71 | exports.getRadius = getRadius;
|
72 | function radiusOf(coordinate) {
|
73 | const { transformations } = coordinate.getOptions();
|
74 | const [, , , innerRadius, outerRadius] = transformations.find((d) => d[0] === 'polar');
|
75 | return [+innerRadius, +outerRadius];
|
76 | }
|
77 | exports.radiusOf = radiusOf;
|
78 | function angleOf(coordinate, isRadius = true) {
|
79 | const { transformations } = coordinate.getOptions();
|
80 | const [, startAngle, endAngle] = transformations.find((d) => d[0] === 'polar');
|
81 | return isRadius
|
82 | ? [(+startAngle * 180) / Math.PI, (+endAngle * 180) / Math.PI]
|
83 | : [startAngle, endAngle];
|
84 | }
|
85 | exports.angleOf = angleOf;
|
86 | function getTransformOptions(coordinate, type) {
|
87 | const { transformations } = coordinate.getOptions();
|
88 | const [, ...args] = transformations.find((d) => d[0] === type);
|
89 | return args;
|
90 | }
|
91 | exports.getTransformOptions = getTransformOptions;
|
92 |
|
\ | No newline at end of file |