Created
September 27, 2018 16:02
-
-
Save chris-vecchio/5967a8993ef4d704cb2218338a08c02b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chartData = { | |
chart: { | |
type: 'bar', | |
width: null, | |
height: null, | |
marginRight: 35, | |
spacingBottom: 25, | |
style: { | |
fontFamily: 'Arial, Helvetica, sans-serif' | |
}, | |
events: { | |
load: function() { | |
$(".highcharts-legend-item path").attr('stroke-width', 3); | |
}, | |
redraw: function() { | |
$(".highcharts-legend-item path").attr('stroke-width', 3); | |
}, | |
beforePrint: function() { | |
this.exportSVGElements[0].box.hide(); | |
this.exportSVGElements[1].hide(); | |
}, | |
afterPrint: function() { | |
this.exportSVGElements[0].box.show(); | |
this.exportSVGElements[1].show(); | |
} | |
} | |
}, | |
title: { | |
text: 'Industry Employment Growth', | |
align: 'left', | |
margin: 15, | |
style: { | |
fontSize: '22px', | |
fontWeight: 'normal', | |
color: 'rgba(85,85,85,1)' | |
} | |
}, | |
credits: { | |
text: "Source: Bureau of Labor Statistics", | |
href: false, | |
useHTML: true, | |
position: { | |
align: 'left', | |
x: 10, | |
y: -5 | |
}, | |
style: { | |
color: 'rgba(102,102,102,1)', | |
fontSize: '12px', | |
cursor: 'default' | |
} | |
}, | |
tooltip: { | |
shared: true, | |
useHTML: true, | |
backgroundColor: 'rgba(255,255,255,1)', | |
borderColor: 'rgba(65,75,76,1)', | |
borderWidth: 1, | |
formatter: function() { | |
var s = '<span style="font-size: 12px; font-weight: normal;">' + this.x + '</span><br/>'; | |
s += '<table>'; | |
$.each(this.points, function() { | |
s += '<tr><td style="color:'; | |
s += this.series.color + ';'; | |
s += ' text-align: left;'; | |
s += ' padding: 0px 10px 0px 0px;'; | |
s += ' font-size: 12px;'; | |
s += ' font-weight: bold;'; | |
s += '">'; | |
s += this.series.options.tooltipname; | |
s += ':</td>'; | |
s += '<td style="text-align: right; font-size: 12px; font-weight: bold;">'; | |
s += ' '; | |
if (this.series.options.tooltipvalueprefix) { | |
s += this.series.options.tooltipvalueprefix; | |
} | |
s += Highcharts.numberFormat(this.y, 1, '.', ','); | |
if (this.series.options.tooltipvaluesuffix) { | |
s += this.series.options.tooltipvaluesuffix; | |
} | |
s += '</td></tr>'; | |
}); | |
s += '</table>'; | |
return s; | |
} | |
}, | |
legend: { | |
verticalAlign: 'top', | |
align: 'left', | |
floating: false, | |
layout: 'horizontal', | |
margin: 10, | |
x: 0, | |
y: -15, | |
itemStyle: { | |
color: 'rgba(102,102,102,1)', | |
fontSize: '12px', | |
fontWeight: 'normal' | |
}, | |
symbolRadius: 0, | |
itemDistance: 15, | |
labelFormatter: function() { | |
return this.options.legendname; | |
} | |
}, | |
plotOptions: { | |
series: { | |
animation: false, | |
pointPadding: 0.08, | |
groupPadding: 0.1, | |
borderWidth: 0, | |
shadow: false | |
}, | |
bar: { | |
dataLabels: { | |
enabled: false | |
} | |
} | |
}, | |
yAxis: { | |
title: { | |
text: 'Year-over-year percent change', | |
style: { | |
fontSize: '12px', | |
fontWeight: 'normal', | |
whiteSpace: 'nowrap', | |
color: 'rgba(102,102,102,1)' | |
} | |
}, | |
labels: { | |
format: '{value}', | |
style: { | |
fontSize: '12px', | |
color: 'rgba(102,102,102,1)' | |
} | |
}, | |
allowDecimals: true, | |
lineColor: 'rgba(145,145,145,0)', | |
lineWidth: 0, | |
gridLineColor: 'rgba(225,225,225,1)', | |
gridLineWidth: 1, | |
minorGridLineColor: 'rgba(225,225,225,0)', | |
tickColor: 'rgba(207,216,220,1)', | |
tickWidth: 0, | |
tickPosition: 'outside', | |
tickLength: 0, | |
minPadding: 0, | |
maxPadding: 0, | |
plotLines: [{ | |
value: 0, | |
color: 'rgba(145,145,145,1)', | |
width: 2 | |
}], | |
min: -1, | |
max: 6, | |
tickInterval: 1 | |
}, | |
xAxis: { | |
type: 'category', | |
title: { | |
text: null | |
}, | |
labels: { | |
overflow: false, | |
rotation: 0, | |
style: { | |
fontSize: '10px', | |
color: 'rgba(102,102,102,1)' | |
} | |
}, | |
lineColor: 'rgba(225,225,225,1)', | |
lineWidth: 1, | |
gridLineColor: 'rgba(225,225,225,0)', | |
gridLineWidth: 0, | |
minorGridLineColor: 'rgba(225,225,225,0)', | |
tickColor: 'rgba(145,145,145,1)', | |
tickWidth: 0, | |
tickPosition: 'inside', | |
tickLength: 7, | |
minPadding: 0, | |
allowDecimals: true, | |
crosshair: false, | |
startOnTick: false, | |
endOnTick: false, | |
showFirstLabel: true, | |
categories: ['Construction', 'Leisure and Hospitality', 'Financial Activities', 'Manufacturing', 'Natural Resources and Mining', 'Education and Health Services', 'Other Services', 'Professional & Business Services', 'Government', 'Trade, Transportation, Utilities', 'Information'] | |
}, | |
exporting: { | |
filename: 'oh_industry_employment_growth', | |
scale: 2, | |
chartOptions: { | |
chart: { | |
events: null | |
} | |
}, | |
sourceWidth: 950, | |
sourceHeight: 540, | |
buttons: { | |
contextButton: { | |
align: 'right', | |
enabled: true, | |
height: 20, | |
symbol: 'menu', | |
symbolFill: 'rgba(65,75,86,1)', | |
symbolSize: 14, | |
symbolStroke: 'rgba(65,75,86,1)', | |
symbolStrokeWidth: 2, | |
symbolX: 12.5, | |
symbolY: 10.5, | |
text: null, | |
verticalAlign: 'top', | |
width: 24, | |
x: -10, | |
y: 0, | |
menuItems: [{ | |
text: 'Latest News Release', | |
onclick: function() { | |
window.open('https://clevelandfed.org/our-research/indicators-and-data/median-cpi.aspx', '_blank'); | |
} | |
}, { | |
separator: true | |
}, { | |
text: "Download XLSX", | |
onclick: function() { | |
this.downloadXLSX(); | |
// ga('send', 'event', 'Highcharts', 'downloadXLSX', '(chart: ' + this.options.chart.gaTitle + ') | ' + document.title); | |
} | |
}, { | |
textKey: "downloadCSV", | |
onclick: function() { | |
this.downloadCSV(); | |
// ga('send', 'event', 'Highcharts', 'downloadCSV', '(chart: ' + this.options.chart.ganame + ') | ' + document.title); | |
} | |
}, { | |
textKey: 'downloadPNG', | |
onclick: function() { | |
// ga('send', 'event', 'Highcharts', 'downloadPNG', '(chart: ' + this.options.chart.ganame + ') | ' + document.title); | |
this.exportChart({ | |
type: 'image/png' | |
}); | |
} | |
}, { | |
textKey: 'downloadPDF', | |
onclick: function() { | |
this.exportChart({ | |
type: 'application/pdf' | |
}); | |
// ga('send', 'event', 'Highcharts', 'downloadPDF', '(chart: ' + this.options.chart.ganame + ') | ' + document.title); | |
} | |
}] | |
} | |
}, | |
csv: { | |
dateFormat: '%m-%d-%Y', | |
columnHeaderFormatter: function(item) { /* Column is axis object */ | |
if (item instanceof Highcharts.Axis) { /* Datetime axis */ | |
if (item.isDatetimeAxis) { /* Use title if it exists */ | |
if (item.options.title.text) { | |
return item.options.title.text; | |
} /* Else use title 'Date' (HC default = 'DateTime') */ | |
else { | |
return 'Date'; | |
} | |
} /* Category axis (only other type) */ | |
else { /* Use title if it exists */ | |
if (item.options.title.text) { | |
return item.options.title.text; | |
} /* Use HC default title if it doesn't */ | |
else { | |
return 'Industry'; | |
} | |
} | |
} /* Column is data series */ | |
else if (item instanceof Highcharts.Series) { /* If custom csvname attribute exists, use it */ | |
if (item.options.csvname) { | |
return item.options.csvname; | |
} /* Else use the default name attribute */ | |
else { | |
return item.name; | |
} | |
} | |
} | |
} | |
}, | |
series: [{ | |
index: 0, | |
zIndex: 1, | |
legendIndex: 0, | |
color: '#2875a8', | |
name: 'Ohio', | |
id: 'Ohio', | |
dataname: 'ohind', | |
legendname: 'Ohio', | |
tooltipname: 'Ohio', | |
tooltipvaluesuffix: '%', | |
marker: { | |
enabled: false | |
}, | |
data: [5.45, 1.77, 1.51, 1.03, 0.93, 0.76, 0.67, 0.31, 0.03, -0.09, -0.39] | |
}, { | |
index: 1, | |
zIndex: 0, | |
legendIndex: 1, | |
color: '#e67a17', | |
name: 'United States', | |
id: 'United States', | |
dataname: 'usind', | |
legendname: 'United States', | |
tooltipname: 'United States', | |
tooltipvaluesuffix: '%', | |
marker: { | |
enabled: false | |
}, | |
data: [4.13, 2.01, 1.43, 1.64, 3.16, 2.07, 1.12, 1.69, 0.16, 0.88, 0.47] | |
}] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment