(function () { var script = document.getElementById('highcharts-script'); function addChart() { var onCustomCodeError; function customCode(options, product) { try { // Sample from highcharts var myTitle = "First Presidential Debate Marks Shift in Candidate Support", // Set title for Twitter myURL = "http://www.prri.org/research/prri-atlantic-october-2016-presidential-election-horserace-clinton-trump/"; // Set URL to the article var items = options.exporting && options.exporting.buttons && options.exporting.buttons.contextButton.menuItems, encodedUrl = encodeURIComponent(myURL), mySharers = [ [ 'Share on Facebook' ], [ 'Share on Google+' ], [ 'Share on Twitter' ], [ 'Share on LinkedIn' ] ] if (items) { options.exporting.buttons.contextButton.menuItems = items.slice(0, -3); Highcharts.each(mySharers, function (item, i){ options.exporting.buttons.contextButton.menuItems[i].text = item.join(''); }); } } catch(error) { console.error(error) if (onCustomCodeError && onCustomCodeError(error) === false){ // stop execution return; } } var chart = new Highcharts['Chart'](options); } function parseData(completeHandler, chartOptions) { try { var dataOptions = { "seriesMapping": [ { "x": 0 }, { "x": 0 }, { "x": 0 } ], "columnTypes": [ "string", "float", "float", "float" ], "csv": ",Hillary Clinton,Donald Trump,Other candidate/Don\u0027t know/Refused\nPre-Debate (Sept. 22-25),43,43,13\nPost-Debate (Sept. 28-Oct. 2),47,41,12" }; dataOptions.sort = true dataOptions.complete = completeHandler; Highcharts.data(dataOptions, chartOptions); } catch (error) { console.log(error); completeHandler(undefined); } } var shareUrl = 'https://cloud.highcharts.com/show/ylanyne/7'; var encodedUrl = encodeURIComponent(shareUrl); var template = { chart: { renderTo: 'highcharts-ylanyne' }, 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": { "series": { "dataLabels": { "useHTML": true, "style": { "fontSize": "12px", "color": "#000000" }, "enabled": true } } }, "yAxis": { "minorTickColor": "#d8d8d8", "max": 60, "tickInterval": 10, "tickColor": "#d8d8d8", "lineColor": "#d8d8d8", "title": { "style": { "color": "#000000" }, "text": null }, "minorGridLineWidth": 0, "lineWidth": 1, "minorGridLineColor": "#d8d8d8", "tickWidth": 1, "gridLineWidth": 0, "minColor": "#d8d8d8", "maxColor": "#d8d8d8" }, "xAxis": { "minorGridLineColor": "#d8d8d8", "minorTickColor": "#d8d8d8", "tickColor": "#d8d8d8", "lineColor": "#d8d8d8", "minorGridLineWidth": 0, "title": { "style": { "color": "#000000", "fontSize": "10px" }, "text": "Source: PRRI/The Atlantic Early October 2016 Survey." } }, "exporting": { "allowHTML": true }, "credits": { "href": "prri.org", "text": "PRRI" }, "legend": { "verticalAlign": "top", "y": 45, "itemStyle": { "color": "#000000" } }, "series": [ { "color": "#3d899e", "index": 0 }, { "color": "#bad270", "index": 1 }, { "color": "#bfc0bf", "index": 2 } ], "subtitle": { "style": { "fontSize": "14px", "color": "#000000", "fontWeight": "normal" }, "text": "Presidential vote choice among likely voters" }, "tooltip": { "backgroundColor": "#ffffff" }, "title": { "style": { "color": "#000000", "fontWeight": "bold" }, "text": "First Presidential Debate Marks Shift in Candidate Support" }, "chart": { "width": null, "style": { "fontFamily": "Arial" }, "type": "column", "height": null } }; 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); customCode(options, 'Chart'); }, 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 = '//cloud.highcharts.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); } }());