Created
July 13, 2014 09:31
-
-
Save bollu/139f3587cab79d92e569 to your computer and use it in GitHub Desktop.
Abstraction over HighCharts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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