-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
89 lines (88 loc) · 3.16 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
<!DOCTYPE html>
<html>
<head>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<link href="https://fonts.googleapis.com/css?family=Pacifico&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="bit.css">
</head>
<body background="https://techcrunch.com/wp-content/uploads/2014/12/bitcoin-falling.png">
<h1><center>Live Bitcoin Ticker</center></h1>
<div id="container" style="min-width: 310px; height: 400px; max-width: 800px; margin: auto; position: absolute;top: 0; right: 0;bottom: 0; left: 0"></div>
</body>
<script>
var chart = Highcharts.chart('container', {
chart: {
type: 'spline',
scrollablePlotArea: {
minWidth: 600,
scrollPositionX: 1
}
},
title: {
text: 'Bitcoin Ticker',
},
subtitle: {
text: 'Bitcoin rate in USD, EURO, GBP',
},
xAxis: {
type: 'datetime',
},
yAxis: {
title: {
text: 'Rate'
},
minorGridLineWidth: 0,
gridLineWidth: 0,
alternateGridColor: null,
},
tooltip: {
valueSuffix: ' rate'
},
plotOptions: {
spline: {
lineWidth: 4,
states: {
hover: {
lineWidth: 4
}
},
marker: {
enabled: true
},
}
},
series: [{
name: 'USD',
data: []
}, {
name: 'EURO',
data: []
},{
name: 'GBP',
data: []
}],
navigation: {
menuItemStyle: {
fontSize: '10px'
}
}
});
setInterval(() =>{
let xhr = new XMLHttpRequest;
xhr.addEventListener('load', function(){
var response = JSON.parse(this.responseText)
var dataUSD = [(new Date).getTime(), response.bpi.USD.rate_float];
var dataEURO = [(new Date).getTime(), response.bpi.EUR.rate_float];
var dataGBP = [(new Date).getTime(), response.bpi.GBP.rate_float];
chart.series[0].addPoint(dataUSD)
chart.series[1].addPoint(dataEURO)
chart.series[2].addPoint(dataGBP)
})
xhr.open('GET', 'https://api.coindesk.com/v1/bpi/currentprice.json')
xhr.send();
}, 4000)
</script>
</html>