(function () {
var script = document.getElementById('highcharts-script');
function addChart() {
function parseData(completeHandler, chartOptions) {
try {
var dataOptions = {
"seriesMapping": [
{
"x": 0
},
{
"x": 0
},
{
"x": 0
},
{
"x": 0
}
],
"columnTypes": [
"string",
"float",
"float",
"float",
"float"
],
"csv": "Date,Latest,BI Projection,OBR Nov 15,OBR Nov 15 Projection\n2013Q1,100,,100,\n2013Q2,98.12601231,,98.12586765,\n2013Q3,100.2496645,,100.2545118,\n2013Q4,103.0656208,,103.0541416,\n2014Q1,104.9058263,,104.6968996,\n2014Q2,103.8472396,,103.4243406,\n2014Q3,104.9919015,,104.8357242,\n2014Q4,106.7358508,,107.3345673,\n2015Q1,108.3020963,,107.635354,\n2015Q2,106.6999861,,106.3396576,106.3396576\n2015Q3,107.7692165,,,109.1392874\n2015Q4,108.5293165,108.5293165,,112.4016659\n2016Q1,,111.1340201,,112.4942156\n2016Q2,,109.4654097,,110.8051828\n2016Q3,,111.6826043,,113.0495141"
};
dataOptions.sort = true
dataOptions.complete = completeHandler;
Highcharts.data(dataOptions, chartOptions);
} catch (error) {
console.log(error);
completeHandler(undefined);
}
}
var shareUrl = 'https://54.244.161.160/show/afiqes';
var encodedUrl = encodeURIComponent(shareUrl);
var template = {
chart: {
renderTo: 'highcharts-afiqes'
},
navigation: {
menuItemStyle: {
fontFamily: Highcharts.SVGRenderer.prototype.getStyle().fontFamily,
padding: '2px 10px'
}
},
exporting: {
buttons: {
contextButton: {
menuItems: [{
text: '' +
'Share on Facebook'
}, {
text: '' +
'Share on Google+'
}, {
text: '' +
'Share on Twitter'
}, {
text: '' +
'Share on LinkedIn'
}, {
separator: true
}]
.concat(Highcharts.getOptions().exporting.buttons.contextButton.menuItems)
.concat([{
separator: true
}, {
text: '' + 'Edit chart'
}, {
text: '' + 'Create chart'
}])
}
}
}
};
var chartOptions = {
"yAxis": {
"title": {
"text": "Nominal GDP (2013 Q1 \u003d 100)"
}
},
"series": [
{
"marker": {
"enabled": false
},
"index": 0
},
{
"color": "#7cb5ec",
"dashStyle": "ShortDash",
"marker": {
"enabled": false
},
"index": 1
},
{
"color": "#b03060",
"marker": {
"enabled": false
},
"index": 2
},
{
"color": "#b03060",
"dashStyle": "ShortDash",
"marker": {
"enabled": false
},
"index": 3
}
],
"subtitle": {
"text": "Source: Bloomberg Intelligence, OBR"
},
"title": {
"text": "The cash size of the economy is smaller than previously thought"
}
};
parseData(function (dataOptions) {
// Merge series configs
if (chartOptions.series && dataOptions) {
Highcharts.each(chartOptions.series, function (series, i) {
chartOptions.series[i] = Highcharts.merge(series, dataOptions.series[i]);
});
}
var options = Highcharts.merge(dataOptions, chartOptions, template);
var chart = new Highcharts['Chart'](options);
}, chartOptions);
}
// Load the Highcharts script if undefined, and add the chart
if (typeof Highcharts !== 'undefined') {
addChart();
} else if (script) {
script.deferredCharts.push(addChart);
} else {
script = document.createElement('script');
script.id = 'highcharts-script';
script.src = '//app.everviz.com/resources/js/highstock-cloud-5.0.7.js';
script.type = 'text/javascript';
script.deferredCharts = [addChart];
script.onload = function () {
// Prevent double firing of event in IE9/IE10
if (!script.chartsAdded) {
script.chartsAdded = true;
while(script.deferredCharts.length) {
script.deferredCharts.shift()();
}
}
};
script.onreadystatechange = function() {
if (this.readyState == 'complete' || this.readyState == 'loaded') {
script.onload();
}
};
document.getElementsByTagName('head')[0].appendChild(script);
}
}());