Guest User

Untitled

a guest
Mar 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. //----------------------------------------Gerando Chart de Relatório Bolsa Por Ano
  2.  
  3. $scope.gerarGraficoBolsaPorOrientador = function gerarGraficoBolsaPorProfessor(ano_inicial,ano_final,departamento){
  4.  
  5. //busca dados
  6. var rows = [];
  7. var data = { ano_inicial: ano_inicial ,
  8. ano_final: ano_final,
  9. departamento: departamento };
  10. $http.post('get_chart_relatorio_bolsa_por_orientador', data).then(function(resposta){
  11. if (resposta.data.status === "error"){
  12. toastr["error"]('', resposta.data.message);
  13. }
  14.  
  15. for (var i in resposta.data){
  16. rows.push({
  17. c: [resposta.data[i]]
  18. });
  19. }
  20.  
  21. //desenha Chart
  22. $scope.chartRelatorioProjetoPorOrientador = {};
  23.  
  24. $scope.chartRelatorioProjetoPorOrientador.type = "BarChart";
  25.  
  26. $scope.chartRelatorioProjetoPorOrientador.options = {
  27. 'title': 'Gráfico de barra: Bolsas por orientador',
  28. colors: ['#ff0000', 'red blue gabriel'],
  29. legend:{position: 'bottom'},
  30. chartArea: {width: '50%'},
  31. hAxis: {
  32. title: 'Quantidade de bolsas por orientador',
  33. minValue: 0,
  34. textStyle: {
  35. bold: true,
  36. fontSize: 12,
  37. color: '#4d4d4d'
  38. },
  39. titleTextStyle: {
  40. bold: true,
  41. fontSize: 18,
  42. color: '#4d4d4d'
  43. }
  44. },
  45. vAxis: {
  46. textStyle: {
  47. fontSize: 12,
  48. bold: true,
  49. color: '#848484'
  50. }
  51. },
  52. width: $(window).width()*0.75,
  53. height: $(window).height()*1
  54. };
  55.  
  56. var chartGerado = new google.visualization.DataTable();
  57.  
  58. chartGerado.addColumn({id: "t", label: "Topping", type: "string"});
  59. chartGerado.addColumn({id: "s", label: "Bolsas", type: "number"});
  60. chartGerado.addColumn({id: "l", label: "Label", type: "number", role:"annotation"});
  61. chartGerado.addColumn({id: "x", label: "Cor", type:"string", role:"style"});
  62. chartGerado.addRows(rows.length);
  63. for(var i = 0; i < rows.length; i++){
  64. chartGerado.setCell(
  65. i,0,rows[i].c["0"].orientador
  66. );
  67. chartGerado.setCell(
  68. i,1,rows[i].c["0"].bolsas
  69. );
  70. chartGerado.setCell(
  71. i,2,rows[i].c["0"].bolsas
  72. );
  73. chartGerado.setCell(
  74. i,3,'color: #ff0000'
  75. );
  76. }
  77.  
  78. $scope.chartRelatorioProjetoPorOrientador.data = chartGerado;
  79.  
  80. var my_div = document.getElementById('chartRelatorioProjetoPorOrientador');
  81. var my_chart = new google.visualization.ChartType(BarChart);
  82.  
  83. google.visualization.events.addListener(my_chart, 'ready', function () {
  84. my_div.innerHTML = '<img src="' + my_chart.getImageURI() + '">';
  85. });
  86.  
  87. my_chart.draw(chartGerado,options);
  88.  
  89. });
  90.  
  91. };
  92.  
  93. <div google-chart id="chartRelatorioProjetoPorOrientador" chart="chartRelatorioProjetoPorOrientador" style="height:100%; width:100%; left: 10; top: 20; overflow:scroll;"></div>
Add Comment
Please, Sign In to add comment