-
Notifications
You must be signed in to change notification settings - Fork 0
/
00-inflation.js
76 lines (64 loc) · 1.74 KB
/
00-inflation.js
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
var seriesOptions = [],
seriesCounter = 0,
names = ['AGS', 'AUT'];
/**
* Create the chart when all data is loaded
* @returns {undefined}
*/
function createChart() {
Highcharts.stockChart('inflation', {
rangeSelector: {
selected: 4
},
xAxis: {
type: 'month',
tickInterval: 31 * 24 * 3600 * 1000
},
yAxis: {
labels: {
formatter: function () {
return (this.value > 0 ? ' + ' : '') + this.value + '%';
}
},
plotLines: [{
value: 0,
width: 2,
color: 'silver'
}]
},
plotOptions: {
series: {
compare: 'percent',
showInNavigator: true
}
},
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
valueDecimals: 2,
split: true
},
series: seriesOptions
});
}
function success(data) {
var name = this.url.match(/(ags|aut)/)[0].toUpperCase();
var i = names.indexOf(name);
seriesOptions[i] = {
name: name,
data: data
};
// As we're loading the data asynchronously, we don't know what order it
// will arrive. So we keep a counter and create the chart when all the data is loaded.
seriesCounter += 1;
if (seriesCounter === names.length) {
createChart();
}
}
Highcharts.getJSON(
'https://cdn.jsdelivr.net/gh/GerhardMes/ArchidesPortfolio/aut-c.json',
success
);
Highcharts.getJSON(
'https://cdn.jsdelivr.net/gh/GerhardMes/ArchidesPortfolio/ags-c.json',
success
);