Ajuda VRaptor + Google Charts

E aew Galera…

Estou com o seguinte problema, preciso gerar um grafico com base no resultado de uma consulta do BD.
mais nao sei como realizar a integracao entre o VRaptor e Google Charts

[code]@Resource
public class MainController {

private final Result result;
private final DaoFactory dao;
private final UsuarioWeb usuarioWeb;
private final Validator validator;
private final Session session;

public MainController(DaoFactory dao, Result result,
		UsuarioWeb usuarioWeb, Validator validator, Session session) {
	this.dao = dao;
	this.result = result;
	this.usuarioWeb = usuarioWeb;
	this.validator = validator;
	this.session = session;

}

@Path("/principal")
public void main() {
	this.result.include("data", new Date());
	this.result.use(Results.json()).withoutRoot().from(this.buscaDados()).serialize();
}

private List buscaDados(){
	
	Criteria c = session.createCriteria(Visita.class, "v")
			.createAlias("v.tipo", "tv", Criteria.INNER_JOIN)
			.setProjection(Projections.projectionList()
             //   .add(Projections.groupProperty("tv.id"))
                .add(Projections.groupProperty("tv.tipo"))
                .add(Projections.count("tv.id")))
	.add(Restrictions.eq("v.tecnico.codigo", new Long(414042)));
	
	return c.list();
	
}[/code]

Trecho do codigo para geracao do grafico
Exemplo pagina do Google
Pagina JSP

<script type="text/javascript">

		      // Load the Visualization API and the piechart package.
		      google.load('visualization', '1.0', {'packages':['corechart']});
		
		      // Set a callback to run when the Google Visualization API is loaded.
		      google.setOnLoadCallback(drawChart);
		
		      // Callback that creates and populates a data table,
		      // instantiates the pie chart, passes in the data and
		      // draws it.
		      function drawChart() {
		
		        // Create the data table.
		        var data = new google.visualization.DataTable();
		        data.addColumn('string', 'Topping');
		        data.addColumn('number', 'Slices');
		        data.addRows([
		          ['Mushrooms', 3],
		          ['Onions', 1],
		          ['Olives', 1],
		          ['Zucchini', 1],
		          ['Pepperoni', 2]
		        ]);
		
		        // Set chart options
		        var options = {'title':'How Much Pizza I Ate Last Night',
		                       'width':400,
		                       'height':300};
		
		        // Instantiate and draw our chart, passing in some options.
		        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
		        chart.draw(data, options);
		      }
	    </script>

eu nao sei como pegar o meu json e setar no grafico

vc precisa transformar o resultado do json e transformar nos dados pra passar pra variável data do gráfico.

provavelmente no addRows.

Mais como eu faco este processo, não tenho experiencia com javascript

processo:

