-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata.js
61 lines (54 loc) · 1.89 KB
/
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
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
var dispatch = d3.dispatch("dataLoaded",
"highlight", "highlightgenre", "highlighttype", "unhighlight");
var meta;
drawNetwork();
function drawNetwork() {
d3.json('intertextual-gestures-mme.json').then( function(data) {
/* Create Map of distinct genre values with the bibliography IDs and MME
gestures to which they map. */
var totalExcerpts = 0,
genreGrp = new Map(),
qTypes = new Map();
meta = data;
meta['genres'] = new Map();
meta['gestures'].forEach( function(gesture) {
var myGenres = [],
sources = gesture.sources,
types = gesture.type;
// Build out map of reference types.
types.forEach( function(typeStr) {
var qTypeEntry = qTypes.get(typeStr) || [];
qTypeEntry.push(gesture);
qTypes.set(typeStr, qTypeEntry);
});
// Build out map of broad genres.
sources.forEach( function(src) {
var genreGestures,
mainGenre = src['genreBroad'];
mainGenre = mainGenre === null ? 'unknown' : mainGenre;
genreGestures = meta['genres'].get(mainGenre);
// Once and once only, map this gesture to this genre.
if ( !myGenres.includes(mainGenre) ) {
// Make sure this genre exists before adding the gesture.
if ( genreGestures === undefined ) {
genreGestures = meta['genres']
.set(mainGenre, [])
.get(mainGenre);
}
genreGestures.push(gesture);
myGenres.push(mainGenre);
}
});
gesture.id = totalExcerpts;
totalExcerpts++;
});
meta['types'] = qTypes;
console.log(meta);
dispatch.call("dataLoaded", null, meta);
});
};
function allowMouseover() {
var selection = d3.select('.selected.clicked'),
userAllowed = d3.select('#mouseover-control').property('checked');
return userAllowed && selection.empty();
};