Jugal | Auto Redraw/Recalculate Pie on Legend | Highchart & Highstock
http://stackoverflow.com/questions/10514025/redraw-pie-chart-in-highchart
Jugal Thakkar
http://jugal.me/
by Jugal Thakkar
HTML
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
<script type="text/javascript" src="http://code.jugal.me/js/jugalsLib.js"></script>
<script type="text/javascript" src="http://code.highcharts.com/stock/highstock.src.js"></script>
<script type="text/javascript" src="http://code.highcharts.com/stock/modules/exporting.src.js"></script>
<div id="container"></div>
CSS
#container {
min-width:500px;
}
JavaScript
var chartingOptions = {
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
formatter: function () {
return this.y + " ( " + this.percentage.toFixed(2) + " % )";
}
},
showInLegend: true
}
},
series: [{
ignoreHiddenPoint: true,
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8], {
name: 'Chrome',
y: 12.8,
visible: false
}, ['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
}]
};
chartingOptions = $.extend({}, jugalsLib.getBasicChartOptions(), chartingOptions);
var chart = new Highcharts.Chart(chartingOptions);