(function () {
var script = document.getElementById('highcharts-script');
function addChart() {
function parseData(completeHandler, chartOptions) {
try {
var dataOptions = {
"seriesMapping": [
{
"x": 0
}
],
"columnTypes": [
"float",
"float"
],
"csv": "Decile,Mean Wealth\n1,9\n2,2.4\n3,2.8\n4,16.1\n5,66.2\n6,35.4\n7,127.8\n8,223\n9,356.6\n10,1239.4"
};
dataOptions.sort = true
dataOptions.complete = completeHandler;
Highcharts.data(dataOptions, chartOptions);
} catch (error) {
console.log(error);
completeHandler(undefined);
}
}
var shareUrl = 'https://app.everviz.com/show/izamuza';
var encodedUrl = encodeURIComponent(shareUrl);
var template = {
chart: {
renderTo: 'highcharts-izamuza'
},
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": "${y}",
"enabled": true
}
}
},
"yAxis": {
"title": {
"text": "Thousands of 2016 USD"
},
"labels": {
"format": "${value}"
}
},
"xAxis": {
"type": "category",
"title": {
"text": "Wealth Decile"
}
},
"exporting": {
"enabled": false
},
"credits": {
"href": null,
"text": "Source: Survey of Consumer Finances. Inheritances converted to 2016 dollars using CPI-U-RS + 5% annual rate of return."
},
"legend": {
"enabled": false
},
"series": [
{
"index": 0
}
],
"tooltip": {
"enabled": false
},
"title": {
"style": {
"fontSize": "14px"
},
"text": "Mean Inheritance Level by Wealth Decile (2016)"
},
"chart": {
"type": "column"
},
"colors": [
"#B31021"
]
};
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);
}
}());