javascriptchartsgoogle-visualizationreact-google-charts

How to adjust Google Charts (WordTree) to take data source from Google sheets URL?


I want to get WordTree created from Google sheets URL as a data source

The wordTree chart is at: https://developers.google.com/chart/interactive/docs/gallery/wordtree

and changing Datasource can be found https://developers.google.com/chart/interactive/docs/drawing_charts

However I'm keep getting errors and can't grab the sheet and code doesn't run


Solution

  • seems to work with the chart wrapper class...

    google.charts.load('current', {
      packages: ['wordtree']
    }).then(function () {
      var chart = new google.visualization.ChartWrapper({
        chartType: 'WordTree',
        containerId: 'chart',
        dataSourceUrl: 'https://docs.google.com/spreadsheets/d/1loB8SHnERMVCyjaWWkWi-ADmA99Yjf4FrgGD-oPUPdA/edit?usp=sharing',
        query: 'SELECT A,B',
        options: {
          wordtree: {
            format: 'implicit',
            word: 'patio'
          }
        }
      });
      chart.draw();
    });
    

    be sure the query property is set to pull the columns with data.

    see following fiddle...
    https://jsfiddle.net/WhiteHat/L0vmk2tq/