将某些选项与Google Apps脚本一起用于嵌入式图表

时间:2019-04-13 21:38:22

标签: google-apps-script charts

创建嵌入式折线图时,private static void printAllQeriesIndeicesInSentence(List<String> sentences, List<String> queries) { Map<Integer, List<String>> sentenceMap = new HashMap<>(); for(int i=0; i < sentences.size(); i++){ List<String> words = Arrays.asList(sentences.get(i).split("\\s+")); sentenceMap.put(i, words); } for(String query: queries){ List<String> queryList = Arrays.asList(query.split("\\s+")); for(Map.Entry<Integer, List<String>> e: sentenceMap.entrySet()){ List<String> wordsList = e.getValue(); if(wordsList.containsAll(queryList)){ System.out.print(e.getKey() + " "); } } System.out.println(); } } 的某些选项对我不起作用。

Options for embedded line chart

例如这些:

cd /tmp/
wget  https://deb.nodesource.com/setup_8.x

echo 'deb https://deb.nodesource.com/node_8.x  stretch  main' > /etc/apt/sources.list.d/nodesource.list

wget -qO - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -

apt update

apt install  nodejs

node -v

npm -v

没有什么适合我的嵌入式折线图。

这是我创建图表的方式(它起作用):

.setOption

1 个答案:

答案 0 :(得分:0)

调用setOption的位置错误。

以下...

var area = {left:20,top:0,width:'50%',height:'75%'}
.setOption("chartArea", area)

与...相同

var area = {left:20,top:0,width:'50%',height:'75%'}.setOption("chartArea", area)

您正尝试在创建的自定义对象setOption上使用area
而不是图表对象。

首先创建area,然后将其添加到图表中...

var area = {left:20,top:0,width:'50%',height:'75%'};

var chart = sheet.newChart()
    .setChartType(Charts.ChartType.LINE)
    .addRange(range).setTransposeRowsAndColumns(true)
    .setPosition(2, 3, 0, 0)
    .setOption("title", name)
    .setOption("chartArea", area)  // <-- add area
    .build();