google / google-visualization-issues

288 stars 35 forks source link

Word Trees - Cannot read properties of undefined (reading 'bb') #2933

Open Pradromalo opened 2 years ago

Pradromalo commented 2 years ago

Hello,

Draw function of Word Trees chart throws error, if the chart is incorporated into report of BI tool, that can generate html output.

I am trying to use Word Trees the following way:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

<div id="wordtree_basic" style="width: 9000px; height: 4500px;font-family: arial"></div>

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

      function drawChart() {
        var data = google.visualization.arrayToDataTable(
          [ ['Phrases'],
            ['cats are better than dogs'],
            ['cats eat kibble'],
            ['cats are better than hamsters'],
            ['cats are awesome'],
            ['cats are people too'],
            ['cats eat mice'],
            ['cats meowing'],
            ['cats in the cradle'],
            ['cats eat mice'],
            ['cats in the cradle lyrics'],
            ['cats eat kibble'],
            ['cats for adoption'],
            ['cats are family'],
            ['cats eat mice'],
            ['cats are better than kittens'],
            ['cats are evil'],
            ['cats are weird'],
            ['cats eat mice'],
          ]
        );

        var options = {
        maxFontSize: 20,
    fontName: 'Calibri',
          wordtree: {
            format: 'implicit',
            word: 'Cognos'
          }
        };

        var chart = new google.visualization.WordTree(document.getElementById('wordtree_basic'));
        chart.draw(data, options);
      }
    </script>

and receive the following error: Cannot read properties of undefined (reading 'bb')

I tried to investigate what throws the error - this part of code in https://www.gstatic.com/charts/51/js/jsapi_compiled_ui_module.js file throws the error:


...
gvjs_.KC = function(a, b, c) {
    var d = this.jF;
    if (3 === d.firstChild.nodeType)
        d.firstChild.data = a;
    else
        throw Error("Unexpected type of text node " + d.firstChild.nodeType);
    a = d.style;
    a.fontFamily = b.bb; // <<<<< throws ERROR since b is undefined
    a.fontSize = b.fontSize + gvjs_T;
    a.fontWeight = b.bold ? gvjs_st : "";
    a.fontStyle = b.Nc ? gvjs_Gp : "";
    a.display = gvjs_xb;
    null != c && (b = gvjs_NB("rotate(%ddeg)", c),
    a.transform = b,
    a.transformOrigin = gvjs_Mr,
    a.WebkitTransform = b,
    a.WebkitTransformOrigin = gvjs_Mr,
    a.MozTransform = b,
    a.MozTransformOrigin = gvjs_Mr,
    a.WAa = b,
    a.XAa = gvjs_Mr,
    a.msTransform = b,
    a.eEa = gvjs_Mr);
    b = d.clientWidth;
    d = d.clientHeight;
    a.display = gvjs_f;
    return new gvjs_A(b,d)
}
;
...

Is this bug or I am using word trees chart in wrong way? Can it be avoided or should be fixed?