How to use ChartBuilder.setDataSourceUrl with Fusion Tables? - google-apps-script

I have that problem. When I set de URL of my request from my table in Fusion Tables, the chart does not work. It say 'Request timed out' when I play the App.
The code is:
var graficoHistoricoMensual=Charts.newAreaChart() .setDataSourceUrl('https://www.googleapis.com/fusiontables/v1/query?sql=select%20ANO,MES,%20count(INCIDENCIA)%20AS%20TotalIncidencias%20from ID_OF_THE_TABLEwhere%20ALMACEN=501%20group%20by%20ANO,MES%20&key=THE_KEY&alt=csv')
.setDataViewDefinition(Charts.newDataViewDefinition().setColumns([0,1]))
.build();
When I executed this URL on one tab of the browser it work perfectly.
Does Fusion Tables work with Google App Script and this method of the Charts Services?

I have never tried this, to answer you based on my experience, but from the error message it seems that Fusion Tables is just too slow for the Chart Service. Or, looking the other way, the Chart Service timeout is too low for Fusion Tables.
If that's really the case, you answer is no, you can not use fusion tables like this (using setDataSourceUrl).
But you can definitely use Fusion Tables data in Apps Script and pass to the Chart Services, you just need to grab the data yourself (using UrlFetchApp), parse it (using either JSON.parse or Utilities.parseCsv), and then create the charts datatable manually, Charts.newDataTable.

Related

Querying data in Google Apps Scripts

I don't see this explicitly mentioned anywhere, but is it possible to do some sort of data query like it's mentioned in the google charts reference?https://developers.google.com/chart/interactive/docs/queries
I'm looking to start a project and this will have a big impact on whether or not I'll use Google Charts or Google Scripts.
Short answer
Yes, it's possible.
Explanation
Exhibit 1:
See https://developers.google.com/chart/interactive/docs/spreadsheets
Exhibit 2:
At this time there are 6 questions returned by searching [google-apps-script][google-query-language]. I picked one that could serve you as a place where is explicitly mentioned:
Creating a table using google app script from a query
Exhibit 3:
At this time there are 137 questions returned by [google-apps-script][google-visualization]. I picked one that could serve you as place where is explicitly mentioned:
Google Visualization Column Chart set a data column from query as role: "Style"

Appengine Fusion tables programmatically creating many map markers

TLDR: I want this, but I am happy to send the data in my database to google as it is created (any user can create a location on the map).
I need to create a lot of map markers on a google map for a website I am creating. Insertions and deletions will be required, but I will never need to filter the data. I found several links showing how to create this map to make it accessible through the use of google docs' spreadsheet, however I have a database of latitude/longitude coordinates in google app engine. My preferred method would be for google to host the map and me to send insertion / deletion queries to the map itself (as the map is constant for all users). This sounded exactly like fusion tables, but I couldn't actually find out how to do it programatically in fusion tables
I know how to create individual points on a map, but there will be a lot of points so sending every single point to the client will be way too slow. My backup plan is simply to use a quad tree and get the client to send the server the bounds of the map and reply with everything in there, but I suspect google has a better solution.
Depending upon the size of your data set and how many insertions and deletions you need to make each day, you might want to consider using the Fusion Tables API. You can do a "replaceRows" operation to swap out the entire table contents, or individual "insert" and "delete" calls. (Of course then your data is stored in Fusion Tables.)
You can then embed your map in the website of your choice, or even host it on Google Drive.

Is it possible to customize fusion table( should point my database ) to use fusionTableLayer?

I would like to create a Map by the excel sheet values (.csv files too).
By using FusionTableLayer API, I think it is possible. At first step we could upload the excel values to the database. Then we create a map by the database annotated value. It is very good idea. This is what I wanted. But One thing is problem to me with FusionTableLayer API is google's Drive has been pointed for the fusion table. It means that all my business data will be shared with google. I don't want to be like that.
Instead of Google's drive My database has to be pointed out. From my database I would like to create a map with FusionTableLayer API. I have been searching through internet, I dont find this is possible. But I believe that it is possible. Please guile me to specify the way to trigger it out ?
Regards,
ArunRaj.
If you want to use your own database, then you cannot use the Fusion Table API as it's meant for the Google Infrastructure. You will have to find another API to take care of this.
One workaround I can suggest to you is to parse points you have as drawing objects for your map. So for each point, create new google.maps.Marker with the respective coordinates. Each region can be denoted with google.maps.Polygon, and lines with google.maps.Polyline. There's plenty more you can do, but it's just a bit more work, and possibly less secure depending on your implementation. Furthermore, you can also add info windows to each of those areas using the Google Maps API by attaching respective listeners to those objects created.
Hope this helps!

Is there any alternative to GViz on Google Apps Script?

The problems:
I need to get data in a kind of "relational" way.
GViz (Google Visualization API) is not available for GAS (Google Apps Script) HTML Service (see here: Can we use Google Chart Tools with Google Script HtmlService).
Getting all the functinality GViz delivers is a dream right now, so, instead, I'd be satisfied with DataTable and DataView objects and google.visualization.data.join(). I dont need charts right now.
All of this, as long as I cannot get full GViz on the client side, could be server side.
Being more explicit, I need to join some queries and not mess up with the normalized data.
Keep in mind that I'm using a Spreadsheet as a data container (the tables are composed of static and dynamic data).
Getting all the functionality from GViz is everyone's dream right now, but some of it is available through Charts Services in UiApps. I have no experience with HTML Service, so I can't speak for that.
https://developers.google.com/apps-script/service_charts
If you're manipulating a lot of data, have you looked at ScriptDB?
https://developers.google.com/apps-script/service_scriptdb
I currently use a set of spreadsheets and Charts Services for a dashboard and it works pretty well. I really wish I could make combo charts, though.
It looks like sometime between mid-March and now, GViz mostly works with HTML Service.
I'm very new to Google Apps Script myself, but I have managed to get TaffyDB working server side. I loaded it up as a library in case I want to use it across multiple projects.
I did have to add this line to make it work server side:
function setTimeout() {}
Not sure if the is necessarily sufficient, but it worked as a starting point.

How Best to handle oData, JSON data with Google Maps API

I'm sorry for such a basic question but this is all very new to me. What would be the best way to handle this scenario:
Access address data via oData
Can only obtain 50 records at a time via oData
Allow user to select what gets retrieved using some kind of toggle switch based on a status field (some selections will result in more than 50 records)
Toggle visibility of markers based on checkboxes
How do I combine the various oData calls during the selection process? How do i toggle markers based on status data stored in JSON? Or do i have it all wrong? Thank you for any help you guys can provide to get me going in the right direction.