ChartWrapper declaration, crating titles for an array, and seeing if it worked.

50 views
Skip to first unread message

Dat Viz

unread,
Dec 20, 2016, 1:16:56 AM12/20/16
to Google Visualization API
          I am a fairly new Apps Script Programmer, so I apologize in advance for any questions that might seem obvious to advanced users. I looked here to learn how to build a dashboard for a Google Sheet. I was able to use some apps script that I tested in the Script Editor to crate an array. I seemed to follow most of the HTML conventions suggested thus far, but when I got to Step 5 I noticed that the options one could specify when setting up either a ControlWrapper or ChartWrapper. I clicked on the links specified there, but the ControlWrapper page, and the ChartWrapper page didn't really go into the properties; they described the methods that could be called. I don't know why Google wouldn't report these, but I am finding they leave a lot of information out for you to just figure out on your own. Perhaps there is an assumption that one has done some web programming, but I haven't so again please excuse any ignorance on my part. Does anyone know where I can find a list of the options that can be set for these two classes?
          Also, I really didn't see anywhere on the page that showed you how to test whether the separate HTML file had worked. I would assume if I am making this as an added dashboard to a Google sheet, I would go to Publish →Deploy as Sheets web add on, but I wasn't sure. Lastly, in the example, they give hand typed/programmed arrays in there, while I used a script to populate an array. I was wondering if I would need to push categorization for all columns to the top of the array? I can share the script I added if this is helpful. I am just a little confused by this write up, as it doesn't really "fill in all of the blanks". Thanks for any help!

Dat Viz

unread,
Dec 20, 2016, 1:22:26 AM12/20/16
to Google Visualization API


On Monday, December 19, 2016 at 10:16:56 PM UTC-8, Dat Viz wrote:
          I am a fairly new Apps Script Programmer, so I apologize in advance for any questions that might seem obvious to advanced users. I looked here to learn how to build a dashboard for a Google Sheet. I was able to use some apps script that I tested in the Script Editor to crate an array. I seemed to follow most of the HTML conventions suggested thus far, but when I got to Step 5 I noticed that the options one could specify when setting up either a ControlWrapper or ChartWrapper. I clicked on the links specified there, but the ControlWrapper page, and the ChartWrapper page didn't really go into the properties; they described the methods that could be called. I don't know why Google wouldn't report these, but I am finding they leave a lot of information out for you to just figure out on your own. Perhaps there is an assumption that one has done some web programming, but I haven't so again please excuse any ignorance on my part. Does anyone know where I can find a list of the options that can be set for these two classes?
          Also, I really didn't see anywhere on the page that showed you how to test whether the separate HTML file had worked. I would assume if I am making this as an added dashboard to a Google sheet, I would go to Publish →Deploy as Sheets web add on, but I wasn't sure. Lastly, in the example, they give hand typed/programmed arrays in there, while I used a script to populate an array. I was wondering if I would need to push categorization for all columns to the top of the array? I can share the script I added if this is helpful. I am just a little confused by this write up, as it doesn't really "fill in all of the blanks". Thanks for any help!

I probably should add what I have thus far:
<!DOCTYPE html>
<html>
 
<head>
 
<!--This is what you will need to do every time you create a data visualization dashboard chart-->
 
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js">
 
<script type="text/javascript"
 
// Load the Visualization API and the controls package.
 
// Packages for all the other charts you need will be loaded
 
// automatically by the system.
    google
.charts.load("current", {'packages' :['corecharts'],['controls']});.
     
// Set a callback to run when the Google Visualization API is loaded.
     google
.charts.setOnLoadCallback(drawDashboard);
     
