//= require highcharts
//= require highcharts/highcharts-more
//= require highcharts/modules/drilldown
(function( $ ){
$.fn.pie_chart = function(title, data) {
// Create the chart
$(this).highcharts({
chart: {
type: 'pie'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}: {point.y}'
}
}
},
credits: {
enabled: false
},
tooltip: {
headerFormat: '{series.name}
',
pointFormat: '{point.name}: {point.percentage:.2f}% of total
'
},
series: [{
name: title,
colorByPoint: true,
data: data.series
}],
title: null,
drilldown: data.drilldown
});
};
})( jQuery );
Blacklight.onLoad(function () {
$('.stats-pie').each (function () {
series = $(this).data('series');
title = $(this).data('title');
drilldown = $(this).data('drilldown');
$(this).pie_chart(title, series, drilldown);
});
});