getSelection() method stopped working

44 views
Skip to first unread message

Simone Fracassa

unread,
May 13, 2021, 8:52:02 AM5/13/21
to Google Visualization API
Hello, I noticed the getSelection() method is not working anymore in all of Tree Map Charts I've created since years. They've always worked, but suddenly the getSelection method stopped returning the row/column value of selected item.

I tried this debugging handler and it returns "nothing", when normally, in Tree Map case, it should return the row value: getSelection()[0].row


function selectHandlerTree() {
           var selection = tree.getSelection();
  var message = '';

  for (var i = 0; i < selection.length; i++) {
    var item = selection[i];
    if (item.row != null && item.column != null) {
      message += '{row:' + item.row + ',column:' + item.column + '}';
    } else if (item.row != null) {
      message += '{row:' + item.row + '}';
    } else if (item.column != null) {
      message += '{column:' + item.column + '}';
    }
  }
  if (message == '') {
    message = 'nothing';
  }
  alert('You selected ' + message);
        }
              
Thanks.

Simone Fracassa

unread,
May 17, 2021, 4:38:25 AM5/17/21
to Google Visualization API
I temporarily solved by loading the previous version of libraries (49).

Daniel LaLiberte

unread,
May 17, 2021, 11:10:16 AM5/17/21
to Google Visualization API
Hi Simone,

The getSelection method should return whatever the current selection is, which sometimes can be "nothing".   Clicking on a selected item also typically toggles the selection, so that whatever was previously selected no longer is.  So, in order for us to reproduce the problem you are seeing, you have to describe the sequence of events and the state of the selection before and after the events.

The Treemap chart was changed in v50 to support additional event configuration options.  It is possible that something was broken unintentionally, but more likely, we have cleaned up a previously unintentional bug that you were taking advantage of.  Either way, we would like to know.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/9ca143f7-3b38-43ad-b790-6b47985919cdn%40googlegroups.com.


--

Daniel LaLiberte

 • SWE

 Cambridge MA

 • dlaliberte@Google.com

Simone Fracassa

unread,
May 18, 2021, 4:55:25 AM5/18/21
to Google Visualization API
Hi Daniel, thanks for your answer.

I think I got the problem: new Tree Map version conflicts with a quite old javascript framework I use specifically in this project to pull data via AJAX based on wich element you select in the treemap. The framework is "PrototypeJS". When I load the framework with the current version of Tree Map the "tree.getSelection()" method returns ad undefined object instead of an array of one element. If I disable the framework loading, the method returns the array as usual.

So this is basically a problem of mine. :)
I think I'll continue using the v49 which is perfect for my purpose.

Thanks again for your help,
regards.
Reply all
Reply to author
Forward
0 new messages