Google Apps Script Chart Use row 1 as headers

前端 未结 1 540
忘了有多久
忘了有多久 2020-12-19 18:53

I have the following chart:

var ss = ... // get sheet
var chart = ss.newChart().asLineChart();
chart.setTitle(\"My Title\");
chart.addRange(dataSheet.getRang         


        
相关标签:
1条回答
  • 2020-12-19 19:34

    First off - your code is OK. I took a copy and made minor changes to it just to use a single sheet for illustration:

    Chart Screenshot - all good

    The problem is likely with your data, specifically the first row. Here's that same example, with some of the "Headers" changed from text into numbers. I believe it is behaving in the bad way you're describing.

    Chart Screenshot - problems

    One more time, but with the numbers in the header forced to be text. (In the spreadsheet, I input them as '4 and '5 - the leading single quote tells Spreadsheet to treat as text.)

    Chart Screenshot - all good again

    Just take a look at the data types in your first row, and make sure that they are Text.

    0 讨论(0)
提交回复
热议问题