-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
140 lines (122 loc) · 5.1 KB
/
index.html
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<html>
<head>
</head>
<body>
<style>
.tabs .table, .tabs .chart, .tabs .details{
display : none;
}
.tabs.table .table {
display : block;
}
.tabs.chart .chart {
display : block;
}
.tabs.details .details {
display : block;
}
.details-table td {
border : 1px solid black;
border-collapse : none;
}
table.content td {
border : none;
width: 50%;
}
table {
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
width:100%;
border-collapse:collapse;
}
table.details-table > tr > td, table th {
font-size:1.2em;
border:1px solid #98bf21;
padding:3px 7px 2px 7px;
}
table.details-table th.details-th {
font-size:1.4em;
text-align:left;
padding-top:5px;
padding-bottom:4px;
background-color:#A7C942;
color:#fff;
}
table.details-table tr.alt td {
color:#000;
background-color:#EAF2D3;
}
</style>
<div class="tabs chart" id="tabs">
<a href="#" onclick="document.getElementById('tabs').className = 'tabs chart';">chart</a>
<a href="#" onclick="document.getElementById('tabs').className = 'tabs table';">table</a>
<a href="#" onclick="document.getElementById('tabs').className = 'tabs details';">details</a>
<div id="body-table" class="table">
</div>
<div id="body-res" class="chart">
<div id="chart_div" style="width: 1300px; height: 800px;"></div>
</div>
<div id="body-details" class="details">
<div id="details"></div>
</div>
</div>
<script src="http://localhost:8899/require?query=CorrespondenceAnalysis/CorrespondenceAnalysis"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
var AC;
sand.require("CorrespondenceAnalysis/CorrespondenceAnalysis", function(r){
google.load("visualization", "1", {packages:["corechart", "table"]});
google.setOnLoadCallback(drawChartAndTable);
function drawChartAndTable() {
var data = google.visualization.arrayToDataTable([
['Lambda1', 'Lambda2']
].concat());
var dataTable = new google.visualization.DataTable();
dataTable.addColumn('string', 'ID');
dataTable.addColumn('number', 'Lambda1');
dataTable.addColumn('number', 'Lambda2');
dataTable.addColumn('string', 'Data Type');
var points = AC.getPoints().map(function(p){
//console.log([p.normCoords[0]].concat(p.label).concat( p.col ? [p.normCoords[1], null] : [null, p.normCoords[1]]));
return [p.label, p.normCoords[0], p.normCoords[1], !p.col ?"Town" : "Profession", p.population];
});
// A column for custom tooltip content
dataTable.addColumn('number','Population');
var getLegend = function(m, lgds){
var table = [];
return m.mapMatrix(function(cell, p, j){
table[j] || (table[j] = [], table[j].push(lgds[j]));
return {cell : cell, j : j, label : lgds[j]};
}).map(function(dim){
return "<table class='content'><tr>"+dim.map(function(a){
return "<tr><td>"+a.label+"</td><td>"+a.cell+"</td></tr>";
}).join("")+"</table>";
});
};
var legends = "<table class='details-table'><tr><td></td><th class='details-th'>Lamdba1</th><th class='details-th'>Lambda2</th></tr><tr><td>Studies</td><td>"
+ getLegend(AC.u_pj, AC.cLegends).join("</td><td>")
+"</td></tr><tr><td>Town</td><td>"
+ getLegend(AC.f_pi.mapMatrix(function(cell,p,i){return cell*Math.sqrt(AC.sumR[i]);}), AC.rLegends).join("</td><td>")
+"</td></tr><table>";
document.getElementById("details").innerHTML = legends;
var options = {
title: 'Correspondence Analysis',
hAxis: {title: 'Lambda1', viewWindowMode: null},
vAxis: {title: 'Lambda2', viewWindowMode: null},
bubble: {textStyle: {fontSize: 11}}
};
dataTable.addRows(points);
var chart = new google.visualization.BubbleChart(document.getElementById('chart_div'));
chart.draw(dataTable, options);
var iframe = document.createElement("iframe");
iframe.width = 2000;
iframe.height = 2000;
iframe.frameborder = 0;
iframe.scrolling = "no";
iframe.src = "https://spreadsheets.google.com/ccc?key="+AC.key+"&hl=en_GB&single=true&gid=0&output=html";
document.getElementById("body-table").appendChild(iframe);
}
AC = new r.CorrespondenceAnalysis({size : 500, font : '10px impact'});
});
</script>
</body>
</html>