(function () { var script = document.getElementById('highcharts-script'); function addChart() { function parseData(completeHandler, chartOptions) { try { var dataOptions = { "seriesMapping": [ { "x": 0 }, { "x": 0 } ], "columnTypes": [ "string", "float", "float" ], "csv": "County Group,Clinton,Trump\nFewest whites,58,37\nFewer whites,43,52\nMore whites,34,60\nMost whites,29,67" }; dataOptions.sort = true dataOptions.complete = completeHandler; Highcharts.data(dataOptions, chartOptions); } catch (error) { console.log(error); completeHandler(undefined); } } var shareUrl = 'https://app.everviz.com/show/yrydiky'; var encodedUrl = encodeURIComponent(shareUrl); var template = { chart: { renderTo: 'highcharts-yrydiky' }, 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 = { "plotOptions": { "line": { "marker": { "symbol": "diamond" }, "pointInterval": 2 } }, "yAxis": { "min": 0, "max": 70, "title": { "text": null }, "labels": { "format": "{value}%" } }, "exporting": { "enabled": false }, "xAxis": { "title": { "text": null } }, "credits": { "style": { "fontFamily": "arial", "fontSize": "12px", "fontColor": "#666666" }, "href": null, "text": null, "enabled": false }, "legend": { "borderColor": "#ffffff", "itemStyle": { "fontColor": "#666666", "fontStyle": "italic" }, "align": "left" }, "series": [ { "color": "#1461cc", "index": 0, "negativeColor": "#f24425" }, { "color": "#f24425", "index": 1 } ], "subtitle": { "style": { "color": "#666666", "fontSize": "16px" }, "text": "Vote share broken down into four even groups of counties with ascending proportions of white voters", "align": "left" }, "tooltip": { "borderColor": "#bbbbbb", "backgroundColor": "#ffffff", "borderRadius": 0, "shadow": false, "borderWidth": 2, "hideDelay": 300 }, "title": { "style": { "fontSize": "20px", "fontWeight": "normal" }, "text": "White voters backed Trump", "align": "left" }, "chart": { "selectionMarkerFill": "#dddddd", "borderColor": "#dddddd", "spacingBottom": 24, "style": { "fontFamily": "\"Austin News Text\", Times New Roman" }, "plotBorderColor": "#dddddd", "type": "column", "inverted": true }, "colors": [ "#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9", "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1" ] }; 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); } }());