function DrawDashboard(){
     
//here is where you add the apps to get what you need.
     
//You need to figure out how to call your spreadsheet from here.
     
var ss = SpreadsheetApp.getActive();
     
var s = ss.getSheetByName("Stats");
     
//Not sure we need a comma separator
     
var datSet = [,];
     
//Here we would convert the array to a datatable
     
var ss = SpreadsheetApp.getActive();
     
var sheets = ss.getSheets();
     
var s = sheets[1];
     
var UI = SpreadsheetApp.getUi();
     
var response = UI.prompt("Please enter the first cell in the category").getResponseText();
     
var ir = s.getRange(response);
     
var n= 0;
     
var stored = [];
     
     
//Here is where you create your dashboard.
     
var dashboard = new google.visualization.Dashboard(document.getElementById('growing-dash'));
     
     
   
//Now you just need to figure out how to do this for a 2D array....we can use this as our script
   
     
while (ir.getValue()!= "") {
       n
= n +1;
       ir
= ir.offset(1, 0);
       
}
      ir
= ir.offset(-n,0)
     
     
for(i =0; i<n;i++) {
        stored
.push([ir.getValue(),ir.offset(n+2,0).getValue()]);
        ir
= ir.offset(1, 0);
       
}
     
var data = google.visualization.AarrayToDataTable(stored[]);
     
     
//creating the datachart
     
     
var Pie = new google.visualization.ChartWrapper({
     
'controltype' : 'PieChart',
     
'container_Id' : 'chart_div',
     
'options' : {
       
'width' : 350,
       
'height' : 325,
       
'title' : 'Count by salary'
       
}
       
     
}
     
</script>
   
   
<base target="_top">
 
</head>
 
<body>
   
<!--This is what is going to hold the dashboard-->
   
<div id="growing-dash">
     
<!--We need div deviders that separate each control and chart-->
     
<div id="filter1"> </div>
     
<div id="chart1"> </div>
     
</div>  </body>

Daniel LaLiberte

unread,
Dec 20, 2016, 1:48:10 PM12/20/16
to Google Visualization API
Hi Doug,

Since you are using AppsScript to display charts, you may have to consult with their documentation first.  The Google Charts documentation won't give you quite enough details since it assumes you are working in a normal web page.  Perhaps this is where you should start:  https://developers.google.com/apps-script/reference/charts/dashboard-panel

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/1241cb09-f148-4346-9c48-35109e39137e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Dat Viz

unread,
Jan 12, 2017, 5:59:12 PM1/12/17
to Google Visualization API
Thank you for the reference Daniel, 
        Unfortunately, when I went here and tried to create a pie chart, I found a couple of problems....
first the UiApp is depreciated, so I can't really follow the example (something Google should take the time to update), and I also found that when I tried to create a pre-defined array, the google.visualization.arrayToDataTable function wouldn't seem to accept a pre-defined array. It seemed that you had to create static values in the app itself. It doesn't help if you are trying to make the application flexible to the user so they can select an array they would like to visualize. I might be doing something wrong here, but that seems very limiting. I searched around a bit to see if there was some example somewhere of someone plugging a pre-defined array into the google.visualization.arrayToDataTable() function, but to no avail. Is that not allowed?


On Monday, December 19, 2016 at 10:16:56 PM UTC-8, Dat Viz wrote:

Daniel LaLiberte

unread,
Jan 12, 2017, 10:28:14 PM1/12/17
to Google Visualization API
Apps Scripts limits what you can do intentionally to avoid security issues.  They might loosen up the restrictions if security can be assured, but you'll have to write to the Apps Scripts folks to get more info on all that.

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.

Dat Viz

unread,
Jan 13, 2017, 3:43:40 PM1/13/17
to Google Visualization API
Are you referring to the use of a pre-defined array being limited? I would assume so, but I am having a hard time finding some relevant information in the documentation that will allow me to just get started on a simple dashboard. I appreciate the pointer, and I was going to try to create a chart without the HTML, but due to the UiApp being depreciated, that doesn't sound like an option. I am searching around, but not having much luck. At this point, I am just trying to find some baby steps towards creating a display that works....Maybe just have a static datatable? That just seems so limiting.


On Thursday, January 12, 2017 at 7:28:14 PM UTC-8, Daniel LaLiberte wrote:
Apps Scripts limits what you can do intentionally to avoid security issues.  They might loosen up the restrictions if security can be assured, but you'll have to write to the Apps Scripts folks to get more info on all that.
On Thu, Jan 12, 2017 at 5:59 PM, Dat Viz <djloq...@gmail.com> wrote:
Thank you for the reference Daniel, 
        Unfortunately, when I went here and tried to create a pie chart, I found a couple of problems....
first the UiApp is depreciated, so I can't really follow the example (something Google should take the time to update), and I also found that when I tried to create a pre-defined array, the google.visualization.arrayToDataTable function wouldn't seem to accept a pre-defined array. It seemed that you had to create static values in the app itself. It doesn't help if you are trying to make the application flexible to the user so they can select an array they would like to visualize. I might be doing something wrong here, but that seems very limiting. I searched around a bit to see if there was some example somewhere of someone plugging a pre-defined array into the google.visualization.arrayToDataTable() function, but to no avail. Is that not allowed?

On Monday, December 19, 2016 at 10:16:56 PM UTC-8, Dat Viz wrote:
          I am a fairly new Apps Script Programmer, so I apologize in advance for any questions that might seem obvious to advanced users. I looked here to learn how to build a dashboard for a Google Sheet. I was able to use some apps script that I tested in the Script Editor to crate an array. I seemed to follow most of the HTML conventions suggested thus far, but when I got to Step 5 I noticed that the options one could specify when setting up either a ControlWrapper or ChartWrapper. I clicked on the links specified there, but the ControlWrapper page, and the ChartWrapper page didn't really go into the properties; they described the methods that could be called. I don't know why Google wouldn't report these, but I am finding they leave a lot of information out for you to just figure out on your own. Perhaps there is an assumption that one has done some web programming, but I haven't so again please excuse any ignorance on my part. Does anyone know where I can find a list of the options that can be set for these two classes?
          Also, I really didn't see anywhere on the page that showed you how to test whether the separate HTML file had worked. I would assume if I am making this as an added dashboard to a Google sheet, I would go to Publish →Deploy as Sheets web add on, but I wasn't sure. Lastly, in the example, they give hand typed/programmed arrays in there, while I used a script to populate an array. I was wondering if I would need to push categorization for all columns to the top of the array? I can share the script I added if this is helpful. I am just a little confused by this write up, as it doesn't really "fill in all of the blanks". Thanks for any help!

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.



--

Daniel LaLiberte

unread,
Jan 13, 2017, 4:09:59 PM1/13/17
to Google Visualization API
I don't know exactly what limitations the AppsScripts imposes, but I know they do impose some.  I was guessing from what you said that the data provided to arrayToDataTable() might have to be static, though that is surprising nevertheless.  If I were you, I would start out with something that you know works, and modify it from there.

On Fri, Jan 13, 2017 at 3:43 PM, Dat Viz <djloq...@gmail.com> wrote:
Are you referring to the use of a pre-defined array being limited? I would assume so, but I am having a hard time finding some relevant information in the documentation that will allow me to just get started on a simple dashboard. I appreciate the pointer, and I was going to try to create a chart without the HTML, but due to the UiApp being depreciated, that doesn't sound like an option. I am searching around, but not having much luck. At this point, I am just trying to find some baby steps towards creating a display that works....Maybe just have a static datatable? That just seems so limiting.

On Thursday, January 12, 2017 at 7:28:14 PM UTC-8, Daniel LaLiberte wrote:
Apps Scripts limits what you can do intentionally to avoid security issues.  They might loosen up the restrictions if security can be assured, but you'll have to write to the Apps Scripts folks to get more info on all that.
On Thu, Jan 12, 2017 at 5:59 PM, Dat Viz <djloq...@gmail.com> wrote:
Thank you for the reference Daniel, 
        Unfortunately, when I went here and tried to create a pie chart, I found a couple of problems....
first the UiApp is depreciated, so I can't really follow the example (something Google should take the time to update), and I also found that when I tried to create a pre-defined array, the google.visualization.arrayToDataTable function wouldn't seem to accept a pre-defined array. It seemed that you had to create static values in the app itself. It doesn't help if you are trying to make the application flexible to the user so they can select an array they would like to visualize. I might be doing something wrong here, but that seems very limiting. I searched around a bit to see if there was some example somewhere of someone plugging a pre-defined array into the google.visualization.arrayToDataTable() function, but to no avail. Is that not allowed?

On Monday, December 19, 2016 at 10:16:56 PM UTC-8, Dat Viz wrote:
          I am a fairly new Apps Script Programmer, so I apologize in advance for any questions that might seem obvious to advanced users. I looked here to learn how to build a dashboard for a Google Sheet. I was able to use some apps script that I tested in the Script Editor to crate an array. I seemed to follow most of the HTML conventions suggested thus far, but when I got to Step 5 I noticed that the options one could specify when setting up either a ControlWrapper or ChartWrapper. I clicked on the links specified there, but the ControlWrapper page, and the ChartWrapper page didn't really go into the properties; they described the methods that could be called. I don't know why Google wouldn't report these, but I am finding they leave a lot of information out for you to just figure out on your own. Perhaps there is an assumption that one has done some web programming, but I haven't so again please excuse any ignorance on my part. Does anyone know where I can find a list of the options that can be set for these two classes?
          Also, I really didn't see anywhere on the page that showed you how to test whether the separate HTML file had worked. I would assume if I am making this as an added dashboard to a Google sheet, I would go to Publish →Deploy as Sheets web add on, but I wasn't sure. Lastly, in the example, they give hand typed/programmed arrays in there, while I used a script to populate an array. I was wondering if I would need to push categorization for all columns to the top of the array? I can share the script I added if this is helpful. I am just a little confused by this write up, as it doesn't really "fill in all of the blanks". Thanks for any help!

--
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 google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.



--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Dat Viz

unread,
Jan 13, 2017, 6:15:28 PM1/13/17
to Google Visualization API
Thanks for all of your help! I will try to find some starting point. I am sure something will stick eventually.


On Friday, January 13, 2017 at 1:09:59 PM UTC-8, Daniel LaLiberte wrote:
I don't know exactly what limitations the AppsScripts imposes, but I know they do impose some.  I was guessing from what you said that the data provided to arrayToDataTable() might have to be static, though that is surprising nevertheless.  If I were you, I would start out with something that you know works, and modify it from there.
On Fri, Jan 13, 2017 at 3:43 PM, Dat Viz <djloq...@gmail.com> wrote:
Are you referring to the use of a pre-defined array being limited? I would assume so, but I am having a hard time finding some relevant information in the documentation that will allow me to just get started on a simple dashboard. I appreciate the pointer, and I was going to try to create a chart without the HTML, but due to the UiApp being depreciated, that doesn't sound like an option. I am searching around, but not having much luck. At this point, I am just trying to find some baby steps towards creating a display that works....Maybe just have a static datatable? That just seems so limiting.

On Thursday, January 12, 2017 at 7:28:14 PM UTC-8, Daniel LaLiberte wrote:
Apps Scripts limits what you can do intentionally to avoid security issues.  They might loosen up the restrictions if security can be assured, but you'll have to write to the Apps Scripts folks to get more info on all that.
On Thu, Jan 12, 2017 at 5:59 PM, Dat Viz <djloq...@gmail.com> wrote:
Thank you for the reference Daniel, 
        Unfortunately, when I went here and tried to create a pie chart, I found a couple of problems....
first the UiApp is depreciated, so I can't really follow the example (something Google should take the time to update), and I also found that when I tried to create a pre-defined array, the google.visualization.arrayToDataTable function wouldn't seem to accept a pre-defined array. It seemed that you had to create static values in the app itself. It doesn't help if you are trying to make the application flexible to the user so they can select an array they would like to visualize. I might be doing something wrong here, but that seems very limiting. I searched around a bit to see if there was some example somewhere of someone plugging a pre-defined array into the google.visualization.arrayToDataTable() function, but to no avail. Is that not allowed?

On Monday, December 19, 2016 at 10:16:56 PM UTC-8, Dat Viz wrote:
          I am a fairly new Apps Script Programmer, so I apologize in advance for any questions that might seem obvious to advanced users. I looked here to learn how to build a dashboard for a Google Sheet. I was able to use some apps script that I tested in the Script Editor to crate an array. I seemed to follow most of the HTML conventions suggested thus far, but when I got to Step 5 I noticed that the options one could specify when setting up either a ControlWrapper or ChartWrapper. I clicked on the links specified there, but the ControlWrapper page, and the ChartWrapper page didn't really go into the properties; they described the methods that could be called. I don't know why Google wouldn't report these, but I am finding they leave a lot of information out for you to just figure out on your own. Perhaps there is an assumption that one has done some web programming, but I haven't so again please excuse any ignorance on my part. Does anyone know where I can find a list of the options that can be set for these two classes?
          Also, I really didn't see anywhere on the page that showed you how to test whether the separate HTML file had worked. I would assume if I am making this as an added dashboard to a Google sheet, I would go to Publish →Deploy as Sheets web add on, but I wasn't sure. Lastly, in the example, they give hand typed/programmed arrays in there, while I used a script to populate an array. I was wondering if I would need to push categorization for all columns to the top of the array? I can share the script I added if this is helpful. I am just a little confused by this write up, as it doesn't really "fill in all of the blanks". Thanks for any help!

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.



--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.



--

Dat Viz

unread,
Jan 17, 2017, 11:18:14 PM1/17/17
to Google Visualization API
So, I saw the Apps Scripts will not work if you don't have a secured HTTPS site. Working a little for a non-profit, that isn't exactly easy to get. I looked to see where I could contact Google App Script support, but like many companies today, they don't seem to have anything other than forums like this one, or requests for new functionality. Is there some place you were referring to that I could actually contact Google Apps Script Service Professionals and explain the situation? I am gong to try posting my question on Stack Overflow, but I don't see any way to get this working right now. If you know of a direct email, or place I can go to inquire, that would be helpful. Otherwise, this whole effort was rather fruitless because they dont' seem to support anything other than creating scripts inside of HTML. Not very user friendly at all.


On Monday, December 19, 2016 at 10:16:56 PM UTC-8, Dat Viz wrote:

Daniel LaLiberte

unread,
Jan 18, 2017, 10:21:24 AM1/18/17
to Google Visualization API
There is no better way I know for you to communicate with people who will be able to answer your questions than what you are doing already.  

By the way, going back to your first example, I noticed that you wrote this:

google.charts.load("current", {'packages' :['corecharts'],['controls']});

That is going to fail to work probably due to syntax errors.  It should instead be:

google.charts.load("current", {'packages' :['corecharts','controls']});

In general, I would recommend you start with something small that works, and change things one at a time until something breaks.

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Dat Viz

unread,
Jan 18, 2017, 1:06:43 PM1/18/17
to Google Visualization API
Thanks again Daniel,
           I have been trying to break down simpler code. I even tried a basic "Hello World" HTML screen which did work. It is when one starts implementing script that the problem comes in. I believe that is exactly what it is with Google Apps Script, that you need to have a security certificate as you had mentioned once you get to the point that you are using scripts. I just don't understand why they removed the UiApp class if they were not going to have something better than this. Thanks for your help, at least I was able to pinpoint the problem (I believe). Maybe I can come up with some resourceful workaround until I hear back on Stack Exchange or from the folks at Google.


On Monday, December 19, 2016 at 10:16:56 PM UTC-8, Dat Viz wrote:
Reply all
Reply to author
Forward
0 new messages