JavaScript
$(function() {
var colors = ['blue', 'green', 'yellow', 'orange', 'red'],
names = ['First', 'Second', 'Third', 'Fourth', 'Fifth'],
values = [6, 7, 9, 1, 1];
$('#container').highcharts({
chart: {
type: 'bar',
},
title: {
text: 'Simple Bar Graph'
},
legend: {
align: 'right',
verticalAlign: 'top',
layout: 'vertical',
x: 0,
y: 80,
padding: 3,
itemMarginTop: 5,
useHTML: true,
itemMarginBottom: 5,
labelFormatter: function() {
return '<div style="width:100px;"><span style="float:left; margin-left:10px">' + names[this.index - 1] + '</span><span style="float:right">' + values[this.index - 1] + '</span></div>';
},
symbolRadius: 0,
},
xAxis: {
categories: ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'sixth', 'seventh'],
allowDecimals: false
},
yAxis: {
allowDecimals: false
},
plotOptions: {
series: {
grouping: false, //add to have center align every bar to its corresponding x axis
events: {
legendItemClick: function(x) {
var i = this.index - 1;
var series = this.chart.series[0];
var point = series.points[i];
if (point.oldY == undefined)
point.oldY = point.y;
point.update({
y: point.y != null ? null : point.oldY
});
}
}
}
},
series: [{
pointPadding: 0,
groupPadding: 0,
borderWidth: 0,
color: colors[0],
showInLegend: false,
data: [{
y: 6,
name: 'First',
color: colors[0]
}, {
y: 7,
name: 'Second',
color: colors[1]
}, {
y: 9,
name: 'Third',
color: colors[2]
}, {
y: 1,
name: 'Fourth',
color: colors[3]
}, {
y: 1,
name: 'Fifth',
color: colors[4]
}, {
y: 1,
...