pie-exploded.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*=========================================================================================
  2. File Name: pie-expolded.js
  3. Description: google pie 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. // Pie 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(drawPieExploded);
  16. // Callback that creates and populates a data table, instantiates the pie chart, passes in the data and draws it.
  17. function drawPieExploded() {
  18. // Create the data table.
  19. var data = google.visualization.arrayToDataTable([
  20. ['Task', 'Hours per Day'],
  21. ['Work', 10],
  22. ['Eat', 1.5],
  23. ['Commute', 2.5],
  24. ['Watch TV', 3],
  25. ['Sleep', 7]
  26. ]);
  27. // Set chart options
  28. var options_bar = {
  29. title: 'My Daily Activities',
  30. height: 400,
  31. fontSize: 12,
  32. colors:['#99B898','#FECEA8', '#FF847C', '#E84A5F', '#474747'],
  33. chartArea: {
  34. left: '5%',
  35. width: '90%',
  36. height: 350
  37. },
  38. slices: {
  39. 1: {offset: 0.15},
  40. 3: {offset: 0.1},
  41. 4: {offset: 0.12},
  42. 5: {offset: 0.1}
  43. }
  44. };
  45. // Instantiate and draw our chart, passing in some options.
  46. var bar = new google.visualization.PieChart(document.getElementById('pie-exploded'));
  47. bar.draw(data, options_bar);
  48. }
  49. // Resize chart
  50. // ------------------------------
  51. $(function () {
  52. // Resize chart on menu width change and window resize
  53. $(window).on('resize', resize);
  54. $(".menu-toggle").on('click', resize);
  55. // Resize function
  56. function resize() {
  57. drawPieExploded();
  58. }
  59. });