Highcharts Pie With legend to right
HTML
<!-- version 4 -->
<script src="http://code.highcharts.com/highcharts.js"></script>
<!-- NOTE height has to be px for the jQuery code to work out the position of where to put the legend -->
<div id="container" style="height: 160px; min-width: 470px;"></div>
JavaScript
$(function () {
$(document).ready(function () {
// Build the chart
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
margin: [0, 200, 0, 0],
spacingTop: 0,
spacingBottom: 0,
spacingLeft: 0,
spacingRight: 0
},
title: {
text: 'Width:'+$(this).find('#container').width()+' height:'+$(this).find('#container').height()
},
legend: {
enabled: true,
floating: true,
verticalAlign: 'xbottom',
marginTop: '50',
align:'right',
layout: 'vertical',
y: $(this).find('#container').height()/4, //chart.height/4
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
size:'90%',
dataLabels: {
enabled: false,
center:['10%', '10%']
},
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox Firefox Firefox', 45.0],
['IE IE IE IE IE IE IE IE IE IE IE', 26.8],
['Chrome', 12.8],
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
}]
});
});
});