Ok, so after trying really hard for some days i am still not able to make 
this work.

This is the problem: I have a JSP which hosts a Google chart that is going 
to be constructed from data that is going to be sent through a Servlet. I'm 
using the Google Visualization Java libraries to implement this servlet.

Then i have this helper function that, taking some data stored in a list of 
objects, constructs a datatable. Following is the class that implements 
said function:

        
public class DataTableGenerator {
        
        public static DataTable generateDatatable(List<AccesoUrl> accesos) {
            
            DataTable data = new DataTable();
            
            ArrayList<ColumnDescription> cd = new ArrayList<>();
            cd.add(new ColumnDescription("fecha", ValueType.DATE, "Fecha"));
            cd.add(new ColumnDescription("navegador", ValueType.TEXT, 
"Navegador"));
            cd.add(new ColumnDescription("ip", ValueType.TEXT, "IP"));
            cd.add(new ColumnDescription("os", ValueType.TEXT, "Sistema 
Operativo"));
            
            data.addColumns(cd);
            
                    
            try {
    
                for(AccesoUrl acceso : accesos) {
                    GregorianCalendar calendario = new GregorianCalendar();
                    calendario.setTimeZone(TimeZone.getTimeZone("GMT"));   
             
                    
                    data.addRowFromValues(calendario, acceso.getNavegador(), 
acceso.getIp(), acceso.getSistemaoperativo());
                    
                }
                
            } catch (TypeMismatchException e) {
                System.out.println(e);
            }
            
            return data;
        }
    }



Now, this piece of code should work, but instead i am getting this 
exception on my web server:

com.google.visualization.datasource.base.TypeMismatchException: Value type 
mismatch.
    at 
com.google.visualization.datasource.datatable.value.ValueType.createValue(Unknown
 
Source)
    at 
com.google.visualization.datasource.datatable.DataTable.addRowFromValues(Unknown
 
Source)

I'm at wit's end now. I have tried every variation i could find on Google 
so that my JSP displays this data on a Google Table type of chart. I have 
tried sending a date as a string, a date as a string formatted as a 
javascript date (i.e "Date(2015,4,4)" or "new Date(2015,4,4)"). I have 
tried using the DateValue object that comes with the java visualization 
library to construct the date as well (i.e new DateValue(2015,4,4)). I have 
also tried passing a Java Date as well. Nothing works, everything throws a 
TypeMismatchException.

I am sure it's the date that's giving me trouble because as soon as i 
remove the date column from the datatable everything runs fine with no 
exception and i can get my data displayed on the Google chart table.

So can anybody please tell me what exactly do i have to do in my Java code 
to be able to construct a datatable with a date cell?


-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to