1

I created a Bubble Chart manually on the spreadsheet and I can see it. But I can't reach it by script. sheet.getCharts() doesn't return my Bubble Chart (but I see other charts)

/* OnOpen Trigger modifying an existing (embedded) chart */
function onOpen (e) {
  try {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
    var bubbleChart = null;

    var charts = sheet.getCharts();

    debugger

    for (var i in charts) {
      Logger.log(charts[i].getOptions().get('title'));
    }

  } catch (err) {
    Logger.log(err.toString());
  }
}

enter image description here

Rubén
  • 34,714
  • 9
  • 70
  • 166
Alex Pilugin
  • 683
  • 2
  • 10
  • 38
  • Have you tried logging the length of `charts`? You could also use an explicit loop rather than `for...in` ([here's an explainer](https://stackoverflow.com/questions/13645890/javascript-for-in-vs-for-loop-performance)). – Brian Nov 09 '17 at 12:56
  • I added a screenshot from a debugger. charts[4] [EmbeddedChart, EmbeddedChart, EmbeddedChart, EmbeddedChart] should have 5 EmbeddedCharts! – Alex Pilugin Nov 09 '17 at 13:04

2 Answers2

1

This appears to be a bug in apps script. It is referenced in a thread dating back to May of this year regarding timeline charts. I have opened a new bug report with Google.

Brian
  • 4,274
  • 2
  • 27
  • 55
0

From my point of view Google doesn't respect Bubble Chart!

sheet.getCharts() ignores Bubble Charts!

EmbeddedBubbleChartBuilder doesn't exist! and EmbeddedScatterChartBuilder doesn't care about sizeAxis option.

ChartType doesn't contain BUBBLE value: Enum ChartType | Apps Script

Alex Pilugin
  • 683
  • 2
  • 10
  • 38