Search code examples
google-apps-scriptgoogle-sheetsgoogle-sheets-formulacustom-functionsparklines

How to create many graphs on chart in Google sheets?


Via =SPARKLINE(myFun()) I can draw one graph. However I need to draw 10 graphs.

I tried to return in myFun multi-dimension array, but I got:

Error
Function SPARKLINE line parameter 1 range must be a single row, a single column, two rows or two columns.

In Google I found some examples how to create many graphs selecting range manually (for example see https://webapps.stackexchange.com/questions/63174/create-a-google-sheets-chart-with-multiple-data-ranges-with-separate-key-columns/63233). But it is not my case. I need to draw data from functions. In sheets I have data which I need to process.


Solution

  • As SPARKLINE doesn't support array formulas(in the sense of autofill), you would need to use a menu or a button to create(setFormulas()) multiple =SPARKLINE(MYFUN()) formulas over 10 cells.

    Alternatively, You can create full fledged charts using the EmbeddedChart class.