(function () {
var script = document.getElementById('highcharts-script');
function addChart() {
var onCustomCodeError;
function customCode(options, product) {
try {
/*
// Sample of extending options:
Highcharts.extend(options, Highcharts.merge(options, {
chart: {
backgroundColor: "#bada55"
},
plotOptions: {
series: {
cursor: "pointer",
events: {
click: function(event) {
alert(this.name + " clicked\n" +
"Alt: " + event.altKey + "\n" +
"Control: " + event.ctrlKey + "\n" +
"Shift: " + event.shiftKey + "\n");
}
}
}
}
}));
*/
} 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
}
],
"columnTypes": [
"string",
"float",
"float"
],
"csv": ",Immigrants today strengthen our country because of their hard work and talents,Immigrants today are a burden to our country because they take our jobs housing and health care\nApril 2-7,54,38\nApril 9-14,55,37\nApril 16-21,54,34\nApril 30-May 5,61,29\nMay 7-12,58,32\nMay 14-19,57,34\nMay 21-26,57,34\nMay 28-June 1,57,31\nJune 4-9,57,35\nJune 11-16,55,37\nJune 18-23,53,38\nJune 25-30,54,35\nJuly 1-6,55,35\nJuly 9-13,52,39\nJuly 16-20,48,41\nJuly 23-27,49,42\nJuly 30-Aug 3,52,38\nAug 6-10,51,38\nAug 13-17,54,39\nAug 20-24,55,35\nAug 27-31,53,37\nSept 3-7,56,35\nSept 17-21,52,38\nSept 18-22,56,33\nSept 24-28,51,39\nOct 1-5,54,35\nOct 8-12,57,34\nOct 15-19,58,33\nOct 22-26,55,38\nOct 29-Nov 2,58,33\nNov 5-9,57,35\nNov 12-16,55,35\nNov 19-23,57,35\nNov 25-30,53,39\nDec 3-7,60,31\nDec 10-14,57,36\nDec 17-21,58,36\nDec 18-21,56,34\nDec 23-28,57,35\nDec 30-Jan 4,55,36"
};
dataOptions.sort = true
dataOptions.complete = completeHandler;
Highcharts.data(dataOptions, chartOptions);
} catch (error) {
console.log(error);
completeHandler(undefined);
}
}
var shareUrl = 'https://app.everviz.com/show/odomos';
var encodedUrl = encodeURIComponent(shareUrl);
var template = {
chart: {
renderTo: 'highcharts-odomos'
},
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": {
"format": "{x}"
}
}
},
"yAxis": {
"minorTickColor": "#d8d8d8",
"tickInterval": 10,
"tickColor": "#d8d8d8",
"lineColor": "#d8d8d8",
"title": {
"style": {
"fontSize": "13px"
},
"text": null
},
"minorGridLineWidth": 0,
"lineWidth": 1,
"minorGridLineColor": "#d8d8d8",
"tickWidth": 1,
"gridLineWidth": 0,
"min": 0,
"minColor": "#d8d8d8",
"maxColor": "#d8d8d8"
},
"xAxis": {
"minorGridLineColor": "#d8d8d8",
"minorTickColor": "#d8d8d8",
"tickColor": "#d8d8d8",
"lineColor": "#d8d8d8",
"minorGridLineWidth": 0,
"title": {
"style": {
"fontSize": "11px",
"color": "#000000"
},
"text": "Source: PRRI, American Values Atlas, 2014."
},
"labels": {
"rotation": null
}
},
"credits": {
"href": "publicreligion.org",
"text": "PRRI"
},
"legend": {
"verticalAlign": "top",
"y": 45,
"itemStyle": {
"color": "#000000"
}
},
"series": [
{
"color": "#c0d769",
"marker": {
"symbol": "circle"
},
"index": 0
},
{
"color": "#00abba",
"marker": {
"symbol": "circle"
},
"index": 1,
"negativeColor": "#000000"
}
],
"subtitle": {
"style": {
"fontWeight": "normal",
"fontSize": "14px",
"color": "#000000"
},
"text": "Which statement comes closest to your own views?"
},
"title": {
"style": {
"fontWeight": "bold",
"color": "#000000"
},
"text": "Immigrants\u0027 Economic and Cultural Impact in 2014"
},
"chart": {
"backgroundColor": "#ffffff",
"plotBackgroundColor": "#ffffff",
"width": null,
"style": {
"fontFamily": "Arial"
},
"type": "line"
},
"colors": [
"#76d155",
"#434348",
"#90ed7d",
"#f7a35c",
"#8085e9",
"#f15c80",
"#e4d354",
"#2b908f",
"#f45b5b",
"#97e4de"
]
};
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 = '//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);
}
}());