Google donut chart for unknown number of variables Google donut chart for unknown number of variables php php

Google donut chart for unknown number of variables


How can this question recieve 5 upvotes in 3 hours..... All it has is large code snippets, and barelly any useful info.

I would start by saving my php input directly into two global javascript variables (instead of creating hidden HTML elements).After accomplishing that I'd replace

var data = google.visualization.arrayToDataTable([      ['Phase', 'Contacts per phase'],     for(i=0;i<=ta;i++)     {        ['admins[i]',     contacts[i]],     }    ]);

with

var data = google.visualization.DataTable();     data.addColumn('string','Phase');     data.addColumn('string','Contacts per Phase');     for(i=0;i<admins.length;i++){        data.addRow([admins[i], contacts[i]]);     };

That would add two columns, Phase and Contacts per Phase, and then populate it with one row per Admin.

Read more about passing php variables into Javascript variables here, very good reading if you're interested.