line-interval.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*=========================================================================================
  2. File Name: line-interval.js
  3. Description: google line 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. // Line 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(drawLineInterval);
  16. // Callback that creates and populates a data table, instantiates the pie chart, passes in the data and draws it.
  17. function drawLineInterval() {
  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_line_interval = {
  40. height: 400,
  41. fontSize: 12,
  42. curveType: 'function',
  43. lineWidth: 4,
  44. intervals: { 'style':'line' },
  45. series: [{'color': '#1DE9B6'}],
  46. chartArea: {
  47. left: '5%',
  48. width: '90%',
  49. height: 350
  50. },
  51. vAxis: {
  52. gridlines:{
  53. color: '#e9e9e9',
  54. count: 5
  55. },
  56. minValue: 0
  57. },
  58. hAxis: {
  59. gridlines:{
  60. color: '#e9e9e9',
  61. count: 5
  62. },
  63. minValue: 0.5,
  64. maxValue: 8.5
  65. },
  66. legend: {
  67. position: 'top',
  68. alignment: 'center',
  69. textStyle: {
  70. fontSize: 12
  71. }
  72. }
  73. };
  74. // Instantiate and draw our chart, passing in some options.
  75. var line = new google.visualization.LineChart(document.getElementById('line-interval'));
  76. line.draw(data, options_line_interval);
  77. }
  78. // Resize chart
  79. // ------------------------------
  80. $(function () {
  81. // Resize chart on menu width change and window resize
  82. $(window).on('resize', resize);
  83. $(".menu-toggle").on('click', resize);
  84. // Resize function
  85. function resize() {
  86. drawLineInterval();
  87. }
  88. });