3d-pie.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*=========================================================================================
  2. File Name: 3d-pie.js
  3. Description: google 3D pie 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. // 3D Pie 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(drawPie3d);
  16. // Callback that creates and populates a data table, instantiates the pie chart, passes in the data and draws it.
  17. function drawPie3d() {
  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_pie3d = {
  29. title: 'My Daily Activities',
  30. is3D: true,
  31. height: 400,
  32. fontSize: 12,
  33. colors:['#99B898','#FECEA8', '#FF847C', '#E84A5F', '#474747'],
  34. chartArea: {
  35. left: '5%',
  36. width: '90%',
  37. height: 350
  38. },
  39. };
  40. // Instantiate and draw our chart, passing in some options.
  41. var pie3d = new google.visualization.PieChart(document.getElementById('pie-3d'));
  42. pie3d.draw(data, options_pie3d);
  43. }
  44. // Resize chart
  45. // ------------------------------
  46. $(function () {
  47. // Resize chart on menu width change and window resize
  48. $(window).on('resize', resize);
  49. $(".menu-toggle").on('click', resize);
  50. // Resize function
  51. function resize() {
  52. drawPie3d();
  53. }
  54. });