Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. <script type="text/javascript">
  2. /**
  3. * Request data from the server, add it to the graph and set a timeout
  4. * to request again
  5. */
  6.  
  7. var chart; // global
  8. function requestData() { //Atualizacao a cada 30 segundos
  9. $.ajax({
  10. url: 'simultaneas.php',
  11. success: function(point) {
  12. var series = chart.series[0],
  13. shift = series.data.length > 30; // shift if the series is
  14. // longer than 20
  15.  
  16. // add the point
  17. var values = eval(point);
  18. chart.series[0].addPoint(point, true, shift);
  19. // call it again after one second
  20. setTimeout(requestData, 30000);
  21. },
  22. cache: false
  23. });
  24. }
  25. $(document).ready(function() {
  26. Highcharts.setOptions({
  27. global: {
  28. useUTC: false
  29. }
  30. });
  31.  
  32. var auto_refresh;
  33.  
  34. window.onload = function() {
  35. funcaoAutoRefresh();
  36. }
  37.  
  38. function funcaoAutoRefresh() { // Atualiza a cada 30 segundos
  39. $("#telefonia").load("faturamento_dia.php");
  40.  
  41. auto_refresh = setTimeout(funcaoAutoRefresh(), 30000);
  42. }
  43.  
  44. chart = new Highcharts.Chart({
  45. chart: {
  46. renderTo: 'simultaneas',
  47. defaultSeriesType: 'spline',
  48. events: {
  49. load: requestData
  50. }
  51. },
  52. title: {
  53. text: 'Chamadas Simultaneas Servidores'
  54. },
  55. xAxis: {
  56. type: 'datetime',
  57. tickPixelInterval: 150,
  58. maxZoom: 20 * 1000
  59. },
  60. yAxis: {
  61. minPadding: 0.2,
  62. maxPadding: 0.2,
  63. title: {
  64. text: '',
  65. margin: 0
  66. }
  67. },
  68. plotOptions: {
  69. spline: {
  70. dataLabels: {
  71. enabled: true
  72. },
  73. enableMouseTracking: false
  74. }
  75. },
  76. series: [{
  77. name: 'Atendidas',
  78. data: []
  79. }]
  80. });
  81. });
  82. $(function () { // NAO ATUALIA .. só quando carrega a pagina.
  83. // Create the first chart
  84. $('#fatultimosdias').highcharts({
  85. chart: {
  86. type: 'column'
  87. },
  88. title: {
  89. text: 'Faturamento Ultimos Dias'
  90. },
  91. xAxis: {
  92. categories: <?php echo json_encode($datetimefatdias, JSON_NUMERIC_CHECK) ?>,
  93. labels: {
  94. style: {
  95. color: 'black',
  96. fontSize:'19px'
  97. }
  98. }
  99. },
  100. yAxis: {
  101. min: 0,
  102. title: {
  103. text: 'Venda'
  104. },
  105. labels: {
  106. overflow: 'justify'
  107. }
  108. },
  109. legend: {
  110. reversed: true
  111. },
  112. plotOptions: {
  113. column: {
  114. dataLabels: {
  115. enabled: true
  116. }
  117. }
  118. },
  119. series: [{
  120. name: 'Venda ( em R$ )',
  121. data: <?php echo json_encode($datavenda, JSON_NUMERIC_CHECK) ?>
  122. },
  123. {
  124. name: 'Custo ( em R$ )',
  125. data: <?php echo json_encode($datacusto, JSON_NUMERIC_CHECK) ?>
  126. },
  127. {
  128. name: 'Revendas ( em R$ )',
  129. data: <?php echo json_encode($datarevenda, JSON_NUMERIC_CHECK) ?>
  130. }]
  131. });
  132. });
  133. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement