2016-11-28 78 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 –