2016-11-28 74 views
0

首先 - 我只使用java脚本和Google Apps脚本大约一周。 我正试图自动完成学生完成的相当多的Google表格的标记。 我的计划是要有一个标准的谷歌表格,标记标记和奖励标记如下。 这是表2,从原材谷歌脚本图表访问属性

Question Criteria Cell reference Correct answer   Marks 
Question 1 FontWeight  A1    bold      1 
Question 2 FontFamily  A1   Times New Roman    2 
Question 3 FontSize  A1    16      2 
Question 4 Value   A1 Tables and Graphs by Fred Nerk  1 
Question 5 Heading Sheet Heading Tables and Graphs by Fred Nerk 1 
Question 6 ChartTitle  Chart Title Commonwealth Medal Tally 2014 2 
Question 7 ChartType  Chart Type  AREA     1 
Question 8 Value   A3    Rank     1 
Question 9 Value   B3    Country     1 
Question 10 Number   A4     1      1 
etc    

我对查找代码如下: 我这些变量发送到模块: Mysht是原材2 Studsheet是学生的电子表格 Studsht1是学生答卷 标准为每桌从以上表上方从表 correctAns 参考上述 我已经能够做一些图表工作 我然后与正确答案的过程学生回答,并给马克在一份报告等

function LookupCriteria(mysht2,Studsht1,reference,Criteria,correctAns,Studsheet){ 
    switch(Criteria) { 
case "FontSize": 
    testvalue = Studsht1.getRange(reference).getFontSize() 
    break; 
case "FontFamily": 
    testvalue = Studsht1.getRange(reference).getFontFamily(); 
    break; 
case "FontWeight": 
    testvalue = Studsht1.getRange(reference).getFontWeight(); 
    break; 
case "Value": 
    testvalue = Studsht1.getRange(reference).getValue(); 
    var lenanswer=correctAns.length; 
    testvalue=testvalue.substring(0,lenanswer); 
    break; 
case "Heading": 
    testvalue = StudSheet.getName(); 
    var lenanswer=correctAns.length; 
    testvalue=testvalue.substring(0,lenanswer); 
    break; 
case "ChartTitle": 
    var StudChart=Studsht1.getCharts()[0]; 
    var option = "title" 
    testvalue=StudChart.getOptions().get(option); 
    break; 
case "ChartType": 
    var StudChart=Studsht1.getCharts()[0]; 
    testvalue=Charts.ChartType; 
    break; 
case "Number": 
    testvalue=Studsht1.getRange(reference).getValue(); 
    return testvalue; 
// testvalue is the student answer 
} 

我的问题是: 我无法找到文件或代码访问从图表 实例信息如何“获取”的颜色为列“或横轴中使用的字体? 所有文档都是关于建筑图表的。 Cheers Col Taylor PS我知道这段代码不是最佳实践。最好使用数组和加载所有数据等 我真的只需要知道这个请求是否可能? 由于 干杯山口泰勒

+0

什么是您所指的“图表示例”?它是否在Apps脚本帮助参考中?你有链接吗? –

+0

非常感谢您的回答。很抱歉,在图表之后没有完整的缺失我想访问有关图表的信息。例如,一列的颜色是什么。横轴上使用的字体是什么。我不想改变这些。我想将它们与学生应该做的事情进行比较,并根据表格给予适当的评分。 Cheers Col –

回答

0

getCharts返回图表对象的数组是EmbeddedChart类型,其中documentation is here的。

看一看ChartOptions可以从使用getOptions(),和modify()可以用来改变各图表中检索 - 这些包含一些代码段,示出了在修改图表的选项。

您会看到有一系列不同的chartBuilder类型,您需要在对图表进行更改时使用其中一种类型,并且每种类型都有不同的选项可供设置 - 它有相当多的对象和方法,但从EmbeddedChart开始链接的文档应该包含在内。

+0

感谢您的回答。我已阅读此文档,但它涉及修改或构建图表。似乎没有多少参考将变量分配给统计图属性 - 除了上面每个代码的统计图的“标题”和“类型”。干杯Col –