-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathdata.js
29 lines (25 loc) · 840 Bytes
/
data.js
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
export default function() {
return this._data || null;
}
export function isEdgeElementParent(datum) {
return (datum.attributes.class == 'edge' || (
datum.tag == 'a' &&
datum.parent.tag == 'g' &&
datum.parent.parent.attributes.class == 'edge'
));
}
export function isEdgeElement(datum) {
return datum.parent && isEdgeElementParent(datum.parent);
}
export function getEdgeGroup(datum) {
if (datum.parent.attributes.class == 'edge') {
return datum.parent;
} else { // datum.parent.tag == 'g' && datum.parent.parent.tag == 'g' && datum.parent.parent.parent.attributes.class == 'edge'
return datum.parent.parent.parent;
}
}
export function getEdgeTitle(datum) {
return getEdgeGroup(datum).children.find(function (e) {
return e.tag == 'title';
});
}