-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindexHeatMap.html
More file actions
146 lines (117 loc) · 3.98 KB
/
Copy pathindexHeatMap.html
File metadata and controls
146 lines (117 loc) · 3.98 KB
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
141
142
143
144
145
146
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Heat Map.</title>
<script type="text/javascript" src="d3/d3.v3.js"></script>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://d3js.org/colorbrewer.v1.min.js"></script>
<script type="text/javascript" src="jsCode/heatMap.js"></script>
<link rel="stylesheet" type="text/css" href="css/styleHeatMap.css">
</head>
<body>
<div id = "buttonsUnit">
<div class = "unit-button">
<input type="radio" name="unit" id ="button4" checked onclick = "setUnitPercent()">
<label for = "button4" unselectable> %</label>
</div>
<div class = "unit-button">
<input type="radio" name="unit" id ="button5" onclick = "setUnitRate()">
<label for = "button5" unselectable> Rate</label>
</div>
<div class = "unit-button">
<input type="radio" name="unit" id ="button6" onclick = "setUnitNum()">
<label for = "button6" unselectable> #</label>
</div>
</div>
<form>
<select id="menuYear" onchange="setYear(this.form.menuYear)">
<option>2000</option>
<option>2001</option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
<option>2007</option>
<option>2008</option>
<option>2009</option>
</select>
</form>
<div id = "popBar"> </div>
<script type = "text/javascript">
//Borders, margins and sizes
var margin = {top: 20, right: 20, bottom: 20, left: 20};
var legend = {top: 10, right: 10, bottom: 50, left: 50};
var widthWhole = 1050 - (margin.right + margin.left);
var heightWhole = 500 - (margin.bottom+ margin.top);
var width = 550 - (margin.right+ margin.left + legend.right + legend.left);
var height = 425 - (margin.top +margin.bottom+ legend.top + legend.bottom);
var legendBarSpace = 15, labelBarSpace = 15;
var widthBar = 130 - labelBarSpace;//widthWhole - width - 2*(margin.left+margin.right) -50; //around250
var heightBar = 100 - legendBarSpace;
var legendLeft = legend.left;
var legendTop = legend.top;
var legendBottom = legend.bottom;
var buckets = 10;
//THE SCALES
var space = .03;
var xScale = d3.scale
.ordinal()
.rangeRoundBands([0, width],space);
var yScale = d3.scale
.ordinal()
.rangeRoundBands([0, height], space);
var colorScale = d3.scale
.quantile()
.range(["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"]) //GnBu
.range(colorbrewer.YlGnBu[buckets - 1])
.range(colorbrewer.YlOrBr[buckets - 1]);
var colorScaleBar = d3.scale
.ordinal()
.range(["red", "blue"]);
//SCALES FOR THE BAR GRAPH
var spaceBar = .1,spaceBarInner = 0.1;
var xScaleBar = d3.scale
.ordinal() //is this the pixel, we should translate the whole part of it
.rangeRoundBands([0, widthBar],spaceBar);
var xScaleBarInner = d3.scale
.ordinal();
var yScaleBar = d3.scale
.linear()
.range([5, heightBar], spaceBar);
//GLOBAL VARIABLE FOR THE DATA
var currentCause = "Other causes of death";
var currentAge = "60 to 64 years";
var currentYear = 2000;
var currentUnit = "Number";
var filteredDatasetBAR = [];
var dataset = [];
var filteredDatasetHM = [];
selected =new Object();
//SVG ELEMENT
var svg = d3.select("body")
.append("svg")
.attr("width", widthWhole)
.attr("height", heightWhole);
var heatMap = svg.append("g")
.attr("class", "heatmap")
.attr("transform", "translate(" + legendLeft + ", "+ legendTop + ")");
var legendHM = svg.append("g")
.attr("class", "legend");
var labelHM = svg.append("g")
.attr("class", "label");
var svgPop = d3.select("#popBar")
.append("svg")
.attr("width", widthBar + labelBarSpace)
.attr("height", heightBar + legendBarSpace);
var barChart = svgPop.append("g")
.attr("class", "barChart");
var legendB = svgPop.append("g")
.attr("class", "legend");
var labelB = svgPop.append("g")
.attr("class", "label");
</script>
</body>
</html>