Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
What's new
8
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
James Ramsey
circles_and_paths_d3
Commits
7a0a7c3a
Commit
7a0a7c3a
authored
Oct 17, 2020
by
James Ramsey
Browse files
Update stack.js
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
stack.js
0 → 100644
View file @
7a0a7c3a
var
data
=
[{
group
:
1
,
x
:
6
,
y
:
8
},
{
group
:
1
,
x
:
4
,
y
:
4
},
{
group
:
1
,
x
:
1
,
y
:
2
},
{
group
:
2
,
x
:
8
,
y
:
3
},
{
group
:
2
,
x
:
1
,
y
:
6
},
{
group
:
2
,
x
:
7
,
y
:
5
},
{
group
:
3
,
x
:
7
,
y
:
1
},
{
group
:
3
,
x
:
6
,
y
:
6
},
{
group
:
3
,
x
:
3
,
y
:
2
}];
var
height
=
600
var
width
=
800
var
svg
=
d3
.
select
(
"
body
"
)
.
append
(
"
svg
"
)
.
attr
(
"
height
"
,
"
100%
"
)
.
attr
(
"
width
"
,
"
100%
"
);
var
colours
=
[
"
#0000FF
"
,
"
#FF0000
"
,
"
#00FF00
"
];
var
line
=
d3
.
line
()
.
x
(
function
(
d
,
i
)
{
return
d
.
x
*
20
;
})
.
y
(
function
(
d
,
i
)
{
return
d
.
y
*
20
;
})
.
curve
(
d3
.
curveNatural
);
function
tweenDash
()
{
var
l
=
this
.
getTotalLength
(),
i
=
d3
.
interpolateString
(
"
0,
"
+
l
,
l
+
"
,
"
+
l
);
return
function
(
t
)
{
return
i
(
t
);
};
}
function
transition
(
selection
)
{
selection
.
each
(
function
()
{
d3
.
select
(
this
).
transition
()
.
duration
(
5000
)
.
attrTween
(
"
stroke-dasharray
"
,
tweenDash
)
.
ease
(
d3
.
easeLinear
);
})
}
var
dataGroup
=
d3
.
nest
()
.
key
(
function
(
d
)
{
return
d
.
group
;
})
.
entries
(
data
);
dataGroup
.
forEach
(
function
(
d
,
i
)
{
var
path
=
svg
.
append
(
"
path
"
)
.
attr
(
"
d
"
,
line
(
d
.
values
))
.
attr
(
"
stroke
"
,
colours
[
i
])
.
attr
(
"
stroke-width
"
,
1
)
.
attr
(
"
fill
"
,
"
none
"
);
transition
(
d3
.
selectAll
(
"
path
"
))
});
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment