This has got to be easy enough! But I've been fiddling with it and can't 
make it work. I'm building a simple Apps Script dash and for some reason 
the Category filter is rendering really far away from the chart. I want it 
be really close to the actual chart as I've got a lot to fit on a single 
site page. See my script below, pulled right out of the Google Editor. (All 
data is fake). 

I'm also having trouble setting colors for the columns and setting titles - 
so if someone could throw an example out based on my code, that would be a 
HUGE help. I'm using .setTitle() etc., but when I run the script I get an 
error that .setTitle isn't defined (same when I try to specify colors, 
etc). I was just adding it to the Chart class like so: 
Charts.newColumnChart().setStacked().setTitle('TEST').setDimensions(1000,1000).setDataViewDefinition(dataViewDefinition).build();
 


Any idea what I'm doing wrong? .setStacked, etc. is working, but I can't 
make other options work like title, or setting the chart's colors, etc. 

Full script below:

function doGet() {
var ss = 
SpreadsheetApp.openByUrl("https://docs.google.com/a/google.com/spreadsheets 
/d/1HLEVLFjr9eMQE2fSANiHDHc-qqSf4hjuDwlonQncdiQ/pubhtml");

var sheet = ss.getSheets()[0];
Logger.log("sheet name is %s", sheet);

var numRows = sheet.getDataRange().getNumRows();
var numCols = sheet.getDataRange().getNumColumns();

var datasource = sheet.getDataRange().getValues();

var data = Charts.newDataTable()
      .addColumn(Charts.ColumnType.STRING, datasource [0] [0])
      .addColumn(Charts.ColumnType.NUMBER, datasource [0] [1])
      .addColumn(Charts.ColumnType.STRING, datasource [0] [2])
      .addColumn(Charts.ColumnType.STRING, datasource [0] [3])
      .addColumn(Charts.ColumnType.NUMBER, datasource [0] [4])
      .addColumn(Charts.ColumnType.NUMBER, datasource [0] [5]);

for (i = 1; i <= datasource.length-1; i++){
Logger.log(datasource [i]);
data.addRow([datasource [i] [0], datasource [i] [1], datasource [i] [2], 
datasource [i] [3], datasource [i] [4], datasource [i] [5]])

};

data.build();

var nameFilter = Charts.newCategoryFilter()
      .setFilterColumnIndex(2)
      .build();

var dataViewDefinition = Charts.newDataViewDefinition().setColumns([0, 1, 4]);

var tableChart =   

Charts.newColumnChart().setStacked().setDimensions(1000,1000).setDataViewDefinition(dataViewDefinition).build();
 


var dashboard = Charts.newDashboardPanel()
  .setDataTable(data)
  .bind([nameFilter],[tableChart]).build();

var uiApp = UiApp.createApplication();

dashboard.add(uiApp.createVerticalPanel()
           .add(uiApp.createHorizontalPanel()
                .add(nameFilter)
                .setSpacing(20))
            .add(uiApp.createHorizontalPanel()
                .add(tableChart)
                .setSpacing(10)));

uiApp.add(dashboard);
return uiApp;

}

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to