donut-exploded.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*=========================================================================================
  2. File Name: donut-exploded.js
  3. Description: google donut exploded chart
  4. ----------------------------------------------------------------------------------------
  5. Item Name: Robust - Responsive Admin Theme
  6. Version: 1.2
  7. Author: PIXINVENT
  8. Author URL: http://www.themeforest.net/user/pixinvent
  9. ==========================================================================================*/
  10. // Donut exploded chart
  11. // ------------------------------
  12. // Load the Visualization API and the corechart package.
  13. google.load('visualization', '1.0', {'packages':['corechart']});
  14. // Set a callback to run when the Google Visualization API is loaded.
  15. google.setOnLoadCallback(drawDonutExploded);
  16. // Callback that creates and populates a data table, instantiates the pie chart, passes in the data and draws it.
  17. function drawDonutExploded() {
  18. // Create the data table.
  19. var data = google.visualization.arrayToDataTable([
  20. ['Task', 'Hours per Day'],
  21. ['Work', 11],
  22. ['Eat', 2],
  23. ['Commute', 2],
  24. ['Watch TV', 2],
  25. ['Sleep', 7]
  26. ]);
  27. // Set chart options
  28. var options_donut_exploded = {
  29. title: 'My Daily Activities',
  30. height: 400,
  31. fontSize: 12,
  32. colors:['#99B898','#FECEA8', '#FF847C', '#E84A5F', '#474747'],
  33. pieHole: 0.55,
  34. chartArea: {
  35. left: '5%',
  36. width: '90%',
  37. height: 350
  38. },
  39. slices: {
  40. 1: {offset: 0.15},
  41. 3: {offset: 0.1},
  42. 4: {offset: 0.12},
  43. 5: {offset: 0.1}
  44. }
  45. };
  46. // Instantiate and draw our chart, passing in some options.
  47. var donutExploded = new google.visualization.PieChart(document.getElementById('donut-exploded'));
  48. donutExploded.draw(data, options_donut_exploded);
  49. }
  50. // Resize chart
  51. // ------------------------------
  52. $(function () {
  53. // Resize chart on menu width change and window resize
  54. $(window).on('resize', resize);
  55. $(".menu-toggle").on('click', resize);
  56. // Resize function
  57. function resize() {
  58. drawDonutExploded();
  59. }
  60. });