-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
174 lines (149 loc) · 4.71 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.container {
text-align: center;
}
/*histogram panel*/
#top-states {
width: 100%;
height: 400px;
font-size: 11px;
}
/*map panel*/
.amcharts-chart-div{
z-index: 2; /*needs to be higher than legend so as to enable hover effect*/
}
.amcharts-legend-div{
z-index: 1
}
.map-box{
display:inline-block;
padding: 10px 15px 20px 0;
border: 1px solid #ddd;
background: #eee;
margin: 10px;
width:47%;
height:400px;
}
#wordcloud-panel {
width: 93%
border: 1px solid #ddd;
}
#mywordcloud {
margin: 10px 30px;
float: left;
}
</style>
<!-- histogram panel -->
<div id="top-states"></div>
<!-- map panel -->
<div class="container">
<div id="map-count" class="map-box"></div>
<div id="map-sentiment" class="map-box"></div>
</div>
<div id="wordcloud-panel">
<div id='mywordcloud'></div>
<br>
<select onchange="selectDestination(this);" id="select">
<option value="FL">Select a destination</option>
<option value="FL">Florida</option>
<option value="MIB"> Miami Beach</option>
<option value="ORD"> Orlando</option>
<option value="TP"> Tampa</option>
<option value="GA">Georgia</option>
<option value="GA"> Atlanta</option>
<option value="IA">Iowa</option>
<option value="ID">Idaho</option>
<option value="MA">Massachusetts</option>
<option value="MD">Maryland</option>
<option value="ME">Maine</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="SC">South Carolina</option>
<option value="MYB"> Myrtle Beach</option>
<option value="SD">South Dakota</option>
<option value="TX">Texas</option>
<option value="SPI"> South Padre Island</option>
<option value="FW"> Fort Worth</option>
<option value="TX"> Austin</option>
<option value="UT">Utah</option>
<option value="WV">West Virginia</option>
<option value="WY">Wyoming</option>
</select>
</div>
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<script src="https://www.amcharts.com/lib/3/ammap.js"></script>
<script src="https://www.amcharts.com/lib/3/maps/js/usaLow.js"></script>
<script src="lib/jquery-1.12.3.min.js"></script>
<script src="lib/d3/d3.js" charset="utf-8"></script>
<script src="lib/d3/d3.layout.cloud.js"></script>
<script src="lib/d3/d3.wordcloud.js"></script>
<!-- make sure data is loaded before js/* -->
<script src="data/histogramData.js"></script>
<script src="data/mapData.js"></script>
<script src="data/textByState.js" charset="utf-8"></script>
<script src="data/stopwords.js"></script>
<script src="js/topStates.js"></script>
<script src="js/USStateMaps.js"></script>
<script src="js/wordcount.js"></script>
<script>
/*
* Load wordcloud data
*/
var FL = FL;
var TX = TX;
var MIB = MIB;
var MYB = MYB;
var OR = OR;
var SPI = SPI;
var FW = FW;
var numOfWords = 250;
var previousId = "FL";
var tweetCloud = d3.wordcloud()
.selector("#mywordcloud") //default: wordcloud
.size([0.82*screen.width, 350])
.scale("log") //default: sqrt
.font("Impact")
.fill(d3.scale.category20())
.words(count(FL, numOfWords))
.spiral("archimedean")
.onwordclick(function(d, i) {window.location = "https://www.google.co.uk/search?q=" + d.text;})
.start();
function selectDestination(select) {
var id = select.options[select.selectedIndex].value;
$("#mywordcloud").html("");
tweetCloud.selector("#mywordcloud").words(count(window[id], numOfWords)).start();
// reset outlineColor and outlineThickness for previous one
var area1 = map1.getObjectById("US-"+previousId);
area1.outlineColor = '#fff';
area1.outlineThickness = 1
var area2 = map2.getObjectById("US-"+previousId);
area2.outlineColor = '#fff';
area2.outlineThickness = 1
// make the chart take in new color
area1.validate();
area2.validate();
// update State color in data
var area3 = map1.getObjectById("US-"+id);
area3.outlineColor = '#ff0000';
area3.outlineThickness = 3
var area4 = map2.getObjectById("US-"+id);
area4.outlineColor = '#ff0000';
area4.outlineThickness = 3
// make the chart take in new color
area3.validate();
area4.validate();
previousId = id
// if ( '' == id ) {
// map.clickMapObject(map.dataProvider);
// }
// else {
// map.clickMapObject(map.getObjectById(id));
// }
}
</script>