views:

124

answers:

1

Ok I will explain my doubt again I am writting this servlet code http://code.google.com/apis/visualization/documentation/dev/dsl_csv.html#intro the url to execute is /CsvDataSourceServlet?url=http://localhost:8084/WebApplication1/F2.csv When i execute this code i get output result on my browser ... I am not understanding how that code is opening my browser and showing {c:[{v:'Bob'},{v:'Jane'}]}]}}); etc etc why is this happening , why is the browser opening to show result can we figure out something from this code http://code.google.com/apis/visualization/documentation/dev/dsl_csv.html#intro

were F2.csv is my *.csv file

now after executing the code I have to display the result which i have to do using the javascript code as follows All Examples

// Load the Visualization API and the ready-made Google table visualization. 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); var query = new google.visualization.Query('CsvDataSourceServlet?url=http://localhost:8084/WebApplication1/**F2.csv**'); query.send(handleCsvDsResponse); } // 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}); }

CSV Data Source

An organization chart. The data is taken from the csv data source.

A: 

here what i am trying now.

public class Beat extends HttpServlet implements DataTableGenerator {

protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter();

try { // /* TODO output your page here out.println(""); out.println(""); out.println("Servlet Beat");
out.println(""); out.println(""); out.println("

Servlet Beat at " + request.getContextPath () + "

"); out.println(""); out.println("");

DataSourceHelper.executeDataSourceServletFlow(request, response, (DataTableGenerator) m1.generateDataTable(null, request));//,Boolean.FALSE);

RequestDispatcher rd; rd = request.getRequestDispatcher("newhtml.html"); rd.include(request, response);//forward(request, response);

} finally { out.close(); } }

public DataTable generateDataTable(Query query, HttpServletRequest request) { // Create a data table. DataTable data = new DataTable(); ArrayList cd = new ArrayList(); cd.add(new ColumnDescription("name", ValueType.TEXT, "Animal name")); cd.add(new ColumnDescription("link", ValueType.TEXT, "Link to wikipedia")); cd.add(new ColumnDescription("population", ValueType.NUMBER, "Population size")); cd.add(new ColumnDescription("vegeterian", ValueType.BOOLEAN, "Vegetarian?"));

data.addColumns(cd);

// Fill the data table.
try {
  data.addRowFromValues("Aye-aye", "http://en.wikipedia.org/wiki/Aye-aye", 100, true);
  data.addRowFromValues("Sloth", "http://en.wikipedia.org/wiki/Sloth", 300, true);
  data.addRowFromValues("Leopard", "http://en.wikipedia.org/wiki/Leopard", 50, false);
  data.addRowFromValues("Tiger", "http://en.wikipedia.org/wiki/Tiger", 80, false);
} catch (TypeMismatchException e) {
  System.out.println("Invalid type!");
}
return data;

}

  public Capabilities getCapabilities(){
      return Capabilities.NONE;
  }

  protected boolean isRestrictedAccessMode() {
     return false;
  }

@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }

@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } }

html code is fine

Getting Started Example

//Load the Visualization API and the ready-made Google table visualization google.load('visualization', '1', {'packages':['table']}); // Set a callback to run when the API is loaded. google.setOnLoadCallback(init); // Send the query to the data source. function init() { // Specify the data source URL. var query = new google.visualization.Query('Beat'); // Send the query with a callback function. query.send(handleQueryResponse); } // Handle the query response. function handleQueryResponse(response) { if (response.isError()) { alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); return; } // Draw the visualization. var data = response.getDataTable(); var chart = new google.visualization.Table(document.getElementById('chart_div')); chart.draw(data, {width: 600, height: 150, is3D: true}); }

Hello! Data Source!

A table chart that shows data taken from the simple data source.

I cant see the chart drawn when i follow this step the chart is drawn fine http://code.google.com/apis/visualization/documentation/dev/dsl_get_started.html

how can i elemenate this coming up google.visualization.Query.setResponse and ends with /Tiger'},{v:80.0},{v:false}]}]}});

but if want to make chart in single event how can i do?

Please guide

Akku