Hi,

Whenever I run the servlet by saying, say
http://localhost:8080/myWebApp/csv?url=http://localhost:8080/myWebApp/Example.csv,
it displays the columns, specifying 1st column is a type date.


 It doesn't throw any exception. Whenever I run the html page, it doesn't
show anything. I change it into a line chart or some other chart, it works.

Here's the html code:

 <!DOCTYPE html>
<html>
<head>
  <title>All Examples</title>
  <!--Load the AJAX API-->
  <script type="text/javascript" src="http://www.google.com/jsapi";></script>
  <script type="text/javascript">

  // Load the Visualization API and the ready-made Google table
visualization.
  google.load('visualization', '1',
{'packages':['piechart,annotatedtimeline,linechart,barchart']});
//google.load('visualization', '1', {'packages':['annotatedtimeline']});

  // Set a callback to run when the API is loaded.
  google.setOnLoadCallback(init);

  // Send the queries to the data sources.
  function init() {

    //var query = new google.visualization.Query('simpleexample?tq=select
name,population');
    //query.send(handleSimpleDsResponse);

    query = new google.visualization.Query('csv?url=
http://localhost:8080/myWebApp/Format1.csv');
    query.send(handleCsvDsResponse);

    //query = new
google.visualization.Query('advanced?tableId=planets&tq=select
planet,mass');
    //query.send(handleAdvancedDsResponse);

    //drawToolbar();
  }



  // Handle the csv data source query response
  function handleCsvDsResponse(response) {
    if (response.isError()) {
      alert('Error in query: ' + response.getMessage() + ' ' +
response.getDetailedMessage());
      return;
    }


    var data = response.getDataTable();
    var chart = new
google.visualization.AnnotatedTimeLine(document.getElementById('csv_div'));
    chart.draw(data, {displayAnnotations:true});

   //var data = response.getDataTable();
  // var chart = new
google.visualization.PieChart(document.getElementById('csv_div'));
   //chart.draw(data, {width: 600, height: 150, is3D: true});

   // var data = response.getDataTable();
  //var chart = new
google.visualization.LineChart(document.getElementById('csv_div'));
   //chart.draw(data, {width: 1100, height: 600, legend:'bottom',title:'Line
Chart' });
  }



  </script>
</head>
<body>

  <h1> CSV Data Source </h1>

  <div id="csv_div"></div>


</body>
</html>







On Mon, Feb 15, 2010 at 7:31 AM, Viz Kid <[email protected]> wrote:

>
> Hi.
>
> Can you give some information on what happens during this process? Is some
> exception is thrown or than indeed the created data table has the proper
> values and types?
>
> Best,
>   Viz Kid
>
>   On Fri, Feb 12, 2010 at 11:22 PM, ramyag539 <[email protected]> wrote:
>
>>  Hi,
>>
>> I want to display an annotated timeline from a csv file. I used the
>> example in the documentation as a guide. However, I am having trouble
>> with the date column. I specified in the servlet that the first column
>> is a date type, but I'm still unable to read and display it. Could you
>> tell me what else I have to do to specify that the csv file 1st column
>> is a date? Should I keep the column dates in csv file in a specific
>> format? Thank You.
>>
>> Here's the servlet code:
>>
>> DataTable dataTable = null;
>>    ULocale requestLocale =
>> DataSourceHelper.getLocaleFromRequest(request);
>>    try {
>>
>>        ColumnDescription cd=new ColumnDescription("start.date",
>> ValueType.DATE, "start.date");
>>        ColumnDescription cd2=new ColumnDescription("y-value",
>> ValueType.NUMBER, "y-value");
>>      List<ColumnDescription> ls=new ArrayList<ColumnDescription>();
>>      ls.add(cd);
>>      ls.add(cd2);
>>        dataTable = CsvDataSourceHelper.read(reader, ls, true,
>> requestLocale);
>>    } catch (IOException e) {
>>      log.error("Couldn't read from url: " + url, e);
>>      throw new DataSourceException(ReasonType.INVALID_REQUEST,
>> "Couldn't read from url: " + url);
>>    }
>>    return dataTable;
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Visualization API" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-visualization-api%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-visualization-api?hl=en.
>>
>>
>   --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-visualization-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-visualization-api?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to