Re: [visualization-api] Re: motion chart using csv

86 views
Skip to first unread message

Maliki Yacouba

unread,
Jul 23, 2009, 12:14:56 PM7/23/09
to google-visua...@googlegroups.com
Hi ChartMan,
I did add the codes on the DataSourceServlet, but it still give me the same error massage.
I hope you can help with more steps.
thank you,
Maliky

----- Original Message -----
From: ChartMan <char...@google.com>
Date: Thursday, July 16, 2009 11:40 am
Subject: [visualization-api] Re: motion chart using csv

>
> The code you need to add in DataSourceServlet is quite simple.
> Something like :
>
>   DataTable dataTable = null;
> List<ColumnDescription> columnDescriptions = Lists.newArrayList();
> columnDescriptions.add(new ColumnDescription("i1",
> ValueType.NUMBER, null));
> columnDescriptions.add(new ColumnDescription("i2",
> ValueType.TEXT, null));
> columnDescriptions.add(new ColumnDescription("i3",
> ValueType.DATE, null));
> ....
>     try {
> dataTable = CsvDataSourceHelper.read(reader,
> columnDescriptions, false);
>     } catch (IOException e) {
>       log.error("Couldn't read from url inside
> CSVDataSource.read(): " + url);
>       throw new DataSourceException(ReasonType.INVALID_REQUEST,
> "Couldn't read from url: " + url);
>     }
>     return dataTable;
>
> Adding this to our example is an option but I am not sure it will
> happen in the near future.
>
> ChartMan
>
> On Thu, Jul 16, 2009 at 5:44 PM, Maliki Yacouba
> <my...@georgetown.edu> wrote:
> >
> > Hi ChartMan
> > I was about to  send you a new e-mail because I thought you
> didn't want to respond me anymore about this problem.
> >
> > The way you describe the problem makes sense to me. The only
> problem is that I am not an experienced programmer - and I guess
> that is why we love google API: simplicity and convenience.
> However, I will try.
> >
> > Also I think this an opportunity for you to ugrade the
> CsvDataSourceServlet to incorporate column description. Can it be
> on request?
> >
> > Thank you for you help,
> > Maliky.
> >
> >
> > ----- Original Message -----
> > From: ChartMan <char...@google.com>
> > Date: Thursday, July 16, 2009 8:01 am
> > Subject: [visualization-api] Re: motion chart using csv
> >
> > > So I was able to track down the problem.
> > >
> > > You are using the CsvDataSourceServlet in the java open source
> > > library. The
> > > servlet is an example servlet that demonstrated how to become a
> > > CSV based
> > > data source.
> > > Since this is an example the code is very simple. Therefore, the
> > > servletdoes not take care of identifying the data structure of the
> > > CSV and outputs
> > > a table where all columns are strings.
> > >
> > > If you wish to create your own real CSV data source, take the
> example> > servlet and add code that creates a list of
> ColumnDescriptions for
> > > your csv
> > > file. Now with the list in hand you can call the utility code in
> > > CsvDataSourceHelper to create a data table based on the csv reader
> > > and the
> > > list of column descriptions.
> > >
> > > Let me know if this makes sense and if it works for you.
> > >
> > > In addition I will update our documentation so that this is made
> > > clear.
> > > ChartMan
> > >
> > > On Mon, Jul 13, 2009 at 5:59 PM, Maliki Yacouba
> > > <my...@georgetown.edu> wrote:
> > >
> > > >
> > > > Hi chartMan,
> > > >
> > > > Here is my query response. Compare to your response, my response
> > > start with
> > > > Col0 and also all my labels are defaulted to string.
> > > > so my question is how can I set the col label to a desire type?
> > > >
> > > > Thank you,
> > > > Malik.
> > > >
> > > >
> > > >
> > >
> google.visualization.Query.setResponse({version:'0.6',status:'warning',warnings:[{reason:'data_truncated',message:'Retrieved> data was truncated',detailed_message:'Data has been truncated due to
> > > > userrequest (LIMIT in
> > > >
> > >
> query)'}],sig:'1261978498',table:{cols:[{id:'Col0',label:'State2',type:'string',pattern:''},{id:'Col1',label:'Year',type:'string',pattern:''},{id:'Col2',label:'HousePrice',type:'string',pattern:''},{id:'Col3',label:'Unemployement',type:'string',pattern:''},{id:'Col4',label:'Region',type:'string',pattern:''},{id:'Col5',label:'Population',type:'string',pattern:''},{id:'Col6',label:'SubPrimeLoan',type:'string',pattern:''}],rows:[{c:[{v:'Alabama'},{v:'2000'},{v:'203.6'},{v:'4.5'},{v:'South'},{v:'4452'},{v:'0.122'}]},{c:[{v:'Alaska'},{v:'2000'},{v:'169.7'},{v:'6.7'},{v:'West'},{v:'628'},{v:'0.046'}]},{c:[{v:'Arizona'},{v:'2000'},{v:'207.2'},{v:'4'},{v:'Southwest'},{v:'5167'},{v:'0.131'}]}]}});>> > >
> > > >
> > > > ----- Original Message -----
> > > > From: ChartMan <char...@google.com>
> > > > Date: Thursday, July 9, 2009 1:26 am
> > > > Subject: [visualization-api] Re: motion chart using csv
> > > >
> > > > > Please check the following url when you run the example server
> > > > >
> > > >
> > >
> http://localhost:8080/myWebApp/csv?url=http://localhost:8080/myWebApp/csv_training.csv&tq=limit> > 3<
> > > >
> > >
> http://localhost:8080/myWebApp/csv?url=http://localhost:8080/myWebApp/csv_training.csv&tq=limit%203> >
> > > > > You should be getting a response for the first 3 lines of
> you data
> > > > > source:
> > > > >
> > > >
> > >
> google.visualization.Query.setResponse({version:'0.6',status:'warning',warnings:[{reason:'data_truncated',message:'Retrieved> > data was truncated',detailed_message:'Data has been truncated due to
> > > > > userrequest (LIMIT in
> > > > >
> > > >
> > >
> query)'}],sig:'1951736017',table:{cols:[{id:'Col1',label:'State',type:'string',pattern:''},{id:'Col2',label:'Year',type:'number',pattern:''},{id:'Col3',label:'HousePrice',type:'number',pattern:''},{id:'Col4',label:'Unemployement',type:'number',pattern:''},{id:'Col5',label:'Region',type:'number',pattern:''},{id:'Col6',label:'Population',type:'number',pattern:''},{id:'Col7',label:'SubPrimeLoan',type:'number',pattern:''}],rows:[{c:[{v:'Alabama'},{v:2000.0},{v:203.6},{v:4.5},,{v:4452.0},{v:0.122}]},{c:[{v:'Alaska'},{v:2000.0},{v:169.7},{v:6.7},,{v:628.0},{v:0.046}]},{c:[{v:'Arizona'},{v:2000.0},{v:207.2},{v:4.0},,{v:5167.0},{v:0.131}]}]}});> >
> > > > > I  removed the 3 rows limit (tq=limit 3) and use the
> response to
> > > > > create a
> > > > > motionchart.
> > > > >
> > > > > ChartMan
> > > > >
> > > > > > On Wed, Jul 8, 2009 at 7:48 PM, Maliki Yacouba
> > > <my...@georgetown.edu>> > wrote:
> > > > > >>
> > > > > >> Hi chartMan,
> > > > > >>
> > > > > >>  to test whether my data was compatible, I used a set
> of data
> > > > > Google used
> > > > > to demonstrate the motionchart (state, year, unployement,
> > > > > houseprice etc).
> > > > > the data was initially in excel format, I just save it in csv
> > > file.> > >> I am sending you the codes and the data
> attachment. I can
> > > > > visualize the
> > > > > table, and the orgchart, but not motionchart
> > > > > >>
> > > > > >>
> > > > > >> I hope you can find the issue.
> > > > > >>
> > > > > >> thank you,
> > > > > >>
> > > > > >> maliky
> > > > > >>
> > > > > >>
> > > > > >>
> > > > > >> ----- Original Message -----
> > > > > >> From: ChartMan <char...@google.com>
> > > > > >> Date: Wednesday, July 8, 2009 4:33 am
> > > > > >> Subject: [visualization-api] Re: motion chart using csv
> > > > > >>
> > > > > >> > Hi
> > > > > >> >
> > > > > >> > Each visualization supports a certain data format. A map
> > > shows> > >> > locations, a
> > > > > >> > motion chart requires entities, time and then values and
> > > so on.
> > > > > >> > I assume that you are using data that is not in the
> correct> > > > format>> > for the
> > > > > >> > the visualization you are using.
> > > > > >> > Please send the csv example you are using and the code
> > > you are
> > > > > >> > using to send
> > > > > >> > the request and draw the visualization.
> > > > > >> >
> > > > > >> > ChartMan
> > > > > >> >
> > > > > >> > On Tue, Jul 7, 2009 at 8:21 PM, Maliki Yacouba
> > > > > >> > <my...@georgetown.edu> wrote:
> > > > > >> >
> > > > > >> > >
> > > > > >> > > Hi,
> > > > > >> > > I am sorry. that was not column order I intended to
> > > share with
> > > > > >> > you. As you
> > > > > >> > > have suggested I made sure the firs two column of my
> > > data are
> > > > > >> > entity and
> > > > > >> > > time (e.g OTERM1, YEAR, GOID1, GOID2). But the
> motionchart> > > > still>> > did show
> > > > > >> > > and continue to tell me "The First and Second Column
> > > must me
> > > > > >> > entity and
> > > > > >> > > time".
> > > > > >> > >
> > > > > >> > > here is the part of the tutorial that I think is not
> > > working> > well.>> > >
> > > > > >> > > // 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.MotionChart(document.getElementById('csv_div'));>>  chart.draw(data, {width: 600, height: 150, is3D: true});
> > > > > >> > >  }
> > > > > >> > >
> > > > > >> > > Please not that this is part of the all_example.html
> > > file in
> > > > > >> > >
> > > > > >> >
> > > > >
> > >
> http://code.google.com/apis/visualization/documentation/dev/dsl_csv.html> >
> > > > > >> > > Thank for your help.
> > > > > >> > > Maliky
> > > > > >> > >
> > > > > >> > >
> > > > > >> > > ----- Original Message -----
> > > > > >> > > From: ChartMan <char...@google.com>
> > > > > >> > > Date: Tuesday, July 7, 2009 1:24 am
> > > > > >> > > Subject: [visualization-api] Re: motion chart using csv
> > > > > >> > >
> > > > > >> > > > From looking into your data I see that you have the
> > > following> > >> > > > columnsOTERM1,GOID1, Year, GOID2,...
> > > > > >> > > > Which means that the first two columns of your
> data are
> > > > > not entity
> > > > > >> > > > and time
> > > > > >> > > > but entity and values. You should move the year
> > > column to
> > > > > be the
> > > > > >> > > > second in
> > > > > >> > > > your data or use a google.visualization.DataView to
> > > > > reorder your
> > > > > >> > > > columns.
> > > > > >> > > > As for bubble clicks - the motion chart state is
> > > quite a
> > > > > complex>> > > > object with
> > > > > >> > > > a lot of information in it. On every user interaction
> > > with> > the>> > > > chart this
> > > > > >> > > > object is changed and you can view its content
> from the
> > > > > advanced>> > > > menu of the
> > > > > >> > > > chart or get it using chart.getState(). You can
> inspect> > > > how this
> > > > > >> > > > objectchanges and act accordingly.
> > > > > >> > > >
> > > > > >> > > > ChartMan
> > > > > >> > > >
> > > > > >> > > > On Tue, Jul 7, 2009 at 1:31 AM, Maliki Yacouba
> > > > > >> > > > <my...@georgetown.edu> wrote:
> > > > > >> > > >
> > > > > >> > > > >
> > > > > >> > > > > Hi
> > > > > >> > > > >
> > > > > >> > > > > The only strange message I am getting is "First and
> > > second> > >> > > > columns must be
> > > > > >> > > > > entity and time."
> > > > > >> > > > > But that requirement is met because I used the same
> > > data to
> > > > > >> > build> > > motionchart on Google spreadsheet. Also
> when a
> > > > > visualize>> > a Table
> > > > > >> > > > instead of
> > > > > >> > > > > a MotionChart I get the table without problem.
> > > > > >> > > > >
> > > > > >> > > > > Here is the first few rows of the data of the file.
> > > > > >> > > > > OTERM1,GOID1,Year,GOID1,GOID2,GOTERM2
> > > > > >> > > > > extracellular space,5615,2009,5615,7154,cell
> > > communication> > >> > > > >
> > > metabolism,8152,2009,8152,5941,unlocalized protein complex
> > > > > >> > > > >
> > > > > >> > > > > One more question. Is it possible to make the
> > > bubble of the
> > > > > >> > > > motionchart> clickable - I mean when the user click
> > > on a
> > > > > >> > particular> > bubble it goes to
> > > > > >> > > > > next level of information
> > > > > >> > > > >
> > > > > >> > > > > thanks
> > > > > >> > > > > Maliky
> > > > > >> > > > >
> > > > > >> > > > > ----- Original Message -----
> > > > > >> > > > > From: ChartMan <char...@google.com>
> > > > > >> > > > > Date: Monday, July 6, 2009 3:21 pm
> > > > > >> > > > > Subject: [visualization-api] Re: motion chart
> using csv
> > > > > >> > > > >
> > > > > >> > > > > > can you copy and send the query response
> coming back
> > > > > from your
> > > > > >> > > > server.> >
> > > > > >> > > > > > On Mon, Jul 6, 2009 at 9:40 PM, Maliki Yacouba
> > > > > >> > > > > > <my...@georgetown.edu> wrote:
> > > > > >> > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > > > Hi CharMan,
> > > > > >> > > > > > > Yes I did make sure that the motionchart column
> > > > > >> > requirements are
> > > > > >> > > > > > met.> actually, I created a motion chart with the
> > > same> > data>> > > > through> > my google
> > > > > >> > > > > > > account using the spreadsheet.
> > > > > >> > > > > > >
> > > > > >> > > > > > > Here is the tutorial I followed:
> > > > > >> > > > > > >
> > > > > >> > > > > >
> > > > > >> > > >
> > > > > >> >
> > > > >
> > >
> http://code.google.com/apis/visualization/documentation/dev/dsl_csv.html> >>>
> > > > > Here are the changes I did in "all_examples_html" file:
> > > > > >> > > > > > > 1) I make sure I loaded the motionchart
> > > package :
> > > > > >> > > > > > > google.load('visualization', '1',
> > > > > >> > > > > > >
> > > {'packages':['table,motionchart,columnchart,piechart,> > >> >
> > >
> > > > > barchart,orgchart']});>
> > > > > >> > > > > > > 2) I save the file named "csv_myfile_csv" in
> > > myWeApp> > of the
> > > > > >> > > > tomtcat> > > directory
> > > > > >> > > > > > >
> > > > > >> > > > > > > 3) in the file "all_examples.html" I  changed
> > > the file
> > > > > >> > > > > > "csv_example.csv" by
> > > > > >> > > > > > > "csv_myfile_csv" and the query became:
> > > > > >> > > > > > > query = new
> google.visualization.Query('csv?url=> > > > >> > > > > > >
> > > > > >> > http://localhost:8080/myWebApp/csv_myfile.csv'<
> > > > > http://localhost:8080/myWebApp/csv_myfile.csv%27>> );
> > > > > >> > > > > > >
> > > > > >> > > > > > > Then I tried to visualize  MotionChart
> > > > > >> > > > > > > var chart = new
> > > > > >> > > > > > >
> > > > > >> > > > > >
> > > > > >> > > >
> > > > > >> >
> > > > >
> > >
> google.visualization.MotionChart(document.getElementById('csv_div'));>>>> > >> > > >  I get the following message.
> > > > > >> > > > > > > "CSV Data Source
> > > > > >> > > > > > > An organization chart. The data is taken
> from the
> > > > > csv data
> > > > > >> > > > source.> > > First and second columns must be
> entity and
> > > > > time.">> > > > > > >
> > > > > >> > > > > > > but when I change to BarChart as:
> > > > > >> > > > > > > var chart = new
> > > > > >> > > > > > >
> > > > > >> > > >
> > > > > >> >
> > > > >
> > >
> google.visualization.BarChart(document.getElementById('csv_div'));>> >
> > > > > > > I will have my variable name appear as legend
> alongside empty
> > > > > >> > > > > > chart area.
> > > > > >> > > > > > >
> > > > > >> > > > > > > and When I change to ColumnCart as:
> > > > > >> > > > > > > var chart = new
> > > > > >> > > > > > >
> > > > > >> > > > > >
> > > > > >> > > >
> > > > > >> >
> > > > >
> > >
> google.visualization.ColumnChart(document.getElementById('csv_div'));>>>> > >> > > > I will have my entity names listed on the x-axis but no chart
> > > > > >> > > > > > appear.>
> > > > > >> > > > > > > Thanks for the help.
> > > > > >> > > > > > > Maliky
> > > > > >> > > > > > >
> > > > > >> > > > > > > ----- Original Message -----
> > > > > >> > > > > > > From: ChartMan <char...@google.com>
> > > > > >> > > > > > > Date: Saturday, July 4, 2009 1:51 pm
> > > > > >> > > > > > > Subject: [visualization-api] Re: motion chart
> > > using csv
> > > > > >> > > > > > >
> > > > > >> > > > > > > > Hi
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > Can you be more specific in what exactly is
> > > > > failing for
> > > > > >> > > > you. The
> > > > > >> > > > > > > > first thing
> > > > > >> > > > > > > > to look is the data format the CSV file is
> > > in, the
> > > > > motion>> > > > chart> > > > expectscolumns with a certain
> format> > > > (listed in the
> > > > > >> > > > motion chart
> > > > > >> > > > > > > > doc page).
> > > > > >> > > > > > > > If this still doesn't work please send us
> > > some more
> > > > > >> > details.> > > > > >
> > > > > >> > > > > > > > ChartMan
> > > > > >> > > > > > > > On Thu, Jul 2, 2009 at 9:58 PM, Maliki
> Yacouba> > > > >> > > > > > > > <my...@georgetown.edu> wrote:
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > Hi
> > > > > >> > > > > > > > > I went through the "Running and testing
> > > > > >> > > > CSVDataSourceServlet" of
> > > > > >> > > > > > > > Using> External Data Source Section.
> > > > > >> > > > > > > > > My problem is that I can not make  a
> > > motionChart> > or any
> > > > > >> > > > other> > > > chart with
> > > > > >> > > > > > > > > the  "csv_example.csv", except OrgChart.
> > > > > >> > > > > > > > > Can someone help me how I can use a csv
> > > file to
> > > > > do a
> > > > > >> > motion> > > > chat.> > >
> > > > > >> > > > > > > > > thanks
> > > > > >> > > > > > > > > maliky
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > >
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > > > > >
> > > > > >> > > > >
> > > > > >> > > >
> > > > > >> > > > >
> > > > > >> > > >
> > > > > >> > >
> > > > > >> > >
> > > > > >> > > >
> > > > > >> > >
> > > > > >> >
> > > > > >> > >
> > > > > >> >
> > > > > >>
> > > > > >> >>
> > > > > >
> > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > > >
> > > >
> > >
> > > >
> > >
> >
> >
> > >
>
> >
>

ChartMan

unread,
Jul 27, 2009, 4:26:39 AM7/27/09
to google-visua...@googlegroups.com
Can you send me the code you are using in your example so I can inspect it.

Thanks

ChartMan

Maliki Yacouba

unread,
Jul 27, 2009, 10:10:15 AM7/27/09
to google-visua...@googlegroups.com
here the file I taught I should modify to add my column descriptions.
Thank you.
Mliky


// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.visualization.datasource.example;

import com.google.visualization.datasource.DataSourceHelper;
import com.google.visualization.datasource.DataSourceServlet;
import com.google.visualization.datasource.base.DataSourceException;
import com.google.visualization.datasource.base.ReasonType;
import com.google.visualization.datasource.datatable.DataTable;
import com.google.visualization.datasource.query.Query;
import com.google.visualization.datasource.util.CsvDataSourceHelper;

import com.ibm.icu.util.ULocale;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;

import javax.servlet.http.HttpServletRequest;

/**
* A demo servlet for serving a simple, constant data table.
* This servlet extends DataSourceServlet, but does not override the default
* empty implementation of method getCapabilities(). This servlet therefore ignores the
* user query (as passed in the 'tq' url parameter), leaving the
* query engine to apply it to the data table created here.
*
* @author Nimrod T.
*/
public class CsvDataSourceServlet extends DataSourceServlet {

/**
* Log.
*/
private static final Log log = LogFactory.getLog(CsvDataSourceServlet.class.getName());

/**
* The name of the parameter that contains the url of the csv to load.
*/
private static final String URL_PARAM_NAME = "url";

/**
* Generates the data table.
* This servlet assumes a special parameter that contains the CSV URL from which to load
* the data.
*/
@Override
public DataTable generateDataTable(Query query, HttpServletRequest request)
throws DataSourceException {
String url = request.getParameter(URL_PARAM_NAME);
if (StringUtils.isEmpty(url)) {
log.error("url parameter not provided.");
throw new DataSourceException(ReasonType.INVALID_REQUEST, "url parameter not provided");
}

Reader reader;
try {
reader = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
} catch (MalformedURLException e) {
log.error("url is malformed: " + url);
throw new DataSourceException(ReasonType.INVALID_REQUEST, "url is malformed: " + url);
} catch (IOException e) {
log.error("Couldn't read from url: " + url, e);
throw new DataSourceException(ReasonType.INVALID_REQUEST, "Couldn't read from url: " + url);
}
DataTable dataTable = null;
/*ULocale requestLocale = DataSourceHelper.getLocaleFromRequest(request); */
List<ColumnDescription> columnDescriptions = Lists.newArrayList();
columnDescriptions.add(new ColumnDescription("i1", ValueType.TEXT, null));
columnDescriptions.add(new ColumnDescription("i2", ValueType.TEXT, null));
columnDescriptions.add(new ColumnDescription("i3", ValueType.NUMBER, null));
columnDescriptions.add(new ColumnDescription("i4", ValueType.NUMBER, null));
columnDescriptions.add(new ColumnDescription("i5", ValueType.NUMBER, null));
columnDescriptions.add(new ColumnDescription("i6", ValueType.NUMBER, null));
columnDescriptions.add(new ColumnDescription("i7", ValueType.NUMBER, null));
ULocale requestLocale = DataSourceHelper.getLocaleFromRequest(request);
try {
dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, false);
} catch (IOException e) {
log.error("Couldn't read from url inside CSVDataSource.read(): " + url);
throw new DataSourceException(ReasonType.INVALID_REQUEST, "Couldn't read from url: " + url);
}
return dataTable;
}

/**
* NOTE: By default, this function returns true, which means that cross
* domain requests are rejected.
* This check is disabled here so examples can be used directly from the
* address bar of the browser. Bear in mind that this exposes your
* data source to xsrf attacks.
* If the only use of the data source url is from your application,
* that runs on the same domain, it is better to remain in restricted mode.
*/
@Override
protected boolean isRestrictedAccessMode() {
return false;

ChartMan

unread,
Jul 27, 2009, 12:07:55 PM7/27/09
to google-visua...@googlegroups.com
This looks like the correct code.
Can you now paste in the response that this server is returning.

ChartMan

Maliki Yacouba

unread,
Jul 27, 2009, 2:46:03 PM7/27/09
to google-visua...@googlegroups.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---

ChartMan

unread,
Jul 27, 2009, 3:04:18 PM7/27/09
to google-visua...@googlegroups.com
This is indeed strange. Are you able to debug only the data creation (using a debugger or prints) to see that the correct columns are used in the table.
If this fails I will try and run your example code on my machine.

ChartMan


On Mon, Jul 27, 2009 at 9:46 PM, Maliki Yacouba <my...@georgetown.edu> wrote:


Here is the response.  it still default all collumn to 'string'.
thank you,
Maliky

google.visualization.Query.setResponse({version:'0.6',status:'warning',warnings:[{reason:'data_truncated',message:'Retrieved data was truncated',detailed_message:'Data has been truncated due to userrequest (LIMIT in query)'}],sig:'1123391979',table:{cols:[{id:'Col0',label:'State',type:'string',pattern:''},{id:'Col1',label:'Year',type:'string',pattern:''},{id:'Col2',label:'HousePrice',type:'string',pattern:''},{id:'Col3',label:'Unemployement',type:'string',pattern:''},{id:'Col4',label:'Region',type:'string',pattern:''},{id:'Col5',label:'Population',type:'string',pattern:''},{id:'Col6',label:'SubPrimeLoan',type:'string',pattern:''}],rows:[{c:[{v:'Alabama'},{v:'2000'},{v:'203.6'},{v:'4.5'},{v:'South'},{v:'4452'},{v:'0.122'}]},{c:[{v:'Alaska'},{v:'2000'},{v:'169.7'},{v:'6.7'},{v:'West'},{v:'628'},{v:'0.046'}]},{c:[{v:'Arizona'},{v:'2000'},{v:'207.2'},{v:'4'},{v:'Southwest'},{v:'5167'},{v:'0.131'}]},{c:[{v:'Arkansas'},{v:'2000'},{v:'185.6'},{v:'4.4'},{v:'South'},{v:'2679'},{v:'0.
094'}]},{c:[{v:'California'},{v:'2000'},{v:'283.6'},{v:'4.9'},{v:'West'},{v:'34008'},{v:'0.127'}]},{c:[{v:'Colorado'},{v:'2000'},{v:'279.8'},{v:'2.8'},{v:'West'},{v:'4327'},{v:'0.107'}]},{c:[{v:'Connecticut'},{v:'2000'},{v:'279'},{v:'2.2'},{v:'New England'},{v:'3413'},{v:'0.12'}]},{c:[{v:'Delaware'},{v:'2000'},{v:'277.4'},{v:'3.9'},{v:'Middle Atlantic'},{v:'787'},{v:'0.159'}]},{c:[{v:'Washington DC'},{v:'2000'},{v:'265.9'},{v:'5.7'},{v:'South'},{v:'571'},{v:'0.117'}]},{c:[{v:'Florida'},{v:'2000'},{v:'213'},{v:'3.6'},{v:'South'},{v:'16050'},{v:'0.143'}]}]}});

Maliki Yacouba

unread,
Jul 28, 2009, 10:12:01 AM7/28/09
to google-visua...@googlegroups.com

ChartMan

unread,
Jul 28, 2009, 3:49:34 PM7/28/09
to google-visua...@googlegroups.com
Hi Maliky
 
I didn't have time to try out your code but it would be helpful if you can run the CsvServlet code in a debugger environment and detect why the column descriptions you provide to CsvDataSourceHelper are not used.
Anther way to find out is to have your server write information to a logger and then check the logger to see if you can find the problem.
In parallel I will try running the code myself in the coming days.
 
ChartMan

On Tue, Jul 28, 2009 at 5:12 PM, Maliki Yacouba <my...@georgetown.edu> wrote:

Hi Chartman
I don't understand what you mean by debugger or print. but when I visualize the table I can see the table column are rendered correctly. But when I try MotionChart it gives me errors even with the column descriptions. And my example code are basically the google example.
 Hopefully you can find  why is not working,
Maliky.


State   Year    HousePrice      Unemployement   Region  Population      SubPrimeLoan
Alabama 2000    203.6   4.5     South   4452    0.122
Alaska  2000    169.7   6.7     West    628     0.046
Arizona 2000    207.2   4       Southwest       5167    0.131

Maliki Yacouba

unread,
Jul 28, 2009, 4:11:01 PM7/28/09
to google-visua...@googlegroups.com

ChartMan

unread,
Jul 29, 2009, 5:05:02 AM7/29/09
to google-visua...@googlegroups.com
Hi

I have edited the example code with the changes above. I ant build to create a new jar. I copied the jar to my tomcat server depot and ran the server. 
I than queried the csv example url and got the following response which is of the desired type.
If this fails for you I will guess that your server is running with the default jar supplied when you downloaded the code and is not getting the changes you are doing in the java files.


ChartMan

google.visualization.Query.setResponse({version:'0.6',status:'warning',warnings:[{reason:'data_truncated',message:'Retrieved data was truncated',detailed_message:'Data has been truncated due to userrequest (LIMIT in query)'}],sig:'1151178224',table:{cols:[{id:'i1',label:'State',type:'string',pattern:''},{id:'i2',label:'Year',type:'string',pattern:''},{id:'i3',label:'HousePrice',type:'number',pattern:''},{id:'i4',label:'Unemployement',type:'number',pattern:''},{id:'i5',label:'Region',type:'number',pattern:''},{id:'i6',label:'Population',type:'number',pattern:''},{id:'i7',label:'SubPrimeLoan',type:'number',pattern:''}],rows:[{c:[{v:'Alabama'},{v:'2000'},{v:203.6},{v:4.5},,{v:4452.0},{v:0.122}]},{c:[{v:'Alaska'},{v:'2000'},{v:169.7},{v:6.7},,{v:628.0},{v:0.046}]}]}});



On Tue, Jul 28, 2009 at 11:11 PM, Maliki Yacouba <my...@georgetown.edu> wrote:
Thank you


----- Original Message -----
From: ChartMan <char...@google.com>
Date: Tuesday, July 28, 2009 3:49 pm
Subject: [visualization-api] Re: motion chart using csv





> This is indeed strange. Are you able to debug only the data creation (using
> a debugger or prints) to see that the correct columns are used in the
> table.If

Maliki Yacouba

unread,
Jul 31, 2009, 10:14:20 AM7/31/09
to google-visua...@googlegroups.com

Maliki Yacouba

unread,
Jul 31, 2009, 1:25:28 PM7/31/09
to google-visua...@googlegroups.com

ChartMan

unread,
Jul 31, 2009, 2:11:42 PM7/31/09
to google-visua...@googlegroups.com
assuming you changed the code like you mentioned. you should create the jar and then copy it to the location from which your server is reading its data. If you are using tomcat, this is a directory under webapps.
If you can find it search for a jar named "google-visualization.jar".
Once you copy the jar and restart the server the code should work (It worked for me).

ChartMan


On Fri, Jul 31, 2009 at 8:25 PM, Maliki Yacouba <my...@georgetown.edu> wrote:
Hi
I am trying to ant build to create a new jar as you did. So can you give some guide how to go about. It looks like you make work at your end. I will be gland to make work at my end.
again Thank you for helping,

Maliky


----- Original Message -----
From: ChartMan <char...@google.com>
Date: Wednesday, July 29, 2009 5:05 am
Subject: [visualization-api] Re: motion chart using csv

Hi


Reply all
Reply to author
Forward
0 new messages