  • faça a requisição pro seu controller usando ajax (pode ser via JQuery $.getJSON

  • veja qual é o formato em que o json chegou usando o console do seu navegador (Developer tools ou Firebug)

  • transforme esse json no formato que o charts espera (arrays de arrays, ou varios addRow’s de um array só)

tem um curso online da caelum que explica melhor o charts:

Eu quero carregar o grafico logo após uma requisicão post,

então vc pode usar o $.post do jquery ao invés do $.getJSON

Mais eu nao sei como usar o $.post Via JavaScript, não tenho experiencia com javascript

vc já disse que não tem experiência. Mas se eu te der a resposta, vc não vai aprender :wink: É bem importante entender o que está acontecendo, senão vc estará preso ao guj sempre que precisar fazer uma coisa nova.

existem vários tópicos aqui no guj sobre isso, e a documentação do jQuery é muito boa (em inglês)

procura sobre o $.post e veja como é o seu uso. Se você conseguir me explicar como ele funciona eu continuo te ajudando :wink:

Desculpe,
mais necessito destes gráficos para entregar um projeto esta semana,
eu ja tinha visto outros posts no qual voce, ajudou uma outra pessoa, http://www.guj.com.br/java/245448-grafico-com-vraptor-e-api-google-chart-resolvido
mais so não consegui entender onde eu chamo a funcão
por exemplo, e adiciono os dados no grafico

$.getJSON('/url/da/logica', function(bcisPorTerreno) {  
    var rows = [];  
    $(bcisPorTerreno).each(function() {  
        rows.push( [this.uso, this.total] );  
    });  
      
   //...  
   data.addRows(rows);  
});  

estou terminando um curso de Design Patterns Online, e logo em seguida irei realizar o de VRaptor, pois
acho fantástico este framework

A funcão $.post é utilizada para realizar uma requisicao post via ajax,

onde o primeiro argumento da funcao e a paginal ou url para onde a requisicao será direcionada,
o segundo argumento são os dados que serão enviados para o servidor para realizar o cadastro por exemplo,
o terceiro e uma funcao de callback onde sera tratado o retorno do servidor.

qual é o motivo de você fazer um post e não um get?

o getJSON que vc faria é bem parecido com o que vc postou, vc só trocaria a url (e parametros talvez), e ao invés de bcisPorTerreno seria a estrutura do objeto que vc está retornando.

como tá vindo o json, e quais são os dados que vc quer mostrar no gráfico?

Desculpe, eu não tinha explicado antes…

É o seguinte, quando o usuario realiza o login, uma requisicao post e gerada para um metodo no controller que valida o usuário, apos a validacao eu faco um result.redirectTo(MainController.class).main();
que chama a pagina main, neste momento ao carregar a main eu ja queria montar o grafico com os dados da consulta do metodo buscaDados. Mais não sei se isto esta correto.

vc quer mostrar os dados logo de cara na página?

se sim, não precisa fazer via ajax, pode simplesmente gerar o javascript necessário usando jsp mesmo:

<script>
function drawChart() {  
     var data = new google.visualization.DataTable();  
     data.addColumn('string', 'Topping');  
     data.addColumn('number', 'Slices');  
     <c:forEach items="${osItems}", var="item">
       data.addRow([${item.algo}, ${item.outroAlgo}]);
    </c:forEach>
     //....
}  
</script>

ao executar como o exemplo anterior estou recebendo a seguinte stracktrace

[quote]java.lang.NumberFormatException: For input string: “tipo”
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:166)
at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:46)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:985)
at org.apache.jsp.WEB_002dINF.jsp.main.main_jsp._jspx_meth_c_005fforEach_005f0(main_jsp.java:479)
at org.apache.jsp.WEB_002dINF.jsp.main.main_jsp._jspService(main_jsp.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at br.com.caelum.vraptor.core.DefaultStaticContentHandler.deferProcessingToContainer(DefaultStaticContentHandler.java:64)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:80)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:67)
at br.com.caelum.vraptor.interceptor.ForwardToDefaultViewInterceptor.intercept(ForwardToDefaultViewInterceptor.java:60)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:85)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.util.hibernate.HibernateTransactionInterceptor.intercept(HibernateTransactionInterceptor.java:48)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:83)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Feb 13, 2012 6:17:50 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [default] in context with path [/sistecamGraphs] threw exception
br.com.caelum.vraptor.view.ResultException: org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/main/main.jsp at line 27

24: data.addColumn(‘number’, ‘Quantidade’);
25:
26: <c:forEach items="${dadosGraficos}" var=“i”>
27: data.addRow([${i.tipo}, ${item.total}]);
28: </c:forEach>
29:
30: data.addRows();

Stacktrace:
at br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:69)
at br.com.caelum.vraptor.interceptor.ForwardToDefaultViewInterceptor.intercept(ForwardToDefaultViewInterceptor.java:60)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:85)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.util.hibernate.HibernateTransactionInterceptor.intercept(HibernateTransactionInterceptor.java:48)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:83)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/main/main.jsp at line 27

