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
3bd33a55
Commit
3bd33a55
authored
Jul 01, 2013
by
Mike Bostock
Browse files
Merge branch 'append-or-insert-function' into 3.2.3
parents
2db1fe85
a27d2d36
Changes
9
Hide whitespace changes
Inline
Side-by-side
d3.js
View file @
3bd33a55
...
...
@@ -484,7 +484,7 @@ d3 = function() {
var
d3_selectionPrototype
=
d3
.
selection
.
prototype
=
[];
d3_selectionPrototype
.
select
=
function
(
selector
)
{
var
subgroups
=
[],
subgroup
,
subnode
,
group
,
node
;
if
(
typeof
selector
!==
"
function
"
)
selector
=
d3_selection_selector
(
selector
);
selector
=
d3_selection_selector
(
selector
);
for
(
var
j
=
-
1
,
m
=
this
.
length
;
++
j
<
m
;
)
{
subgroups
.
push
(
subgroup
=
[]);
subgroup
.
parentNode
=
(
group
=
this
[
j
]).
parentNode
;
...
...
@@ -500,13 +500,13 @@ d3 = function() {
return
d3_selection
(
subgroups
);
};
function
d3_selection_selector
(
selector
)
{
return
function
()
{
return
typeof
selector
===
"
function
"
?
selector
:
function
()
{
return
d3_select
(
selector
,
this
);
};
}
d3_selectionPrototype
.
selectAll
=
function
(
selector
)
{
var
subgroups
=
[],
subgroup
,
node
;
if
(
typeof
selector
!==
"
function
"
)
selector
=
d3_selection_selectorAll
(
selector
);
selector
=
d3_selection_selectorAll
(
selector
);
for
(
var
j
=
-
1
,
m
=
this
.
length
;
++
j
<
m
;
)
{
for
(
var
group
=
this
[
j
],
i
=
-
1
,
n
=
group
.
length
;
++
i
<
n
;
)
{
if
(
node
=
group
[
i
])
{
...
...
@@ -518,7 +518,7 @@ d3 = function() {
return
d3_selection
(
subgroups
);
};
function
d3_selection_selectorAll
(
selector
)
{
return
function
()
{
return
typeof
selector
===
"
function
"
?
selector
:
function
()
{
return
d3_selectAll
(
selector
,
this
);
};
}
...
...
@@ -696,25 +696,24 @@ d3 = function() {
})
:
this
.
node
().
innerHTML
;
};
d3_selectionPrototype
.
append
=
function
(
name
)
{
name
=
d3
.
ns
.
qualify
(
name
);
function
append
()
{
return
this
.
appendChild
(
d3_document
.
createElementNS
(
this
.
namespaceURI
,
name
));
}
function
appendNS
()
{
return
this
.
appendChild
(
d3_document
.
createElementNS
(
name
.
space
,
name
.
local
));
}
return
this
.
select
(
name
.
local
?
appendNS
:
append
);
name
=
d3_selection_creator
(
name
);
return
this
.
select
(
function
()
{
return
this
.
appendChild
(
name
.
apply
(
this
,
arguments
));
});
};
function
d3_selection_creator
(
name
)
{
return
typeof
name
===
"
function
"
?
name
:
(
name
=
d3
.
ns
.
qualify
(
name
)).
local
?
function
()
{
return
d3_document
.
createElementNS
(
name
.
space
,
name
.
local
);
}
:
function
()
{
return
d3_document
.
createElementNS
(
this
.
namespaceURI
,
name
);
};
}
d3_selectionPrototype
.
insert
=
function
(
name
,
before
)
{
name
=
d3
.
ns
.
qualify
(
name
);
if
(
typeof
before
!==
"
function
"
)
before
=
d3_selection_selector
(
before
);
function
insert
(
d
,
i
)
{
return
this
.
insertBefore
(
d3_document
.
createElementNS
(
this
.
namespaceURI
,
name
),
before
.
call
(
this
,
d
,
i
));
}
function
insertNS
(
d
,
i
)
{
return
this
.
insertBefore
(
d3_document
.
createElementNS
(
name
.
space
,
name
.
local
),
before
.
call
(
this
,
d
,
i
));
}
return
this
.
select
(
name
.
local
?
insertNS
:
insert
);
name
=
d3_selection_creator
(
name
);
before
=
d3_selection_selector
(
before
);
return
this
.
select
(
function
()
{
return
this
.
insertBefore
(
name
.
apply
(
this
,
arguments
),
before
.
apply
(
this
,
arguments
));
});
};
d3_selectionPrototype
.
remove
=
function
()
{
return
this
.
each
(
function
()
{
...
...
@@ -7444,7 +7443,7 @@ d3 = function() {
d3
.
transition
.
prototype
=
d3_transitionPrototype
;
d3_transitionPrototype
.
select
=
function
(
selector
)
{
var
id
=
this
.
id
,
subgroups
=
[],
subgroup
,
subnode
,
node
;
if
(
typeof
selector
!==
"
function
"
)
selector
=
d3_selection_selector
(
selector
);
selector
=
d3_selection_selector
(
selector
);
for
(
var
j
=
-
1
,
m
=
this
.
length
;
++
j
<
m
;
)
{
subgroups
.
push
(
subgroup
=
[]);
for
(
var
group
=
this
[
j
],
i
=
-
1
,
n
=
group
.
length
;
++
i
<
n
;
)
{
...
...
@@ -7461,7 +7460,7 @@ d3 = function() {
};
d3_transitionPrototype
.
selectAll
=
function
(
selector
)
{
var
id
=
this
.
id
,
subgroups
=
[],
subgroup
,
subnodes
,
node
,
subnode
,
transition
;
if
(
typeof
selector
!==
"
function
"
)
selector
=
d3_selection_selectorAll
(
selector
);
selector
=
d3_selection_selectorAll
(
selector
);
for
(
var
j
=
-
1
,
m
=
this
.
length
;
++
j
<
m
;
)
{
for
(
var
group
=
this
[
j
],
i
=
-
1
,
n
=
group
.
length
;
++
i
<
n
;
)
{
if
(
node
=
group
[
i
])
{
...
...
d3.min.js
View file @
3bd33a55
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/selection/append.js
View file @
3bd33a55
...
...
@@ -2,18 +2,15 @@ import "../core/document";
import
"
../core/ns
"
;
import
"
selection
"
;
// TODO append(node)?
// TODO append(function)?
d3_selectionPrototype
.
append
=
function
(
name
)
{
name
=
d3
.
ns
.
qualify
(
name
);
function
append
()
{
return
this
.
appendChild
(
d3_document
.
createElementNS
(
this
.
namespaceURI
,
name
));
}
function
appendNS
()
{
return
this
.
appendChild
(
d3_document
.
createElementNS
(
name
.
space
,
name
.
local
));
}
return
this
.
select
(
name
.
local
?
appendNS
:
append
);
name
=
d3_selection_creator
(
name
);
return
this
.
select
(
function
()
{
return
this
.
appendChild
(
name
.
apply
(
this
,
arguments
));
});
};
function
d3_selection_creator
(
name
)
{
return
typeof
name
===
"
function
"
?
name
:
(
name
=
d3
.
ns
.
qualify
(
name
)).
local
?
function
()
{
return
d3_document
.
createElementNS
(
name
.
space
,
name
.
local
);
}
:
function
()
{
return
d3_document
.
createElementNS
(
this
.
namespaceURI
,
name
);
};
}
src/selection/insert.js
View file @
3bd33a55
import
"
../core/document
"
;
import
"
../core/ns
"
;
import
"
selection
"
;
d3_selectionPrototype
.
insert
=
function
(
name
,
before
)
{
name
=
d3
.
ns
.
qualify
(
name
);
if
(
typeof
before
!==
"
function
"
)
before
=
d3_selection_selector
(
before
);
function
insert
(
d
,
i
)
{
return
this
.
insertBefore
(
d3_document
.
createElementNS
(
this
.
namespaceURI
,
name
),
before
.
call
(
this
,
d
,
i
));
}
function
insertNS
(
d
,
i
)
{
return
this
.
insertBefore
(
d3_document
.
createElementNS
(
name
.
space
,
name
.
local
),
before
.
call
(
this
,
d
,
i
));
}
return
this
.
select
(
name
.
local
?
insertNS
:
insert
);
name
=
d3_selection_creator
(
name
);
before
=
d3_selection_selector
(
before
);
return
this
.
select
(
function
()
{
return
this
.
insertBefore
(
name
.
apply
(
this
,
arguments
),
before
.
apply
(
this
,
arguments
));
});
};
src/selection/select.js
View file @
3bd33a55
...
...
@@ -7,7 +7,7 @@ d3_selectionPrototype.select = function(selector) {
group
,
node
;
if
(
typeof
selector
!==
"
function
"
)
selector
=
d3_selection_selector
(
selector
);
selector
=
d3_selection_selector
(
selector
);
for
(
var
j
=
-
1
,
m
=
this
.
length
;
++
j
<
m
;)
{
subgroups
.
push
(
subgroup
=
[]);
...
...
@@ -26,7 +26,7 @@ d3_selectionPrototype.select = function(selector) {
};
function
d3_selection_selector
(
selector
)
{
return
function
()
{
return
typeof
selector
===
"
function
"
?
selector
:
function
()
{
return
d3_select
(
selector
,
this
);
};
}
src/selection/selectAll.js
View file @
3bd33a55
...
...
@@ -6,7 +6,7 @@ d3_selectionPrototype.selectAll = function(selector) {
subgroup
,
node
;
if
(
typeof
selector
!==
"
function
"
)
selector
=
d3_selection_selectorAll
(
selector
);
selector
=
d3_selection_selectorAll
(
selector
);
for
(
var
j
=
-
1
,
m
=
this
.
length
;
++
j
<
m
;)
{
for
(
var
group
=
this
[
j
],
i
=
-
1
,
n
=
group
.
length
;
++
i
<
n
;)
{
...
...
@@ -21,7 +21,7 @@ d3_selectionPrototype.selectAll = function(selector) {
};
function
d3_selection_selectorAll
(
selector
)
{
return
function
()
{
return
typeof
selector
===
"
function
"
?
selector
:
function
()
{
return
d3_selectAll
(
selector
,
this
);
};
}
src/transition/select.js
View file @
3bd33a55
...
...
@@ -8,7 +8,7 @@ d3_transitionPrototype.select = function(selector) {
subnode
,
node
;
if
(
typeof
selector
!==
"
function
"
)
selector
=
d3_selection_selector
(
selector
);
selector
=
d3_selection_selector
(
selector
);
for
(
var
j
=
-
1
,
m
=
this
.
length
;
++
j
<
m
;)
{
subgroups
.
push
(
subgroup
=
[]);
...
...
src/transition/selectAll.js
View file @
3bd33a55
...
...
@@ -10,7 +10,7 @@ d3_transitionPrototype.selectAll = function(selector) {
subnode
,
transition
;
if
(
typeof
selector
!==
"
function
"
)
selector
=
d3_selection_selectorAll
(
selector
);
selector
=
d3_selection_selectorAll
(
selector
);
for
(
var
j
=
-
1
,
m
=
this
.
length
;
++
j
<
m
;)
{
for
(
var
group
=
this
[
j
],
i
=
-
1
,
n
=
group
.
length
;
++
i
<
n
;)
{
...
...
test/selection/append-test.js
View file @
3bd33a55
...
...
@@ -25,6 +25,12 @@ suite.addBatch({
assert
.
isTrue
(
svg
[
0
][
0
].
parentNode
===
body
.
node
());
assert
.
isTrue
(
svg
[
0
][
0
]
===
body
.
node
().
lastChild
);
},
"
appends an element specified as a function
"
:
function
(
body
)
{
var
svg
=
body
.
select
(
"
svg
"
).
remove
().
node
();
assert
.
isFalse
(
svg
===
body
.
node
().
lastChild
);
body
.
append
(
function
()
{
return
svg
;
});
assert
.
isTrue
(
svg
===
body
.
node
().
lastChild
);
},
"
propagates data to new element
"
:
function
(
body
)
{
var
data
=
new
Object
(),
div
=
body
.
data
([
data
]).
append
(
"
div
"
);
assert
.
strictEqual
(
div
[
0
][
0
].
__data__
,
data
);
...
...
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