[Solved] Google radar chart not rendering when more than 2 columns of input is given


You are loading the wrong chart library:

google.load('visualization', '1', {'packages':['corechart']});

should be:

google.load('visualization', '1', {'packages':['imagechart']});

Also, you have a trailing comma at the end of your options array, which you should remove:

var options = {cht: 'rs', chco: '00FF00,FF00FF', chg: '25.0,25.0,4.0,4.0', chm: 'B,FF000080,0,1.0,5.0|B,FF990080,1,1.0,5.0'};

You can simplify your handling of the JSON as well, as there is no need to input it as a string and then eval it – you can just use the output as is:

var data = new google.visualization.DataTable(<?php echo json_encode($response); ?>);

Edit:

There are a few more things you should do. First, remove this line:

echo json_encode($response);

from the PHP section at the top, as it is printing out the json string into your HTML where you don’t want it. Second, move the script tag for your javascript into either the <head> or <body> elements, as <script> is not a valid child of <html>. Third, you are missing the new keyword in front of the DataTable constructor:

var dataTable = new google.visualization.DataTable(response);

Those adjustments should fix it you.

5

solved Google radar chart not rendering when more than 2 columns of input is given