area-interval.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*=========================================================================================
  2. File Name: area-interval.js
  3. Description: google area interval 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. // Area Interval 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(drawAreaInterval);
  16. // Callback that creates and populates a data table, instantiates the pie chart, passes in the data and draws it.
  17. function drawAreaInterval() {
  18. // Create the data table.
  19. var data = new google.visualization.DataTable();
  20. data.addColumn('number', 'x');
  21. data.addColumn('number', 'values');
  22. data.addColumn({id:'i0', type:'number', role:'interval'});
  23. data.addColumn({id:'i1', type:'number', role:'interval'});
  24. data.addColumn({id:'i2', type:'number', role:'interval'});
  25. data.addColumn({id:'i2', type:'number', role:'interval'});
  26. data.addColumn({id:'i2', type:'number', role:'interval'});
  27. data.addColumn({id:'i2', type:'number', role:'interval'});
  28. data.addRows([
  29. [1, 100, 90, 110, 85, 96, 104, 120],
  30. [2, 120, 95, 130, 90, 113, 124, 140],
  31. [3, 130, 105, 140, 100, 117, 133, 139],
  32. [4, 90, 85, 95, 85, 88, 92, 95],
  33. [5, 70, 74, 63, 67, 69, 70, 72],
  34. [6, 30, 39, 22, 21, 28, 34, 40],
  35. [7, 80, 77, 83, 70, 77, 85, 90],
  36. [8, 100, 90, 110, 85, 95, 102, 110]
  37. ]);
  38. // Set chart options
  39. var options_area_interval = {
  40. title: 'Line intervals, default',
  41. height: 400,
  42. fontSize: 12,
  43. curveType: 'function',
  44. lineWidth: 4,
  45. intervals: { 'style':'area' },
  46. series: [{'color': '#80cbe7'}],
  47. chartArea: {
  48. left: '5%',
  49. width: '90%',
  50. height: 350
  51. },
  52. vAxis: {
  53. gridlines:{
  54. color: '#e9e9e9',
  55. count: 5
  56. },
  57. minValue: 0
  58. },
  59. hAxis: {
  60. gridlines:{
  61. color: '#e9e9e9',
  62. count: 5
  63. },
  64. minValue: 0.5,
  65. maxValue: 8.5
  66. },
  67. legend: {
  68. position: 'top',
  69. alignment: 'center',
  70. textStyle: {
  71. fontSize: 12
  72. }
  73. }
  74. };
  75. // Instantiate and draw our chart, passing in some options.
  76. var area = new google.visualization.LineChart(document.getElementById('area-interval'));
  77. area.draw(data, options_area_interval);
  78. }
  79. // Resize chart
  80. // ------------------------------
  81. $(function () {
  82. // Resize chart on menu width change and window resize
  83. $(window).on('resize', resize);
  84. $(".menu-toggle").on('click', resize);
  85. // Resize function
  86. function resize() {
  87. drawAreaInterval();
  88. }
  89. });