Skip to content

Instantly share code, notes, and snippets.

@karkranikhil
Last active October 30, 2019 03:51
Show Gist options
  • Select an option

  • Save karkranikhil/1ffb0a0046bed8d044c3691c57653ba7 to your computer and use it in GitHub Desktop.

Select an option

Save karkranikhil/1ffb0a0046bed8d044c3691c57653ba7 to your computer and use it in GitHub Desktop.
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Funding history'
},
xAxis: {
categories: ["2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001"]
},
yAxis: {
min: 0,
title: {
text: 'Funding'
},
labels: {
formatter: function() {
if ( this.value > 1000 ) return Highcharts.numberFormat( this.value/1000, 1) + "K";
return Highcharts.numberFormat(this.value,0);
}
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: ( // theme
Highcharts.defaultOptions.title.style &&
Highcharts.defaultOptions.title.style.color
) || 'gray'
}
}
},
legend: {
symbolWidth: 30,
symbolRadius: 0,
squareSymbol: false
},
tooltip: {
shared: true,
useHTML: true,
headerFormat: '<b>{point.key}</b><table>',
pointFormat: '<tr><td style="color: {series.color}">{series.name}: </td>' +
'<td style="text-align: right"><b>${point.y}</b></td></tr>',
footerFormat: '<tr><td>Total: </td>' +
'<td style="text-align: right"><b>${point.total}</b></td></tr>',
valueDecimals: 2
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false
}
}
},
series: [{
color:'#76b7f8',
name: 'Category 1 funding',
data: [198, 10, 0, 0, 0, 0, 0, 0, 78, 55, 78, 0, 0, 4, 8]
}, {
color:'#FDC8A3',
name: 'Category 2 funding',
data:[10, 10, 0, 0, 0, 0, 0, 0, 7, 5, 78, 0, 20, 4, 8]
}, {
color:'#7FEDD9',
name: 'Category 3 funding',
data: [14, 10, 0, 0, 0, 0, 0, 0, 78, 55, 78, 0, 0, 4, 8]
},
{
color:'#FFC0CC',
name: 'Category 4 funding',
data: [12, 10, 0, 0, 0, 0, 0, 0, 78, 55, 78, 0, 0, 4, 8]
}]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment