-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
104 lines (79 loc) · 2.25 KB
/
index.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// var noUiSlider = require('nouislider');
// var d3 = require('d3');
// var NJ = require('neighbor-joining');
// Setup Elm app
var node = document.getElementById('cluster-form')
var app = Elm.Main.embed(node);
// Initialize D3 component
var piechart = piechart();
var parameters = parameters();
var histogram = histogram();
// Set parameters
var piechartRadius = 80;
var numColumn = 4;
var href = window.location.href;
var url = href.replace(/index.html/,'');
console.log(url);
// Get the data
var dataCluster = rawClusterData;
var taxoCluster = rawRankData;
console.log(dataCluster);
// var taxoClusterNull = taxoCluster.species.filter(function(d) {
// return (d.name === null || d.name === "");
// });
// console.log(taxoClusterNull);
// Create the slider
var slider = document.getElementById('slider-degre');
noUiSlider.create(slider, {
start: [1,2],
step: 1,
tooltips: [ true, true],
range: {
'min': [0],
'max': [10]
},
});
slider.noUiSlider.on('change', function(range){
app.ports.sliderChange.send({
'min' : parseInt(range[0]),
'max' : parseInt(range[1])
});
});
app.ports.dataClusters.send({
"distanceClusters" : dataCluster,
"taxonomicClusters": taxoCluster,
"displayedClusters" : undefined,
"parameters" : [ parametersData ],
});
app.ports.sliderRange.subscribe(function(range){
slider.noUiSlider.updateOptions({
range: {
'min': range[0],
'max': range[1]
}
});
});
app.ports.sliderValue.subscribe(function(range){
slider.noUiSlider.set(range);
});
app.ports.deletePies.subscribe(function(params){
d3.selectAll('g.piecharts').remove()
});
app.ports.draw.subscribe(function(params) {
var data = params[0];
var histoData = params[1];
d3
.select('svg')
.attr('width',function(d){
return (numColumn * (piechartRadius+200)) + 100;
})
.attr('height',function(d){
return ((data.length/numColumn) * (piechartRadius+150)) + 700;
});
d3.select('g.histogram').datum(histoData).call(histogram,500,500);
d3.select('g.clusters')
.attr('transform', "translate(0,400)")
.datum(data)
.call(piechart,piechartRadius,piechartRadius,numColumn, url);
});
// For the MashTree