-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
125 lines (104 loc) · 2.7 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<script src="https://unpkg.com/d3-path"></script>
<script src="https://unpkg.com/d3-shape"></script>
<script src="https://unpkg.com/d3-curve-circlecorners"></script>
<style>
svg {
display: block;
margin: 0.5em 0;
background-color: #eee;
}
svg path {
fill: none;
stroke-width: 0.1;
}
svg path#first {
stroke: red;
}
svg path#second {
stroke: blue;
}
svg path#third {
stroke: green;
}
svg path#fourth {
stroke: purple;
}
</style>
<h1><code>d3-curve-circlecorners</code> Demo Page</h1>
<h2>Multiple Segments, Longer than the Curve Radius (0.5)</h2>
<code> [ [2, 1], [2, 4], [0, 4], [2, 6], [4, 6], [6, 5] ]</code>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0"
height="300px"
viewBox="0 0 10 10"
>
<path id="first" />
</svg>
<h2>Curve Radius Larger (3) than Some Segments</h2>
<p>Some nodes become quite sharp, at the expense of others</p>
<code> [ [2, 1], [2, 4], [0, 4], [2, 6], [4, 6], [6, 5] ]</code>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0"
height="300px"
viewBox="0 0 10 10"
>
<path id="second" />
</svg>
<h2>Two Segments</h2>
<code> [ [-2, 1.15], [-3.15, 1.15], [-3.15, -1] ]</code>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0"
height="300px"
viewBox="-5 -5 10 10"
>
<path id="third" />
</svg>
<h2>Overlapping Segments (BUG)</h2>
<code> [ [-1, -1], [-1, 0], [-1, -5], ]</code>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0"
height="300px"
viewBox="-5 -5 10 10"
>
<path id="fourth" />
</svg>
<script>
window.addEventListener('load', () => {
const data = [
[2, 1],
[2, 4],
[0, 4],
[2, 6],
[4, 6],
[6, 5],
];
const firstDrawing = d3.line().curve(circleCorners.radius(0.5))(data);
const secondDrawing = d3.line().curve(circleCorners.radius(3))(data);
const thirdDrawing = d3.line().curve(circleCorners.radius(0.65))([
[-2, 1.15],
[-3.15, 1.15],
[-3.15, -1],
]);
const fourthDrawing = d3.line().curve(circleCorners.radius(6))([
[-1, -1],
[-1, 0],
[-1, -5],
]);
document.getElementById('first').setAttribute('d', firstDrawing);
document.getElementById('second').setAttribute('d', secondDrawing);
document.getElementById('third').setAttribute('d', thirdDrawing);
document.getElementById('fourth').setAttribute('d', fourthDrawing);
});
</script>