Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MUR Drupal
d3-library
Commits
dba9baf2
Commit
dba9baf2
authored
Dec 20, 2012
by
Mike Bostock
Browse files
Remove force-dynamic example.
Replaced by <
http://bl.ocks.org/929623
>.
parent
3208345a
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/force/force-dynamic.html
deleted
100644 → 0
View file @
3208345a
<!DOCTYPE html>
<meta
charset=
"utf-8"
>
<title>
Force-Directed Layout (Dynamic)
</title>
<style>
rect
{
fill
:
#fff
;
}
.node
{
fill
:
#000
;
}
.cursor
{
fill
:
none
;
stroke
:
brown
;
pointer-events
:
none
;
}
.link
{
stroke
:
#999
;
}
</style>
<body>
<script
src=
"../../d3.js"
></script>
<script>
var
width
=
960
,
height
=
500
,
fill
=
d3
.
scale
.
category20
(),
nodes
=
[],
links
=
[];
var
svg
=
d3
.
select
(
"
body
"
).
append
(
"
svg
"
)
.
attr
(
"
width
"
,
width
)
.
attr
(
"
height
"
,
height
);
svg
.
append
(
"
rect
"
)
.
attr
(
"
width
"
,
width
)
.
attr
(
"
height
"
,
height
);
var
force
=
d3
.
layout
.
force
()
.
distance
(
30
)
.
nodes
(
nodes
)
.
links
(
links
)
.
size
([
width
,
height
]);
var
cursor
=
svg
.
append
(
"
circle
"
)
.
attr
(
"
r
"
,
30
)
.
attr
(
"
transform
"
,
"
translate(-100,-100)
"
)
.
attr
(
"
class
"
,
"
cursor
"
);
force
.
on
(
"
tick
"
,
function
()
{
svg
.
selectAll
(
"
line.link
"
)
.
attr
(
"
x1
"
,
function
(
d
)
{
return
d
.
source
.
x
;
})
.
attr
(
"
y1
"
,
function
(
d
)
{
return
d
.
source
.
y
;
})
.
attr
(
"
x2
"
,
function
(
d
)
{
return
d
.
target
.
x
;
})
.
attr
(
"
y2
"
,
function
(
d
)
{
return
d
.
target
.
y
;
});
svg
.
selectAll
(
"
circle.node
"
)
.
attr
(
"
cx
"
,
function
(
d
)
{
return
d
.
x
;
})
.
attr
(
"
cy
"
,
function
(
d
)
{
return
d
.
y
;
});
});
svg
.
on
(
"
mousemove
"
,
function
()
{
cursor
.
attr
(
"
transform
"
,
"
translate(
"
+
d3
.
mouse
(
this
)
+
"
)
"
);
});
svg
.
on
(
"
mousedown
"
,
function
()
{
var
point
=
d3
.
mouse
(
this
),
node
=
{
x
:
point
[
0
],
y
:
point
[
1
]},
n
=
nodes
.
push
(
node
);
// add links to any nearby nodes
nodes
.
forEach
(
function
(
target
)
{
var
x
=
target
.
x
-
node
.
x
,
y
=
target
.
y
-
node
.
y
;
if
(
Math
.
sqrt
(
x
*
x
+
y
*
y
)
<
30
)
{
links
.
push
({
source
:
node
,
target
:
target
});
}
});
restart
();
});
restart
();
function
restart
()
{
force
.
start
();
svg
.
selectAll
(
"
line.link
"
)
.
data
(
links
)
.
enter
().
insert
(
"
line
"
,
"
circle.node
"
)
.
attr
(
"
class
"
,
"
link
"
)
.
attr
(
"
x1
"
,
function
(
d
)
{
return
d
.
source
.
x
;
})
.
attr
(
"
y1
"
,
function
(
d
)
{
return
d
.
source
.
y
;
})
.
attr
(
"
x2
"
,
function
(
d
)
{
return
d
.
target
.
x
;
})
.
attr
(
"
y2
"
,
function
(
d
)
{
return
d
.
target
.
y
;
});
svg
.
selectAll
(
"
circle.node
"
)
.
data
(
nodes
)
.
enter
().
insert
(
"
circle
"
,
"
circle.cursor
"
)
.
attr
(
"
class
"
,
"
node
"
)
.
attr
(
"
cx
"
,
function
(
d
)
{
return
d
.
x
;
})
.
attr
(
"
cy
"
,
function
(
d
)
{
return
d
.
y
;
})
.
attr
(
"
r
"
,
4.5
)
.
call
(
force
.
drag
);
}
</script>
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