Sankey: setAction is not a function

21 views
Skip to first unread message

Gyula Kósa

unread,
Jun 17, 2021, 8:50:43 AMJun 17
to Google Visualization API
Hi! I'm following the developer guide at https://developers.google.com/chart/interactive/docs/customizing_tooltip_content#full.

I get 'Sankey chart.html:66 Uncaught (in promise) TypeError: chart.setAction is not a function' error in the browser console for the following implementation.

I'm wondering what do I wrong?

    <script type="text/javascript">
        google.charts.load("current", {packages:['sankey', 'wordtree']});
        
        google.charts.setOnLoadCallback(drawSankeyChart);

        function drawSankeyChart() {
          var data = new google.visualization.DataTable();
          data.addColumn('string', 'From');
          data.addColumn('string', 'To');
          data.addColumn('number', 'Weight');
          data.addRows([
            ...
          ]);
      
          // Set chart options
          var options = {
            width: 1000,
            tooltip: {
                trigger: 'selection'
            }
          };
      
          var chart = new google.visualization.Sankey(document.getElementById('sankey_multiple'));
      
          chart.setAction({
                id: 'remove',
                text: 'Remove',
                action: function() {
                    selection = chart.getSelection();
                    alert(selection[0].row + 'will be removed');
                    }
                });

            chart.draw(data, options);
         };
...

Charles Friedo

unread,
Jun 29, 2021, 7:10:59 AMJun 29
to Google Visualization API
Hello,

You can create Sankey chart without coding in Google Sheets and Excel.

ChartExpo™ is a data visualization tool with 50+ custom chart types.

You can make charts with few clicks..
Sharing video on How to create Sankey diagram

Installation Sources:

Reply all
Reply to author
Forward
0 new messages