Need Tooltips: Change google sheet existing data into DataTable

前端 未结 1 859
天涯浪人
天涯浪人 2021-01-15 02:49

Problem: All the documentation I see uses a DataTable that writes the data in the script itself. I need to call this tooltip data from existing rows. I need

相关标签:
1条回答
  • 2021-01-15 03:33

    in the embedded chart, use a data view definition to add the tooltip role...

    see following snippet...

    function newChart() {
      // Generate a chart representing the data in the range of A1:B15.
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheet = ss.getSheets()[11];
    
      // build the data view definition
      var COLUMN_SPEC = [
        0,
        1,
        {sourceColumn: 2, role: 'tooltip'}
      ];
      var viewSpec = Charts.newDataViewDefinition()
         .setColumns(COLUMN_SPEC)
         .build();
    
      var chart = sheet.newChart()
         .setChartType(Charts.ChartType.SCATTER)
         .setDataViewDefinition(viewSpec)
         .addRange(sheet.getRange('R3:S5000'))
         .addRange(sheet.getRange('Q3:Q5000'))
    
         .setPosition(5, 5, 0, 0)
         .build();
    
      sheet.insertChart(chart);
    }
    
    0 讨论(0)
提交回复
热议问题