Skip to content

Commit dc43a2b

Browse files
committed
Updated code.
1 parent e157866 commit dc43a2b

File tree

10 files changed

+188
-510
lines changed

10 files changed

+188
-510
lines changed

capture-visualization/index.js

+12-427
Large diffs are not rendered by default.

capture-visualization/public/app.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"use strict";
2+
3+
//
4+
// Render a chart to a particular element on the page.
5+
//
6+
function renderChart (bindto, data, size) {
7+
var chart = c3.generate({
8+
bindto: bindto,
9+
size: size,
10+
data: {
11+
json: data,
12+
keys: {
13+
x: "Year",
14+
value: [
15+
"AvgTemp"
16+
]
17+
}
18+
},
19+
transition: {
20+
duration: 0 // Disable animated transitions when we are capturing a static image.
21+
}
22+
});
23+
};
24+
25+
$(function () {
26+
27+
$.get("nyc-temperature.csv")
28+
.then(function (response) {
29+
var parseOptions = {
30+
header: true,
31+
dynamicTyping: true
32+
};
33+
const parsed = Papa.parse(response, parseOptions);
34+
const chartSize = {
35+
width: 600,
36+
height: 300
37+
};
38+
renderChart("#chart", parsed.data, chartSize);
39+
})
40+
.catch(function (err) {
41+
console.error(err);
42+
});
43+
44+
});
45+

capture-visualization/toolkit/template-chart/public/bower.json capture-visualization/public/bower.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
],
1717
"dependencies": {
1818
"jquery": "^3.3.1",
19-
"c3": "^0.4.18"
19+
"c3": "^0.4.18",
20+
"papaparse": "^4.3.7"
2021
}
2122
}

