Charts for EM cotton story
author:
Mike Zavarello
by Mike Zavarello
HTML
<!-- Atlanta Fed scripts -->
<script src="https://www.frbatlanta.org/~/media/javascript/system/UniversalGoogleAnalytics.js"></script>
<script src="https://www.frbatlanta.org/~/media/javascript/highcharts/highcharts-global-settings-min.js"></script>
<!-- standard Highcharts scripts -->
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div class="economyMattersChart" id="container_CottonChart"></div>
CSS
.economyMattersChart { height: 400px; width: 100%; margin: 0 auto; }
JavaScript
$(document).ready(function(){
var iframeWidth_economyMattersChart = $('.economyMattersChart').width();
var iframeHeight_economyMattersChart = $('.economyMattersChart').height();
/* chart 1: cotton prices */
var sourceLine_CottonChart = 'Source: National Bureau of Economic Research, Macrohistory Database';
setChartDefaults(iframeWidth_economyMattersChart,iframeHeight_economyMattersChart,sourceLine_CottonChart,50);
var chartOptions_CottonChart = {
chart: { marginBottom: 95, marginRight: 20, renderTo: 'container_CottonChart', type: 'line' },
exporting: {
chartOptions: {
legend: { enabled: true }
},
filename: 'atlanta-fed_energy-important-but-less-so-in-louisiana-economy'
},
legend: { enabled: false },
subtitle: { text: 'Plunge in 1920 threatened many southern banks', width: iframeWidth_economyMattersChart * 0.8 },
title: { text: 'Monthly Wholesale New York Cotton Prices, 1870-1929', width: iframeWidth_economyMattersChart * 0.8 },
tooltip: {
formatter: function () {
var s = '<span style="font-size: 14px;">' + Highcharts.dateFormat('%B %Y', this.x) + '</span>';
$.each(this.points, function (i, point) {
s += '<br /><span style="color: ' + point.series.color + '; font-weight: bold;">' + point.series.name + '</span>: ' + Highcharts.numberFormat(point.y, 1) + ' cents per pound';
});
return s;
},
shared: true
},
xAxis: {
type: 'datetime', labels: { y: 20 }
},
yAxis: {
title: { text: 'Cents per pound' }, min: 0, tickInterval: 5, labels: { format: '{value:,.0f}' }
},
series: [
{ name: 'New York cotton prices', data:...