author | ymh <ymh.work@gmail.com> |
Fri, 09 Dec 2016 11:41:15 +0100 | |
changeset 467 | 762fc0eb4946 |
parent 424 | feb0d3e0fef9 |
child 532 | 1190ea937f2d |
permissions | -rw-r--r-- |
39
c693e8673d5b
add visu-langue with google treemap
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
2 |
import * as d3 from 'd3-selection'; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
3 |
import * as d3h from 'd3-hierarchy'; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
4 |
import * as d3s from 'd3-scale'; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
5 |
import * as d3t from 'd3-transition'; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
6 |
import * as d3e from 'd3-ease'; |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
123
diff
changeset
|
7 |
import _ from 'lodash/lodash'; |
39
c693e8673d5b
add visu-langue with google treemap
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
8 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
9 |
// inspired by http://bl.ocks.org/ganeshv/6a8e9ada3ab7f2d88022 |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
10 |
// and https://bost.ocks.org/mike/treemap/ |
39
c693e8673d5b
add visu-langue with google treemap
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
11 |
export default Ember.Component.extend({ |
188
d2cb39155997
/langue endpoint ID querystring parameter
Chloe Laisne <chloe.laisne@gmail.com>
parents:
142
diff
changeset
|
12 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
13 |
constants: Ember.inject.service(), |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
14 |
filter: Ember.inject.service(), |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
15 |
colors: Ember.inject.service(), |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
16 |
utils: Ember.inject.service(), |
188
d2cb39155997
/langue endpoint ID querystring parameter
Chloe Laisne <chloe.laisne@gmail.com>
parents:
142
diff
changeset
|
17 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
18 |
scale: Ember.computed('maxCount', 'minCount', function () { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
19 |
let maxCount = this.get('maxCount'); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
20 |
let minCount = this.get('minCount'); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
21 |
return this.get('colors').getScaleLinear(minCount, maxCount); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
22 |
}), |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
23 |
maxCount: 0, |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
24 |
minCount: 0, |
295
e1f154f20f96
Add selected state to treemap
Chloe Laisne <chloe.laisne@gmail.com>
parents:
294
diff
changeset
|
25 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
26 |
firstRender: true, |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
27 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
28 |
filterLanguageObserver: Ember.observer('filter.language', function () { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
29 |
Ember.$('.node').removeClass("selected"); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
30 |
Ember.$('.node[data-id="' + this.get('filter').get('language') + '"]').addClass("selected"); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
31 |
}), |
84 | 32 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
33 |
filterOtherModified: false, |
84 | 34 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
35 |
filterOtherObserver: Ember.observer('filter.date.[]', 'filter.discourse.[]', 'filter.theme.[]', 'filter.location', function() { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
36 |
this.set('filterOtherModified', true); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
37 |
this.set('firstRender', true); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
38 |
}), |
305
ff6cf3fc5f40
api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents:
295
diff
changeset
|
39 |
|
84 | 40 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
41 |
didRender: function () { |
84 | 42 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
43 |
if(!this.get('filterOtherModified') && !this.get('firstRender')) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
44 |
return; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
45 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
46 |
this.set('firstRender', false); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
47 |
this.set('filterOtherModified', false); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
48 |
var self = this; |
84 | 49 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
50 |
var margin = { top: 30, right: 0, bottom: 0, left: 0 }; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
51 |
var width = Ember.$('#' + this.get('elementId')).width(); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
52 |
var height = Ember.$('#' + this.get('elementId')).height() - margin.top - margin.bottom; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
53 |
var ratio = (1+Math.sqrt(5))/2; |
84 | 54 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
55 |
var languages = this.get('languages'); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
56 |
var languagesMap = languages.reduce(function (res, l) { res[l.get('id')] = l.get('count'); return res; }, {}); |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
123
diff
changeset
|
57 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
58 |
var treemap = d3h.treemap() |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
59 |
.size([width/ratio, height]) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
60 |
.tile(d3h.treemapSquarify.ratio(1)); |
84 | 61 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
62 |
var element = d3.select('#' + this.get('elementId')) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
63 |
.style("width", width + margin.left + margin.right + 'px') |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
64 |
.style("height", height + margin.bottom + margin.top + 'px') |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
65 |
.style("margin-left", -margin.left + "px") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
66 |
.style("margin-right", -margin.right + "px"); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
67 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
68 |
var breadcrumbs = element.select("div.breadcrumbs"); |
84 | 69 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
70 |
if(breadcrumbs.empty()) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
71 |
breadcrumbs = element.insert("div", ":first-child") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
72 |
.attr("class", "breadcrumbs") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
73 |
.attr("y", -margin.top) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
74 |
.style("width", width + 'px') |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
75 |
.style("height", margin.top + 'px'); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
76 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
77 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
78 |
var root = _.cloneDeep(this.constants.LANGUAGES_TREEMAP); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
79 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
80 |
function ancestors(d) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
81 |
let ancestors = []; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
82 |
let currentNode = d; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
83 |
while (currentNode.parent) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
84 |
ancestors.unshift(currentNode = currentNode.parent); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
85 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
86 |
return ancestors; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
87 |
} |
84 | 88 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
89 |
// This function set the count and parent attributes |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
90 |
function decorateData(d) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
91 |
if (d.children) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
92 |
d.count = d.children.reduce(function (p, v) { v.parent = d; return p + decorateData(v); }, 0); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
93 |
} else if (d.values) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
94 |
d.count = d.values.reduce(function (p, v) { return p + (languagesMap[v] ? languagesMap[v] : 0); }, 0); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
95 |
} else { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
96 |
d.count = languagesMap[d.id] ? languagesMap[d.id] : 0; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
97 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
98 |
return d.count; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
99 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
100 |
decorateData(root); |
188
d2cb39155997
/langue endpoint ID querystring parameter
Chloe Laisne <chloe.laisne@gmail.com>
parents:
142
diff
changeset
|
101 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
102 |
// Clean tree with empty nodes |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
103 |
function cleanTree(n) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
104 |
if(n.children) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
105 |
n.children = n.children.filter(function(c) { return c.count !== 0;}); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
106 |
n.children.forEach(function(c) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
107 |
cleanTree(c); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
108 |
}); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
109 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
110 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
111 |
cleanTree(root); |
84 | 112 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
113 |
var transitioning = false; |
261
02e2396bcbbc
Migrate to ember 2.7 + correct jquery null context error + declare shim for popcorn (instead of silencing the JSHint error)
ymh <ymh.work@gmail.com>
parents:
198
diff
changeset
|
114 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
115 |
display(root, 1); |
84 | 116 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
117 |
function transition(d, node, nodeWrapper) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
118 |
if (transitioning || !d) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
119 |
return; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
120 |
} |
84 | 121 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
122 |
selectHandler(d); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
123 |
transitioning = true; |
84 | 124 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
125 |
var t = d3t.transition().duration(750).ease(d3e.easeLinear); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
126 |
var newNode = display(d, 0); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
127 |
var transitionNodes = node.transition(t); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
128 |
var transitionNewNodes = newNode.transition(t); |
84 | 129 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
130 |
newNode.style("fill-opacity", 0); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
131 |
transitionNodes.style("opacity", 0).remove().on("end", function () { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
132 |
nodeWrapper.remove(); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
133 |
transitioning = false; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
134 |
}); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
135 |
transitionNewNodes.style("opacity", 1); |
84 | 136 |
|
188
d2cb39155997
/langue endpoint ID querystring parameter
Chloe Laisne <chloe.laisne@gmail.com>
parents:
142
diff
changeset
|
137 |
} |
d2cb39155997
/langue endpoint ID querystring parameter
Chloe Laisne <chloe.laisne@gmail.com>
parents:
142
diff
changeset
|
138 |
|
467
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
139 |
function selectHandler(d) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
140 |
if (d.id) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
141 |
self.get('filter').setFilter('language', d.id); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
142 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
143 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
144 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
145 |
function display(rData, opacity) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
146 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
147 |
var countArray = rData.children.map(function (d) { return d.count; }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
148 |
var dMin = Math.min.apply(null, countArray); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
149 |
var dMax = Math.max.apply(null, countArray); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
150 |
var globalMin = rData.children.reduce(function minRec(m, c) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
151 |
if(c.count < m) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
152 |
m = c.count; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
153 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
154 |
if(c.children) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
155 |
m = c.children.reduce(minRec, m); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
156 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
157 |
return m; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
158 |
}, dMax); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
159 |
var dataScale = d3s.scaleLinear().domain([globalMin, dMax]).range([globalMin, dMax]); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
160 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
161 |
var nameArray = rData.children.reduce(function (res, d) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
162 |
res = res.concat(d.name.split(/[\s\-]/)); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
163 |
return res; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
164 |
}, ["(nnnnn)"]).sort(function(a,b) { return b.length - a.length; }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
165 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
166 |
var w = self.get('utils').getWidthOfText(nameArray[0], '11px'); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
167 |
var p = w*w/(width*height); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
168 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
169 |
if(dMin/dMax < p) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
170 |
dataScale = dataScale.range([p*100,100]); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
171 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
172 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
173 |
var rNode = d3h.hierarchy(rData) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
174 |
.sum(function (d) { return (d.children) ? 0 : dataScale(d.count); }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
175 |
.sort(function (a, b) { return b.value - a.value; }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
176 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
177 |
self.setProperties({ minCount: dMin, maxCount: dMax }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
178 |
var scale = self.get('scale'); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
179 |
var backgroundColor = function (_d) { return scale(_d.data.count); }; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
180 |
var colorClass = function (_d) { return (self.get('colors').getPerceptiveLuminance(backgroundColor(_d)) >= 0.5) ? 'light-color' : 'dark-color'; }; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
181 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
182 |
var nodeWrapper = element.append("div") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
183 |
.attr("class", "nodes") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
184 |
.datum(rNode); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
185 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
186 |
var descendants = treemap(rNode).descendants().filter(function (c) { return c.depth === rNode.depth + 1; }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
187 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
188 |
var node = nodeWrapper.selectAll() |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
189 |
.data(descendants) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
190 |
.enter() |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
191 |
.append("div") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
192 |
.attr("data-id", function (d) { return d.data.id; }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
193 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
194 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
195 |
node.attr("class", function (_d) { return "node " + colorClass(_d) + (_d.id === self.get('filter').get('language') ? " selected" : ""); }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
196 |
.style("width", function (d) { return (Math.round(d.x1 * ratio) - Math.round(d.x0 * ratio)) + 'px'; }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
197 |
.style("height", function (d) { return (d.y1 - d.y0) + 'px'; }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
198 |
.style("left", function (d) { return Math.round(d.x0*ratio) + 'px'; }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
199 |
.style("top", function (d) { return d.y0 + 'px'; }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
200 |
.style("background-color", backgroundColor) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
201 |
.style('opacity', opacity) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
202 |
.attr('title', function (d) { return d.data.name + ' (' + d.data.count + ')'; }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
203 |
.on("click", function (d) { selectHandler(d.data); }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
204 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
205 |
node.filter(function (d) { return d.children; }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
206 |
.classed("children", true) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
207 |
.on("click", function (d) { transition(d.data, node, nodeWrapper); }) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
208 |
.append("i") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
209 |
.attr("class", "fa fa-folder-o"); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
210 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
211 |
node.append("span") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
212 |
.html(function (d) { return d.data.name + ' <span class="count">(' + d.data.count + ')</span>'; }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
213 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
214 |
breadcrumbs |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
215 |
.selectAll("span") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
216 |
.remove(); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
217 |
let i = 0; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
218 |
ancestors(rNode.data).forEach(function (a) { |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
219 |
breadcrumbs |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
220 |
.append("span") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
221 |
.attr('class', (i++) ? "level" : "root") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
222 |
.html(a.name) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
223 |
.datum(a) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
224 |
.on("click", function (d) { transition(d, node, nodeWrapper); }); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
225 |
}); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
226 |
breadcrumbs |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
227 |
.append("span") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
228 |
.attr('class', (i) ? "level" : "root") |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
229 |
.html(rNode.data.name) |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
230 |
.datum(rNode.data); |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
231 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
232 |
return node; |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
233 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
234 |
|
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
235 |
} |
762fc0eb4946
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents:
424
diff
changeset
|
236 |
|
39
c693e8673d5b
add visu-langue with google treemap
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
237 |
}); |