capture-visualization/toolkit/template-chart/public/index.html capture-visualization/public/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
<script src="bower_components/jquery/dist/jquery.js"></script>
1010
<script src="bower_components/d3/d3.js"></script>
1111
<script src="bower_components/c3/c3.js"></script>
12+
<script src="bower_components/papaparse/papaparse.js"></script>
1213
<script src="app.js"></script>
1314
</head>
1415
<body>
15-
<div id='chart'></div>
16+
<div id='chart'></div>
1617
</body>
1718
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
Year,MinTemp,MaxTemp,AvgTemp
2+
1917,-25,37.8,10.547245179063365
3+
1918,-21.1,40,11.825205479452052
4+
1919,-18.3,37.2,12.125824175824178
5+
1920,-18.9,34.4,11.286475409836074
6+
1921,-15.6,35.6,12.751095890410959
7+
1922,-18.9,34.4,12.001369863013698
8+
1923,-13.9,37.2,11.665753424657524
9+
1924,-15,37.2,11.08784153005464
10+
1925,-18.9,37.2,11.937637362637368
11+
1926,-15,37.8,10.772865013774107
12+
1927,-18.3,33.3,11.932465753424664
13+
1928,-13.9,34.4,11.961157024793385
14+
1929,-13.3,37.2,12.328082191780814
15+
1930,-13.9,38.9,12.53301369863014
16+
1931,-11.7,37.2,13.26561643835617
17+
1932,-11.7,35.6,12.900961538461535
18+
1933,-21.1,38.9,12.447099447513821
19+
1934,-26.1,38.3,11.733150684931507
20+
1935,-18.3,35,11.739041095890402
21+
1936,-19.4,41.1,11.940027322404374
22+
1937,-10,37.8,12.546428571428576
23+
1938,-14.4,35.6,12.938356164383551
24+
1939,-14.4,35.6,12.62821917808219
25+
1940,-13.9,36.7,11.04616438356164
26+
1941,-12.2,36.7,12.78082191780821
27+
1942,-20,36.1,12.310714285714294
28+
1943,-22.2,37.2,12.117671232876717
29+
1944,-11.1,38.9,12.637534246575356
30+
1945,-16.7,36.1,12.307808219178066
31+
1946,-15,34.4,13.040273972602742
32+
1947,-13.9,35,12.159041095890403
33+
1948,-17.8,39.4,12.316986301369864
34+
1949,-8.3,38.9,13.88131868131868
35+
1950,-14.4,35,12.076373626373627
36+
1951,-13.3,34.4,12.815479452054786
37+
1952,-13.3,37.8,13.236202185792356
38+
1953,-10,38.9,13.947796143250693
39+
1954,-13.9,37.8,12.737671232876705
40+
1955,-17.8,37.8,12.68255494505495
41+
1956,-10,37.2,11.957240437158474
42+
1957,-17.8,38.3,13.081318681318683
43+
1958,-16.1,33.9,11.46863013698631
44+
1959,-13.9,36.1,13.060273972602742
45+
1960,-13.3,32.8,12.23196721311476
46+
1961,-18.9,36.1,12.839589041095888
47+
1962,-15.6,37.2,11.958630136986303
48+
1963,-18.9,36.7,12.046575342465754
49+
1964,-12.8,37.2,12.555191256830605
50+
1965,-12.8,35,12.37712328767122
51+
1966,-13.3,39.4,12.846849315068491
52+
1967,-15.6,35.6,11.705753424657528
53+
1968,-18.3,36.7,12.284836065573764
54+
1969,-11.7,36.1,12.702191780821918
55+
1970,-16.1,34.4,12.42027397260274
56+
1971,-15.6,35.6,12.939726027397267
57+
1972,-15,34.4,12.172540983606549
58+
1973,-13.9,36.7,13.430821917808212
59+
1974,-14.4,35,12.660684931506855
60+
1975,-9.4,36.7,12.790684931506851
61+
1976,-18.3,35.6,11.859699453551904
62+
1977,-18.9,40,12.458356164383554
63+
1978,-12.2,35,11.707123287671221
64+
1979,-17.8,35,13.251780821917801
65+
1980,-18.3,38.9,12.78374316939891
66+
1981,-16.7,35.6,12.912876712328769
67+
1982,-17.8,36.7,12.749178082191776
68+
1983,-15.6,37.2,13.362191780821927
69+
1984,-13.3,35.6,13.030327868852472
70+
1985,-18.9,35,13.110821917808213
71+
1986,-13.3,36.7,12.983287671232878
72+
1987,-15.6,36.1,12.903287671232881
73+
1988,-15,37.2,12.674316939890723
74+
1989,-14.4,35.6,12.234657534246589
75+
1990,-13.9,35,14.048219178082192
76+
1991,-12.2,38.9,14.049178082191775
77+
1992,-11.7,33.9,12.195081967213117
78+
1993,-13.9,38.9,13.1131506849315
79+
1994,-18.9,36.7,12.952602739726041
80+
1995,-14.4,38.9,13.01150684931507
81+
1996,-15,35.6,12.081420765027325
82+
1997,-15.6,36.1,12.414246575342458
83+
1998,-10,33.9,14.0149315068493
84+
1999,-12.8,38.3,13.639589041095885
85+
2000,-16.1,33.9,12.131420765027318
86+
2001,-8.9,39.4,13.498493150684943
87+
2002,-7.2,36.7,13.599999999999998
88+
2003,-13.9,34.4,11.953150684931495
89+
2004,-17.2,32.8,12.515846994535524
90+
2005,-15,37.2,13.219863013698642
91+
2006,-9.4,36.1,13.841506849315062
92+
2007,-13.3,33.3,12.878493150684925
93+
2008,-12.2,35.6,12.991803278688527
94+
2009,-14.4,33.3,12.273972602739729
95+
2010,-10.6,39.4,13.783698630136989
96+
2011,-14.4,40,13.620684931506842
97+
2012,-10.6,37.8,14.093579234972683
98+
2013,-11.7,36.7,13.033150684931497
99+
2014,-15.5,33.3,12.514657534246563
100+
2015,-16.6,36.1,13.809726027397259
101+
2016,-18.2,35.6,14.016803278688531
102+
2017,-9.9,34.4,14.783536585365862

capture-visualization/toolkit/charts.js

-22
This file was deleted.

capture-visualization/toolkit/template-chart/public/app.js

-27
This file was deleted.

capture-visualization/toolkit/template-chart/web-server.js

-32
This file was deleted.

capture-visualization/web-server.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use strict";
2+
3+
const express = require('express');
4+
const path = require('path');
5+
6+
module.exports = {
7+
start: () => { // Export a start function so our main module can start the web server at its leisure.
8+
return new Promise((resolve, reject) => { // Wrap web server startup in a promise.
9+
const app = express();
10+
11+
const staticFilesPath = path.join(__dirname, "public"); // Make our 'public' sub-directory accessible via HTTP.
12+
const staticFilesMiddleWare = express.static(staticFilesPath);
13+
app.use('/', staticFilesMiddleWare);
14+
15+
const server = app.listen(3000, err => { // Start our web server!
16+
if (err) {
17+
reject(err); // Error occurred while starting web server.
18+
}
19+
else {
20+
resolve(server); // Web server started ok.
21+
}
22+
});
23+
});
24+
}
25+
}

0 commit comments

Comments
 (0)