-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathG20-summary.html
238 lines (178 loc) · 5.89 KB
/
G20-summary.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<html>
<head>
<title>G20 climate and energy summary | Carbon Brief</title>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<style>
#container {max-width: 800px;}
#logocontainer{ max-width: 800px; height: 26px;}
#logo {position: absolute; right:10px;}
@media screen and (min-width: 830px) {
#logo {
left: 778px;
}
}
</style>
</head>
<body>
<!-- you can set minimum dimensions for the chart here -->
<!-- for example swap the <div below for this version -->
<!-- <div id="container" style="min-width: 310px; max-width: 600px; height: 400px; margin: 0 auto"></div> -->
<div id="container"></div>
<div id="logocontainer">
<img id="logo" src="https://s3-eu-west-1.amazonaws.com/cbhighcharts/CB-logo-for-highcharts.png">
</div>
<script type="text/javascript">
$(function() {
Highcharts.setOptions({
// here is the CB colour scheme
// dark blue - 0b4572
// yellow - EFC530
// light blue - 2f8fce
// red - C7432B
// light grey - 999999
// lilac - A14A7B
// orange - DF9239
// this line sets the colours
// the first colour is for bottom chunk of a stacked column (reversed: false)
// here I've used a gradient of 15 steps from CB dark blue to red, via grey
// you can make your own gradient custom here:
// http://www.strangeplanet.fr/work/gradient-generator/?c=9:FFFFFF:000000
colors: ['#999999', "#2F8FCE", "#EFC530", "#C7432B", "#A14A7B", "#0B4572"],
chart: {
// set the font family for the chart. PT Serif is CB default for body text.
style: {
fontFamily: '"PT Sans", Arial, sans-serif'
}
}
});
// Create the chart
// type: 'column'
// creates column chart. See www.highcharts.com/demo/ for more options
// zoomType: 'x,y'
// allows the user to zoom in to the chart on the x and y axis
// you can set to allow x zoom or y zoom only
$('#container').highcharts({
chart: {
renderTo: 'container',
backgroundColor: 'transparent',
type: 'column',
zoomType: 'x,y'
},
// set the title of the chart (here no title)
title: {
text: 'G20 and the world',
align: 'left',
margin: 30
},
// turn off the highcharts credit
credits: {
enabled: false
},
// controls how the columns stack
// options are 'normal' and 'percent'
// if you don't want stacked columns, delete this section
plotOptions: {
column: {
stacking: 'percent',
pointPadding: 0,
groupPadding: 0
}
},
// options for the y axis
yAxis: {
// controls the order of series in a stacked column/area chart
reversedStacks: false,
// fixes the maximum value for the y axis (switch off with "//")
// max: 300,
// sets the font size for the y axis labels
labels: {
style: {
fontSize: '12px'
},
// adds the suffix "Mt" to the values on the y axis
format: '{value} %'
},
// set the title of the y axis
title: {
text: ''
}
},
// sets options for the x axis
xAxis: {
type: 'category',
crosshair: {
// width: 40,
// pale grey #E5E5E5
// black #000000
color: '#E5E5E5'
},
labels: {
//rotation: -90,
style: {
fontSize: '12px'
}
}
},
tooltip: {
valueDecimals: 1,
formatter: function() {
var globalShare = ((this.point.value * 100)/33508).toFixed(1);
return this.series.name + ' <br/> ' + ' <span style="color:' + this.point.color + '">\u25CF</span> ' + Highcharts.numberFormat(this.point.y, 0) + '<br/>(' + Highcharts.numberFormat(this.point.percentage,1) + ' % of global total)'
},
shared: false,
// crosshairs: 'true'
},
// sets options for the legend
legend: {
// turn the legend on or off
enabled: true,
// margin: 20,
// width: 400,
padding: 20,
// set the layout of the legend
layout: 'horizontal',
floating: false,
verticalAlign: 'top',
// you can fine-tune the legend position here
y: 25
// x: 15,
// set the font size of the legend
// add "//" to use default settings
// itemStyle: {
// fontSize: '10px'
// }
},
// pull the data from a google spreadsheet
// you have to publish the spreadsheet to the web
// then grab the code from the url
// for example here, the bit after "d/" and before the final "/"
// https://docs.google.com/spreadsheets/d/1NAzRluJxGjyrJqsI6kjtSYxcPXTIL-lQZ6chFDcx2XI/
data: {
googleSpreadsheetKey: '149KqD14GpxafveGydFa2GL-evIeZcfuOL_lcMhgb2Zs',
complete: function (options) {
var series = options.series;
series[1].tooltip = {
// valuePrefix: '\u00A3 ',
valueSuffix: ' million'
}
}
}
},
// add an image on top of the chart
// you can add anything eg to annotate it
// here we're using it to add the CB logo
// the size and position of the logo is controlled by the numbers after the url
// the first sets the x offset (#pixels from the left)
// the second sets the y offset (#pixels from the top)
// the third and fourth set the size in x, y
function(chart) { // on complete
chart.renderer.image()
.add();
});
});
</script>
</body>
</html>