1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < title > Temperature Data</ title >
6+ < meta charset ="UTF-8 ">
7+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
8+ < link rel ="stylesheet " href ="/styles.css ">
9+ < link href ='https://fonts.googleapis.com/css?family=Michroma ' rel ='stylesheet '>
10+ < link rel ="icon " type ="image/png " href ="/favicon-96x96.png " sizes ="96x96 " />
11+ < link rel ="icon " type ="image/svg+xml " href ="/favicon.svg " />
12+ </ head >
13+
14+ < body >
15+ < ul class ="navigationBar ">
16+ < li > < a href ="/index.html "> Home</ a > </ li >
17+ < li > < a href ="/mapping.html "> Open Data</ a > </ li >
18+ < li class ="right "> < a href ="/about.html "> About</ a > </ li >
19+ </ ul >
20+
21+ < div class =mappingTitle >
22+ < h1 > Welcome to the Temperature Data visualization Page!</ h1 >
23+ < p > These charts represent data taken from < a
24+ href ="https://www.data.gov.uk/collections/environment/weather "> The weather data page of the
25+ data.gov website</ a > </ p >
26+ < hr >
27+ </ div >
28+
29+
30+ < div class ="chartBig ">
31+ < canvas id ="temperatureMeanAnnual "> </ canvas >
32+ </ div >
33+ < div class ="textBox ">
34+ < p >
35+ The data above represents the mean average temperature across the years 1884 - 2020, representing the largest
36+ time range currently hosted on the website and showing how temperatures have gradually risen over the course of many years
37+ in the UK
38+ </ p >
39+ </ div >
40+
41+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js "> </ script >
42+ < script src ="https://cdn.jsdelivr.net/npm/chart.js "> </ script >
43+
44+ < script >
45+ const meanTempData = '/Datasets/uk-mean-temperature.csv'
46+ d3 . csv ( meanTempData ) . then ( function ( datapoints ) {
47+ // Prep the variables and then push data into them.
48+ const year = [ ]
49+ const meanTemp = [ ]
50+
51+ for ( i = 0 ; i < datapoints . length ; i ++ ) {
52+ year . push ( datapoints [ i ] . Year )
53+ meanTemp . push ( datapoints [ i ] [ 'Annual mean temperature (°C)' ] )
54+ } ;
55+
56+ // prep the data for our chart
57+ const tempMeanTotal = {
58+ labels : year ,
59+ datasets : [ {
60+ label : 'Mean Temp (in celsius)' ,
61+ data : meanTemp ,
62+ fill : false ,
63+ borderColor : 'rgb(75, 192, 192)' ,
64+ tension : 0.1 ,
65+ } ]
66+ }
67+ // draw the chart
68+ const tempMeanChart = new Chart ( meanTempTot , {
69+ type : 'line' ,
70+ data : tempMeanTotal ,
71+ options : {
72+ scales : {
73+ y : {
74+ title : {
75+ display : true ,
76+ text : 'Temperature in celsius'
77+ }
78+ } ,
79+ x : {
80+ title : {
81+ display : true ,
82+ text : 'Year'
83+ }
84+ }
85+ }
86+ }
87+ } )
88+
89+
90+ } )
91+ const meanTempTot = document . getElementById ( 'temperatureMeanAnnual' ) ;
92+
93+ </ script >
94+ < div >
95+ < hr >
96+ </ div >
97+ < div class =textBox >
98+ < p >
99+ < u >
100+ All data is provided by the UK government at < a href ="https://www.data.gov.uk/ "> The open data project</ a >
101+ </ u >
102+ </ p >
103+ </ div >
104+ </ body >
105+
106+ </ html >
0 commit comments