Google Sheet Pie Chart JS : Slices offset method not working ?

135 views
Skip to first unread message

JY_FR-DE-EN

unread,
Jul 27, 2017, 7:50:19 PM7/27/17
to Google Visualization API
Hello,

I've been spending hours trying to figure out why the Exploding/Spliting method of the 
Chart Builder/Embedding
is not working at all in my "google sheet assigned script"

.setOption ('slices', Value)
e.g. {3: {offset : 0.3};

Any ideas/experience on that ? Is this deprecated somehow ?
(other .setOption methods works : Colors for example)

My sheet has a 3 columns (therefore selecting B2:C5), 4 lines, simplified for testing purposes.

Here is the code :

function GeneratePie() {  
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("B2:C5");  
var pie = sheet.newChart()
   .setChartType(Charts.ChartType.PIE)
  .addRange(range)
    .setPosition(5,6 ,5, 5)
  //.setTitle("This is the title of my chart")
 .setOption('slices', {
      0: {offset: 0.05},
      1: {offset: 0.15},
      2: {offset: 0.25},
      3: {offset: 0.35}
    })

.setOption('title', 'Updated!');

// another try
  slicces[0] = '{offset: 0.2}'; 
 pie.setOption('slices', slicces); // wrapper is the ChartWrapper */   
pie.setOption('title', 'Updated2!');
sheet.insertChart(pie.build());   
  
  var chart = sheet.getCharts()[1];
 chart = chart.modify()
     .setOption('title', 'Updated ZZZZZZZ!')
     .setPosition(5,6,6,6)
 .setOption('slices', {
      0: {offset: 0.05},
      1: {offset: 0.15},
      2: {offset: 0.25},
      3: {offset: 0.35}
    })
 
     .build();
 sheet.updateChart(chart); 
}

All comments are welcome...

Thank you !

Daniel LaLiberte

unread,
Jul 27, 2017, 9:15:56 PM7/27/17
to Google Visualization API
This is a question about using charts via AppsScript.  You should probably ask such questions on the forum for the AppsScript users, since very few people in this forum are likely to be able to help you.

If it turns out to be a problem in Google Charts, then come back and ask again about the chart specific details.  

One way to test whether the problem is on the Charts side or the AppsScript side is to build a simple JavaScript example, say using jsfiddle, that uses just the options that you are trying to figure out.


--
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/bd8b347f-b634-48dd-a33b-80424ef9b8c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

JY_FR-DE-EN

unread,
Jul 28, 2017, 4:09:20 AM7/28/17
to Google Visualization API
Thank you Daniel, I asked here because I thought it might get lost in AppsScript, but if you say so.

I forgot to mention that a fiddle like these one :

Works perfectly, but I'm afraid it's different since
eg "arrayToDataTable"
or all google visualization
are not in the code below.

I'll try and rephrase the whole thing to put in AppsScript forum,

Regards,

JY
To post to this group, send email to google-visua...@googlegroups.com.



--
Message has been deleted

JY_FR-DE-EN

unread,
Jul 28, 2017, 5:32:47 AM7/28/17
to Google Visualization API
Sorry, still searching for the right group to post.

I found a 'Google Spreadsheets API'  group, but there is not much going on.

Any help much appreciated, thank you ! :-) 

Daniel LaLiberte

unread,
Jul 28, 2017, 9:09:00 AM7/28/17
to Google Visualization API
Try this page for several pointers:  https://developers.google.com/apps-script/support

Point to your jsfiddle as an example of what you want via apps script.

--
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.



--

JY_FR-DE-EN

unread,
Jul 28, 2017, 2:15:26 PM7/28/17
to Google Visualization API
Reply all
Reply to author
Forward
0 new messages