24: data.addColumn(‘number’, ‘Quantidade’);
25:
26: <c:forEach items="${dadosGraficos}" var=“i”>
27: data.addRow([${i.tipo}, ${item.total}]);
28: </c:forEach>
29:
30: data.addRows();

Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at br.com.caelum.vraptor.core.DefaultStaticContentHandler.deferProcessingToContainer(DefaultStaticContentHandler.java:64)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:80)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:67)
… 53 more
Caused by: java.lang.NumberFormatException: For input string: “tipo”
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:166)
at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:46)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:985)
at org.apache.jsp.WEB_002dINF.jsp.main.main_jsp._jspx_meth_c_005fforEach_005f0(main_jsp.java:479)
at org.apache.jsp.WEB_002dINF.jsp.main.main_jsp._jspService(main_jsp.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
… 67 more
[/quote]

[code]function drawChart() {

	        // Create the data table.
	        var data = new google.visualization.DataTable();
	        data.addColumn('string', 'Tipo');
	        data.addColumn('number', 'Quantidade');

	        <c:forEach items="${dadosGraficos}" var="i">  
	        	data.addRow([${i.tipo}, ${i.total}]);  
	     	</c:forEach>
	        
	        data.addRows();  
	    
	        // Set chart options
	        var options = {'title':'How Much Pizza I Ate Last Night',
	                       'width':400,
	                       'height':300};
	
	        // Instantiate and draw our chart, passing in some options.
	        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
	        chart.draw(data, options);
	      }[/code]

no codigo onde adicionamos os dados data.addRow ta com erro de compilacao

${dadosGraficos} é uma lista de que?

É uma lista List<Object[]>

e Object[] tem a propriedade tipo? :wink:

se é um object[] vc precisa usá-lo como o tal lá no c:forEach… algo como i[0], i[1], i[2], etc

Fiz da seguinte maneira mais nao funcionou

var rows = []; 
		        
		        <c:forEach items="${dadosGraficos}" var="i">  
		        	rows.push( [${i[0]}, ${i[1]}] ); 		
		     	</c:forEach>
				
		     	data.addRows(rows);

e no codigo fonte da pagina apareceu

<script type="text/javascript">

		      // Load the Visualization API and the piechart package.
		      google.load('visualization', '1.0', {'packages':['corechart']});
		
		      // Set a callback to run when the Google Visualization API is loaded.
		      google.setOnLoadCallback(drawChart);

		      
		      // Callback that creates and populates a data table,
		      // instantiates the pie chart, passes in the data and
		      // draws it.
		      function drawChart() {
		
		        // Create the data table.
		        var data = new google.visualization.DataTable();
		        data.addColumn('string', 'Tipo');
		        data.addColumn('number', 'Quantidade');

		        var rows = []; 
		        
		          
		        	rows.push( [PREVENTIVA, 28] ); 		
		     	  
		        	rows.push( [TESTE DE PRODUTO, 6] ); 		
		     	  
		        	rows.push( [CONSULTIVA, 25] ); 		
		     	  
		        	rows.push( [CORRETIVA, 10] ); 		
		     	
				
		     	data.addRows(rows);
		     	
		        // Set chart options
		        var options = {'title':'How Much Pizza I Ate Last Night',
		                       'width':400,
		                       'height':300};
		
		        // Instantiate and draw our chart, passing in some options.
		        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
		        chart.draw(data, options);
		      }
	    </script>

só pra ficar mais legalzinho, coloque aspas em volta do i[0]:

rows.push( ['${i[0]}', ${i[1]}] ); 

assim os nomes vão ficar corretos (deve ter ido tudo como undefined)

Isto mesmo Lucas,
Muito Obrigado pela ajuda e compreensao

eu fiz da seguinte maneira

function drawChart() {
		
		        // Create the data table.
		        var data = new google.visualization.DataTable();
		        data.addColumn('string', 'Tipo');
		        data.addColumn('number', 'Quantidade');

		        var rows = []; 

		        <c:forEach items="${dadosGraficos}" var="i">
		        	rows.push( ['${i[0]}', ${i[1]}] ); 		
		     	</c:forEach>
		   
		     	data.addRows(rows);
		     			     	
		        // Set chart options
		        var options = {'title':'Gráfico por Tipo de Visitas',
		                       'width':500,
		                       'height':350};
		
		        // Instantiate and draw our chart, passing in some options.
		        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
		        chart.draw(data, options);
		      }