Add more column titles to Google Pie Chart

37 Views Asked by At

my query is GROUP BY 2 columns and I need to show that second column in the chart legend. I've tried a few things, but nothing has worked. Can some please assist.

Thanks Angel

var data = new google.visualization.DataTable();        
data.addColumn('string', 'Location');
data.addColumn('number', 'Pounds');

    for(i=0;i<my_2d.length;i++)
    data.addRow([
        my_2d[i] [0],
        parseInt(my_2d[i] [2])
    ]);
1

There are 1 best solutions below

0
WhiteHat On BEST ANSWER

the Pie Chart only accepts one additional column, which is for a tooltip when hovering a slice, see the Data Format.

however, if you're simply wanting to add more information to the legend entries,
you can simply append the values when adding to the data table, as follows...

my_2d[i][0] + ' - ' + my_2d[i][1]


var data = new google.visualization.DataTable();        
data.addColumn('string', 'Location');
data.addColumn('number', 'Pounds');

for(i=0;i<my_2d.length;i++)
data.addRow([
    my_2d[i][0] + ' - ' + my_2d[i][1],  // <-- here
    parseInt(my_2d[i] [2])
]);