Google Sheet饼图JS:切片偏移方法不起作用? [英] Google Sheet Pie Chart JS : Slices offset method not working?

本文介绍了Google Sheet饼图JS:切片偏移方法不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直花费(很多时间)试图弄清楚如何在Google表格/
中爆炸/拆分饼图(例如,使用Google Apps脚本中的切片设置选项)
http://fiddle.jshell.net/6d5fLwnm/4/
这适用于使用Google可视化的Google表格之外



例如PieChart
.setOption('slices',Value)
例如{3:{offset:0.3};

但是Google Chart Builder / Embedding
的这种方法在我的Google表格分配脚本(见代码见下)



对此有何想法/经验?不知何故,这是否被弃用?
(其他.setOption方法的工作方式:例如颜色)

我的工作表有3列(因此选择B2:C5),4行,简化测试目的。
这里是代码:

pre $函数GeneratePie(){
var sheet = SpreadsheetApp.getActiveSheet() ;
var range = sheet.getRange(B2:C5);
var pie = sheet.newChart()
.setChartType(Charts.ChartType.PIE)
.addRange(范围)
.setPosition(5,6,5,5)
//.setTitle(\"This is 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 !');

//另一个尝试
片段[0] ='{offset:0.2}';
pie.setOption('slices',slicces); // wrapper是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( '切片',{
0:{偏移:0.05},
1:{偏移:0.15},
2:{偏移:0.25},
3:{偏移: 0.35}
})

.build();
sheet.updateChart(chart);

欢迎发表评论...



谢谢!

解决方案

与App Script版本的可视化:饼图不完全互换。所以我不认为它现在在Apps Script中受到支持。



reverseCategories()是与切片相关的Apps脚本方法,它不是很多。


I've been spending (lots of) time trying to figure out how to explode/split a Pie Chart within Google Sheets / (eg. Using the slices setoption in Google Apps Script) http://fiddle.jshell.net/6d5fLwnm/4/ This works outside google sheets using Google Visualisation

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

But this method of the Google Chart Builder/Embedding is not working AT ALL in my "google sheet assigned script" (see below for code)

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 !

解决方案

The codes from Visualization: Pie Chart of Google Charts API are not fully interchangeable with that of App Script version yet. So I don't think it's supported as of now in Apps Script.

reverseCategories() is the Apps Script method related to slicing which isn't much.

这篇关于Google Sheet饼图JS:切片偏移方法不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