@figtreejs/core 0.0.1-alpha.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 +9 -0
- package/eslint.config.js +9 -0
- package/package.json +76 -0
- package/src/@custom-types/normalize-svg-path.d.ts +13 -0
- package/src/@custom-types/parse-svg-path.d.ts +8 -0
- package/src/@custom-types/svg-path-types.d.ts +37 -0
- package/src/bauble-makers/makers.ts +112 -0
- package/src/bauble-makers/set-up-baubles.ts +197 -0
- package/src/bauble-makers/utils.ts +61 -0
- package/src/components/baubles/bauble.tsx +61 -0
- package/src/components/baubles/branches.tsx +13 -0
- package/src/components/baubles/clades/cartoon.tsx +68 -0
- package/src/components/baubles/clades/highlight.tsx +96 -0
- package/src/components/baubles/clades/index.ts +1 -0
- package/src/components/baubles/clades.tsx +45 -0
- package/src/components/baubles/helpers.tsx +62 -0
- package/src/components/baubles/index.ts +16 -0
- package/src/components/baubles/labels.tsx +38 -0
- package/src/components/baubles/nodes.tsx +51 -0
- package/src/components/baubles/shapes/branch.tsx +53 -0
- package/src/components/baubles/shapes/circle.tsx +64 -0
- package/src/components/baubles/shapes/index.ts +9 -0
- package/src/components/baubles/shapes/label.tsx +104 -0
- package/src/components/baubles/shapes/rectangle.tsx +83 -0
- package/src/components/baubles/types.ts +99 -0
- package/src/components/decorations/axis/axis-types.ts +123 -0
- package/src/components/decorations/axis/axis.tsx +21 -0
- package/src/components/decorations/axis/index.ts +2 -0
- package/src/components/decorations/axis/polar-axis-bars.tsx +102 -0
- package/src/components/decorations/axis/polar-axis.tsx +175 -0
- package/src/components/decorations/axis/rectangular-axis-bars.tsx +53 -0
- package/src/components/decorations/axis/rectangular-axis.tsx +151 -0
- package/src/components/decorations/index.ts +2 -0
- package/src/components/decorations/legend/discrete-legend.tsx +93 -0
- package/src/components/decorations/legend/index.ts +1 -0
- package/src/components/decorations/legend/legend.tsx +1 -0
- package/src/components/figtree/figtree-types.ts +69 -0
- package/src/components/figtree/figtree.tsx +136 -0
- package/src/components/figtree/index.ts +3 -0
- package/src/components/hoc/index.ts +7 -0
- package/src/components/hoc/with-branch.tsx +148 -0
- package/src/components/hoc/with-branches.tsx +54 -0
- package/src/components/hoc/with-clades.tsx +47 -0
- package/src/components/hoc/with-node.tsx +183 -0
- package/src/components/hoc/with-nodes.tsx +45 -0
- package/src/components/index.ts +4 -0
- package/src/context/aminated-context.ts +3 -0
- package/src/context/dimension-context.ts +22 -0
- package/src/context/layout-context.ts +20 -0
- package/src/context/scale-context.ts +12 -0
- package/src/evo/index.ts +1 -0
- package/src/evo/tree/index.ts +5 -0
- package/src/evo/tree/mcc-tree.ts +0 -0
- package/src/evo/tree/normalized-tree/immutable-tree-helpers.ts +136 -0
- package/src/evo/tree/normalized-tree/immutable-tree.test.ts +158 -0
- package/src/evo/tree/normalized-tree/immutable-tree.ts +1365 -0
- package/src/evo/tree/normalized-tree/index.ts +3 -0
- package/src/evo/tree/parsers/annotation-parser.ts +276 -0
- package/src/evo/tree/parsers/index.ts +3 -0
- package/src/evo/tree/parsers/newick-character-parser.ts +246 -0
- package/src/evo/tree/parsers/newick-parsing.ts +22 -0
- package/src/evo/tree/parsers/nexus-parser.ts +12 -0
- package/src/evo/tree/parsers/nexus-parsing.ts +68 -0
- package/src/evo/tree/parsers/parsing.test.ts +289 -0
- package/src/evo/tree/parsers/stream-reader/index.ts +1 -0
- package/src/evo/tree/parsers/stream-reader/newick-importer.txt +395 -0
- package/src/evo/tree/parsers/stream-reader/nexus-importer.test.ts +99 -0
- package/src/evo/tree/parsers/stream-reader/nexus-importer.ts +293 -0
- package/src/evo/tree/parsers/stream-reader/nexus-tokenizer.ts +77 -0
- package/src/evo/tree/parsers/stream-reader/nexus-transform-stream.txt +109 -0
- package/src/evo/tree/taxa/helper-functions.ts +46 -0
- package/src/evo/tree/taxa/index.ts +1 -0
- package/src/evo/tree/taxa/taxon.ts +116 -0
- package/src/evo/tree/traversals/index.ts +1 -0
- package/src/evo/tree/traversals/preorder-traversal.ts +89 -0
- package/src/evo/tree/traversals/traversal-types.ts +6 -0
- package/src/evo/tree/tree-types.ts +197 -0
- package/src/evo/tree/utilities.ts +44 -0
- package/src/index.ts +6 -0
- package/src/layouts/functional/index.ts +2 -0
- package/src/layouts/functional/radial-layout.ts +150 -0
- package/src/layouts/functional/rectangular-layout.ts +71 -0
- package/src/layouts/index.ts +3 -0
- package/src/layouts/layout-interface.ts +90 -0
- package/src/layouts/types.ts +32 -0
- package/src/path.helpers.ts +81 -0
- package/src/store/polar-scale.ts +145 -0
- package/src/store/store.ts +144 -0
- package/src/tests/baubles/__snapshots__/branch-labels.test.tsx.snap +901 -0
- package/src/tests/baubles/__snapshots__/node-labels.test.tsx.snap +1516 -0
- package/src/tests/baubles/branch-labels.test.tsx +103 -0
- package/src/tests/baubles/label.svg +131 -0
- package/src/tests/baubles/node-labels.test.tsx +126 -0
- package/src/tests/clades/__snapshots__/cartoon.test.tsx.snap +327 -0
- package/src/tests/clades/__snapshots__/highlight.test.tsx.snap +337 -0
- package/src/tests/clades/cartoon.test.tsx +65 -0
- package/src/tests/clades/highlight.test.tsx +66 -0
- package/src/tests/figtree/__snapshots__/figtree.test.tsx.snap +761 -0
- package/src/tests/figtree/figtree.test.tsx +123 -0
- package/src/tests/figtree/simple.svg +47 -0
- package/src/tests/layouts/radiallayout.test.ts +23 -0
- package/src/tests/layouts/rectangularlayout.test.ts +65 -0
- package/src/tests/shapes/branch.test.tsx +40 -0
- package/src/tests/shapes/circle.test.tsx +47 -0
- package/src/tests/shapes/label.test.tsx +101 -0
- package/src/tests/shapes/rectangle.test.tsx +67 -0
- package/src/tests/shapes/types.ts +1 -0
- package/src/utils.ts +57 -0
- package/tsconfig.json +12 -0
- package/vite.config.ts +34 -0
- package/vitetest.config.ts +11 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, test } from "vitest";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import { ImmutableTree } from "../../evo";
|
|
4
|
+
import { FigTree } from "../../components";
|
|
5
|
+
import { polarLayout, radialLayout, rectangularLayout } from "../../layouts";
|
|
6
|
+
import { Branches, BranchLabels } from "../../bauble-makers/makers";
|
|
7
|
+
|
|
8
|
+
const tree = ImmutableTree.fromNewick("((A:1,B:1):2,C:1);");
|
|
9
|
+
|
|
10
|
+
describe("Branch labels", () => {
|
|
11
|
+
test("renders a tree node labels", () => {
|
|
12
|
+
const fig = render(
|
|
13
|
+
<svg
|
|
14
|
+
width="400px"
|
|
15
|
+
height="400px"
|
|
16
|
+
data-testid="figure"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
>
|
|
19
|
+
<FigTree
|
|
20
|
+
width={400}
|
|
21
|
+
height={400}
|
|
22
|
+
tree={tree}
|
|
23
|
+
layout={rectangularLayout}
|
|
24
|
+
baubles={[
|
|
25
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
26
|
+
BranchLabels({ text: "Label!" }),
|
|
27
|
+
]}
|
|
28
|
+
/>
|
|
29
|
+
</svg>,
|
|
30
|
+
);
|
|
31
|
+
//fig.debug();
|
|
32
|
+
expect(fig).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
test("renders a tree with aligned Node labels and a function for text", () => {
|
|
35
|
+
const fig = render(
|
|
36
|
+
<svg
|
|
37
|
+
width="400px"
|
|
38
|
+
height="400px"
|
|
39
|
+
data-testid="figure"
|
|
40
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
41
|
+
>
|
|
42
|
+
<FigTree
|
|
43
|
+
width={400}
|
|
44
|
+
height={400}
|
|
45
|
+
tree={tree}
|
|
46
|
+
layout={rectangularLayout}
|
|
47
|
+
baubles={[
|
|
48
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
49
|
+
BranchLabels({ text: (n) => `${n.number}` }),
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
</svg>,
|
|
53
|
+
);
|
|
54
|
+
//fig.debug();
|
|
55
|
+
expect(fig).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
test("renders a tree branchlabels - polar", () => {
|
|
58
|
+
const fig = render(
|
|
59
|
+
<svg
|
|
60
|
+
width="400px"
|
|
61
|
+
height="400px"
|
|
62
|
+
data-testid="figure"
|
|
63
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
64
|
+
>
|
|
65
|
+
<FigTree
|
|
66
|
+
width={400}
|
|
67
|
+
height={400}
|
|
68
|
+
tree={tree}
|
|
69
|
+
layout={polarLayout}
|
|
70
|
+
baubles={[
|
|
71
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
72
|
+
BranchLabels({ text: "Label!" }),
|
|
73
|
+
]}
|
|
74
|
+
/>
|
|
75
|
+
</svg>,
|
|
76
|
+
);
|
|
77
|
+
//fig.debug();
|
|
78
|
+
expect(fig).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
test("renders a tree node labels in radial layout", () => {
|
|
81
|
+
const fig = render(
|
|
82
|
+
<svg
|
|
83
|
+
width="400px"
|
|
84
|
+
height="400px"
|
|
85
|
+
data-testid="figure"
|
|
86
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
87
|
+
>
|
|
88
|
+
<FigTree
|
|
89
|
+
width={400}
|
|
90
|
+
height={400}
|
|
91
|
+
tree={tree}
|
|
92
|
+
layout={radialLayout}
|
|
93
|
+
baubles={[
|
|
94
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
95
|
+
BranchLabels({ text: "Label!" }),
|
|
96
|
+
]}
|
|
97
|
+
/>
|
|
98
|
+
</svg>,
|
|
99
|
+
);
|
|
100
|
+
//fig.debug();
|
|
101
|
+
expect(fig).toMatchSnapshot();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
data-testid="figure"
|
|
3
|
+
height="400px"
|
|
4
|
+
width="400px"
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
>
|
|
7
|
+
<g>
|
|
8
|
+
<g
|
|
9
|
+
transform="translate(10,10)"
|
|
10
|
+
>
|
|
11
|
+
<g
|
|
12
|
+
class="branch-layer"
|
|
13
|
+
>
|
|
14
|
+
<path
|
|
15
|
+
d="M 0.001 237.5 C0.001,237.5 0,237.5 0,237.5 C0,237.5 0,237.5005 0,237.50074999999998 C0,237.50074999999998 0,237.500875 0,237.50093750000002 C0,237.50093750000002 0,237.50096875000003 0,237.50098437500003 C0,237.50098437500003 0,237.5009921875 0,237.50099609375002 C0,237.50099609375002 0,237.501 0,237.501 "
|
|
16
|
+
fill="none"
|
|
17
|
+
stroke="black"
|
|
18
|
+
stroke-width="2"
|
|
19
|
+
/>
|
|
20
|
+
<path
|
|
21
|
+
d="M 0.001 237.5 C0.001,237.5 0,95 0,95 C0,95 126.66666666666666,95.0005 190,95.00075000000001 C190,95.00075000000001 221.66666666666666,95.00087500000001 237.5,95.0009375 C237.5,95.0009375 245.41666666666666,95.00096875 249.375,95.000984375 C249.375,95.000984375 251.35416666666666,95.0009921875 252.34375,95.00099609375 C252.34375,95.00099609375 253.33333333333331,95.001 253.33333333333331,95.001 "
|
|
22
|
+
fill="none"
|
|
23
|
+
stroke="black"
|
|
24
|
+
stroke-width="2"
|
|
25
|
+
/>
|
|
26
|
+
<path
|
|
27
|
+
d="M 253.33433333333332 95 C253.33433333333332,95 253.33333333333331,0 253.33333333333331,0 C253.33333333333331,0 316.66666666666663,0.0005 348.3333333333333,0.00075 C348.3333333333333,0.00075 364.16666666666663,0.000875 372.0833333333333,0.0009375 C372.0833333333333,0.0009375 376.04166666666663,0.00096875 378.0208333333333,0.000984375 C378.0208333333333,0.000984375 379.01041666666663,0.0009921875 379.5052083333333,0.00099609375 C379.5052083333333,0.00099609375 380,0.001 380,0.001 "
|
|
28
|
+
fill="none"
|
|
29
|
+
stroke="black"
|
|
30
|
+
stroke-width="2"
|
|
31
|
+
/>
|
|
32
|
+
<path
|
|
33
|
+
d="M 253.33433333333332 95 C253.33433333333332,95 253.33333333333331,190 253.33333333333331,190 C253.33333333333331,190 316.66666666666663,190.0005 348.3333333333333,190.00074999999998 C348.3333333333333,190.00074999999998 364.16666666666663,190.000875 372.0833333333333,190.00093750000002 C372.0833333333333,190.00093750000002 376.04166666666663,190.00096875000003 378.0208333333333,190.00098437500003 C378.0208333333333,190.00098437500003 379.01041666666663,190.0009921875 379.5052083333333,190.00099609375002 C379.5052083333333,190.00099609375002 380,190.001 380,190.001 "
|
|
34
|
+
fill="none"
|
|
35
|
+
stroke="black"
|
|
36
|
+
stroke-width="2"
|
|
37
|
+
/>
|
|
38
|
+
<path
|
|
39
|
+
d="M 0.001 237.5 C0.001,237.5 0,380 0,380 C0,380 63.33333333333333,380.0005 95,380.00075 C95,380.00075 110.83333333333333,380.00087499999995 118.75,380.00093749999996 C118.75,380.00093749999996 122.70833333333333,380.00096874999997 124.6875,380.000984375 C124.6875,380.000984375 125.67708333333333,380.00099218749995 126.171875,380.00099609374996 C126.171875,380.00099609374996 126.66666666666666,380.001 126.66666666666666,380.001 "
|
|
40
|
+
fill="none"
|
|
41
|
+
stroke="black"
|
|
42
|
+
stroke-width="2"
|
|
43
|
+
/>
|
|
44
|
+
</g>
|
|
45
|
+
<g
|
|
46
|
+
class="node-label-layer"
|
|
47
|
+
>
|
|
48
|
+
<g>
|
|
49
|
+
<text
|
|
50
|
+
alignment-baseline="bottom"
|
|
51
|
+
text="Label!"
|
|
52
|
+
text-anchor="end"
|
|
53
|
+
transform="translate(-6,231.5) rotate(0)"
|
|
54
|
+
>
|
|
55
|
+
Label!
|
|
56
|
+
</text>
|
|
57
|
+
<path
|
|
58
|
+
d="M0 237.5L0 237.5"
|
|
59
|
+
stroke="grey"
|
|
60
|
+
stroke-dasharray="2"
|
|
61
|
+
stroke-width="1"
|
|
62
|
+
/>
|
|
63
|
+
</g>
|
|
64
|
+
<g>
|
|
65
|
+
<text
|
|
66
|
+
alignment-baseline="hanging"
|
|
67
|
+
text="Label!"
|
|
68
|
+
text-anchor="end"
|
|
69
|
+
transform="translate(247.33333333333331,101) rotate(0)"
|
|
70
|
+
>
|
|
71
|
+
Label!
|
|
72
|
+
</text>
|
|
73
|
+
<path
|
|
74
|
+
d="M253.33333333333331 95L253.33333333333331 95"
|
|
75
|
+
stroke="grey"
|
|
76
|
+
stroke-dasharray="2"
|
|
77
|
+
stroke-width="1"
|
|
78
|
+
/>
|
|
79
|
+
</g>
|
|
80
|
+
<g>
|
|
81
|
+
<text
|
|
82
|
+
alignment-baseline="middle"
|
|
83
|
+
text="Label!"
|
|
84
|
+
text-anchor="start"
|
|
85
|
+
transform="translate(386,0) rotate(0)"
|
|
86
|
+
>
|
|
87
|
+
Label!
|
|
88
|
+
</text>
|
|
89
|
+
<path
|
|
90
|
+
d="M380 0L380 0"
|
|
91
|
+
stroke="grey"
|
|
92
|
+
stroke-dasharray="2"
|
|
93
|
+
stroke-width="1"
|
|
94
|
+
/>
|
|
95
|
+
</g>
|
|
96
|
+
<g>
|
|
97
|
+
<text
|
|
98
|
+
alignment-baseline="middle"
|
|
99
|
+
text="Label!"
|
|
100
|
+
text-anchor="start"
|
|
101
|
+
transform="translate(386,190) rotate(0)"
|
|
102
|
+
>
|
|
103
|
+
Label!
|
|
104
|
+
</text>
|
|
105
|
+
<path
|
|
106
|
+
d="M380 190L380 190"
|
|
107
|
+
stroke="grey"
|
|
108
|
+
stroke-dasharray="2"
|
|
109
|
+
stroke-width="1"
|
|
110
|
+
/>
|
|
111
|
+
</g>
|
|
112
|
+
<g>
|
|
113
|
+
<text
|
|
114
|
+
alignment-baseline="middle"
|
|
115
|
+
text="Label!"
|
|
116
|
+
text-anchor="start"
|
|
117
|
+
transform="translate(132.66666666666666,380) rotate(0)"
|
|
118
|
+
>
|
|
119
|
+
Label!
|
|
120
|
+
</text>
|
|
121
|
+
<path
|
|
122
|
+
d="M126.66666666666666 380L126.66666666666666 380"
|
|
123
|
+
stroke="grey"
|
|
124
|
+
stroke-dasharray="2"
|
|
125
|
+
stroke-width="1"
|
|
126
|
+
/>
|
|
127
|
+
</g>
|
|
128
|
+
</g>
|
|
129
|
+
</g>
|
|
130
|
+
</g>
|
|
131
|
+
</svg>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { describe, test } from "vitest";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import { ImmutableTree } from "../../evo";
|
|
4
|
+
import { FigTree } from "../../components";
|
|
5
|
+
import { polarLayout, radialLayout, rectangularLayout } from "../../layouts";
|
|
6
|
+
import { Branches, NodeLabels } from "../../bauble-makers/makers";
|
|
7
|
+
|
|
8
|
+
const tree = ImmutableTree.fromNewick("((A:1,B:1):2,C:1);");
|
|
9
|
+
|
|
10
|
+
describe("Node labels", () => {
|
|
11
|
+
test("renders a tree node labels", () => {
|
|
12
|
+
const fig = render(
|
|
13
|
+
<svg
|
|
14
|
+
width="400px"
|
|
15
|
+
height="400px"
|
|
16
|
+
data-testid="figure"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
>
|
|
19
|
+
<FigTree
|
|
20
|
+
width={400}
|
|
21
|
+
height={400}
|
|
22
|
+
tree={tree}
|
|
23
|
+
layout={rectangularLayout}
|
|
24
|
+
baubles={[
|
|
25
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
26
|
+
NodeLabels({ text: "Label!" }),
|
|
27
|
+
]}
|
|
28
|
+
/>
|
|
29
|
+
</svg>,
|
|
30
|
+
);
|
|
31
|
+
//fig.debug();
|
|
32
|
+
expect(fig).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
test("renders a tree with aligned Node labels and a function for text", () => {
|
|
35
|
+
const fig = render(
|
|
36
|
+
<svg
|
|
37
|
+
width="400px"
|
|
38
|
+
height="400px"
|
|
39
|
+
data-testid="figure"
|
|
40
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
41
|
+
>
|
|
42
|
+
<FigTree
|
|
43
|
+
width={400}
|
|
44
|
+
height={400}
|
|
45
|
+
tree={tree}
|
|
46
|
+
layout={rectangularLayout}
|
|
47
|
+
baubles={[
|
|
48
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
49
|
+
NodeLabels({ text: (n) => `${n.number}`, aligned: true }),
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
</svg>,
|
|
53
|
+
);
|
|
54
|
+
//fig.debug();
|
|
55
|
+
expect(fig).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
test("renders a tree node labels - polar", () => {
|
|
58
|
+
const fig = render(
|
|
59
|
+
<svg
|
|
60
|
+
width="400px"
|
|
61
|
+
height="400px"
|
|
62
|
+
data-testid="figure"
|
|
63
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
64
|
+
>
|
|
65
|
+
<FigTree
|
|
66
|
+
width={400}
|
|
67
|
+
height={400}
|
|
68
|
+
tree={tree}
|
|
69
|
+
layout={polarLayout}
|
|
70
|
+
baubles={[
|
|
71
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
72
|
+
NodeLabels({ text: "Label!" }),
|
|
73
|
+
]}
|
|
74
|
+
/>
|
|
75
|
+
</svg>,
|
|
76
|
+
);
|
|
77
|
+
//fig.debug();
|
|
78
|
+
expect(fig).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
test("renders a tree with aligned Node labels and a function for text - polar", () => {
|
|
81
|
+
const fig = render(
|
|
82
|
+
<svg
|
|
83
|
+
width="400px"
|
|
84
|
+
height="400px"
|
|
85
|
+
data-testid="figure"
|
|
86
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
87
|
+
>
|
|
88
|
+
<FigTree
|
|
89
|
+
width={400}
|
|
90
|
+
height={400}
|
|
91
|
+
tree={tree}
|
|
92
|
+
layout={polarLayout}
|
|
93
|
+
baubles={[
|
|
94
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
95
|
+
NodeLabels({ text: (n) => `${n.number}`, aligned: true }),
|
|
96
|
+
]}
|
|
97
|
+
/>
|
|
98
|
+
</svg>,
|
|
99
|
+
);
|
|
100
|
+
//fig.debug();
|
|
101
|
+
expect(fig).toMatchSnapshot();
|
|
102
|
+
});
|
|
103
|
+
test("renders a tree node labels in radial layout", () => {
|
|
104
|
+
const fig = render(
|
|
105
|
+
<svg
|
|
106
|
+
width="400px"
|
|
107
|
+
height="400px"
|
|
108
|
+
data-testid="figure"
|
|
109
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
110
|
+
>
|
|
111
|
+
<FigTree
|
|
112
|
+
width={400}
|
|
113
|
+
height={400}
|
|
114
|
+
tree={tree}
|
|
115
|
+
layout={radialLayout}
|
|
116
|
+
baubles={[
|
|
117
|
+
Branches({ attrs: { strokeWidth: 2, stroke: "black" } }),
|
|
118
|
+
NodeLabels({ text: "Label!" }),
|
|
119
|
+
]}
|
|
120
|
+
/>
|
|
121
|
+
</svg>,
|
|
122
|
+
);
|
|
123
|
+
//fig.debug();
|
|
124
|
+
expect(fig).toMatchSnapshot();
|
|
125
|
+
});
|
|
126
|
+
});
|