-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
62 lines (56 loc) · 1.41 KB
/
Copy pathscripts.js
File metadata and controls
62 lines (56 loc) · 1.41 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
// Highcharts super simple example
$(function () {
$('#highchart-container-1').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}]
});
});
// Import data
// Using d3js
d3.json('flavors_of_cacao.json', function(err, data) {
$('#cacao-data-1').text(JSON.stringify(data, null, 2));
})
d3.json('data-to-transform.json', function(err, data) {
$('#transformed-data-1').text(JSON.stringify(data, null, 2));
var curatedData = _(data.data.inTheaters)
.map('movies')
.flatten()
.map(function(movie){
return {
votes: movie.votes,
title: movie.title,
metascore: +movie.metascore,
filmingLocationsCount: movie.filmingLocations.length
};
})
.sortBy(function(movie) {return - movie.metascore})
.value()
$('#transformed-data-2').text(JSON.stringify(curatedData, null, 2))
})
// Import CSV data using PapaParse
Papa.parse('flavors_of_cacao.csv', {
download: true,
header: true,
complete: function(results){
$('#papa-data-1').text(JSON.stringify(results, null, 2));
}
});