New Google Charts Error when clicking on row in table. Uncaught TypeError: b.split is not a function -- Has been working for several years

New Google Charts Error when clicking on row in table. Uncaught TypeError: b.split is not a function -- Has been working for several years

我们有多个 Google 可视化 table,我们已经成功使用了几年。然而,在过去的一周里,我们开始在其中许多人中看到这个错误

我们要做的是单击 table 中的一行,以允许我们根据该行的内容超链接到另一个页面。正如我所说,它已经工作了好几年。我确切地知道它在哪里坏了。正是这一行触发了错误:

var row = table.getSelection()[0].row;

我知道是这一行,因为如果我硬编码 ROW 的值,超链接会按预期工作。

对于未更改的代码可能导致此错误的原因有什么建议吗?

代码如下:

        <!--Load the AJAX API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.css" rel="stylesheet" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.js"></script>


    <script type="text/javascript">

    google.load("visualization", "1.1", {packages:["table"]});
    google.setOnLoadCallback(drawVisualization);

    function drawVisualization() {

                    var d = new google.visualization.arrayToDataTable([$tableReportResults]);

                    var table = new google.visualization.Table(document.getElementById('table_report_results'));

                    var view = new google.visualization.DataView(d);
                            
                    var cssClassNames = {'hoverTableRow': 'hover-table-row', headerCell: 'googleHeaderCell'};
                    var colIndex = 0;
                    var  last_row = d.getNumberOfRows() -1;
                    var ts =  $( "#dropdown_1_dropdown option:selected" ).val();

                    var syear =  $( "#dropdown_2_dropdown option:selected" ).text();
                    syear = encodeURIComponent(syear);
                    google.visualization.events.addListener(table, 'ready', function () {
                        $('.google-visualization-table-table').find('td').each(function() {
                            $(this).mouseover(function(){
                                    colIndex = $(this).index();
                                    var row = $(this).parent().index() - 1; // subtract 1 for the table header
                                    //console.log(row, colIndex);
                             });
                        });
                    });

                        google.visualization.events.addListener(table, 'select', function() {           

                            $('.google-visualization-table-table').find('td').each(function() {
                                $(this).mouseover(function(){
                                        colIndex = $(this).index();
                                        row = $(this).parent().index() - 1; // subtract 1 for the table header
                                        console.log('mouseover = ' + colIndex + ' , ' + row);
                                        }); 
                                });
                                
                        var row = table.getSelection()[0].row;

我使用 google 图表的先前版本 49 解决了我的问题。

 <script>
      google.charts.load('49', 
        {packages: ['corechart']});
    </script>

或:

<script type="text/javascript">
    {literal}google.charts.load('49', {packages: ['corechart', 'geochart', 'timeline', 'gantt', 'treemap']});{/literal}
</script>

如果您使用实际版本,您应该根据以下信息更改您的代码:

https://groups.google.com/g/google-visualization-api/c/G4Keck3KVwU