Skip to content

Instantly share code, notes, and snippets.

@bollu
Created July 13, 2014 09:31
Show Gist options
  • Select an option

  • Save bollu/139f3587cab79d92e569 to your computer and use it in GitHub Desktop.

Select an option

Save bollu/139f3587cab79d92e569 to your computer and use it in GitHub Desktop.
Abstraction over HighCharts
function draw_pie_chart(container_selector, name, title, data) {
// Build the chart
$(container_selector).highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: title
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
type: 'pie',
name: name,
data: data
}]
});
}
function gen_pie_chart(container_selector, name, title, json_file_path) {
function init_pie_chart(json_data) {
draw_pie_chart(container_selector, name, title, json_data);
};
$.ajax({
url: json_file_path,
success: init_pie_chart
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment