(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 }, { "x": 0 }, { "x": 0 }, { "x": 0 }, { "x": 0 } ], "columnTypes": [ "string", "float", "float", "float", "float", "float", "float", "float", "float" ], "csv": "categories,World,Europe,Africa,Asia,Latin America,Northern America,United Kingdom,Selected OECD\n1990,2.9,6.8,2.5,1.6,1.6,9.8,6.4,7.2\n2000,2.8,7.7,1.9,1.4,1.2,12.8,8,9.3\n2010,3.2,9.3,1.7,1.6,1.4,14.8,11.3,11.7\n2013,3.2,9.8,1.7,1.6,1.4,14.9,12.4,12.2" }; dataOptions.sort = true dataOptions.complete = completeHandler; Highcharts.data(dataOptions, chartOptions); } catch (error) { console.log(error); completeHandler(undefined); } } var shareUrl = 'https://app.everviz.com/show/asisir'; var encodedUrl = encodeURIComponent(shareUrl); var template = { chart: { renderTo: 'highcharts-asisir' }, 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": "%" }, "labels": { "format": "{value}%" } }, "credits": { "href": null, "text": "\u003cb\u003eSource\u003c/b\u003e: United Nations Population Division Trends in International Migrant Stock. 2013." }, "series": [ { "index": 0 }, { "index": 1 }, { "index": 2 }, { "index": 3 }, { "index": 4 }, { "index": 5 }, { "index": 6 }, { "index": 7 } ], "subtitle": { "text": "Chart provided by www.migrationobservatory.ox.ac.uk" }, "title": { "text": "Stock of migrants as a share of the host population" } }; 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); } }());