Hi,
I have a problem with sum of column in datatable chart:
the last row write a single column total's, but the column have not a time 
format, infact the total is a numeric sum
Someone have a tips....?

function drawTable()
{ 
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Data');
        data.addColumn({type:'number', label:'Ore sessione'});
        data.addColumn({type:'number', label:Time1'});
data.addColumn({type:'number', label:'Time2'});
data.addColumn({type:'number', label:'Time3'});
data.addColumn({type:'number', label:'Time4});
data.addColumn({type:'number', label:'Time5'})
        data.addRows([
          ['01/08/2016 lun', 9.02, 0.00, 0.25, 8.30, 8.00, 0.30],
          ['02/08/2016 mar', 8.35, 0.00, 0.33, 8.0, 8.00, 0.0],
          ['03/08/2016 mer', 8.44, 0.15, 0.58, 7.45, 8.00, 0.0],
          ['04/08/2016 gio', 8.42, 0.00, 0.25, 8.15, 8.00, 0.15],
          ['05/08/2016 ven', 8.39, 0.00, 0.29, 8.0, 8.00, 0.0],
          ['06/08/2016 sab', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['07/08/2016 dom', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['08/08/2016 lun', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['09/08/2016 mar', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['10/08/2016 mer', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['11/08/2016 gio', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['12/08/2016 ven', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['13/08/2016 sab', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['14/08/2016 dom', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['15/08/2016 lun', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['16/08/2016 mar', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['17/08/2016 mer', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['18/08/2016 gio', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['19/08/2016 ven', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['20/08/2016 sab', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['21/08/2016 dom', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['22/08/2016 lun', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['23/08/2016 mar', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['24/08/2016 mer', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['25/08/2016 gio', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['26/08/2016 ven', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['27/08/2016 sab', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['28/08/2016 dom', 0.0, 0.00, 0.0, 0.0, 0.0, 0.0],
          ['29/08/2016 lun', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['30/08/2016 mar', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0],
          ['31/08/2016 mer', 0.0, 8.00, 0.0, 0.0, 0.0, 0.0]
        ]);
        function getSum(data, column) {
          var total = 0;
          for (i = 0; i < data.getNumberOfRows(); i++)
            total = total + data.getValue(i, column);
          return total;
        }
        var total_cells = [{v: 'Total',p: {className: 'TotalCell'}}];
        for (j = 1; j < data.getNumberOfColumns(); j++) {
          total_cells.push( getSum(data, j) );
        }
        data.addRow(total_cells); 
var formatter = new google.visualization.NumberFormat({prefix: '', 
negativeColor: 'red', negativeParens: true});
formatter.format(data, 1);
formatter.format(data, 2);
formatter.format(data, 3);
formatter.format(data, 4);
formatter.format(data, 5);
formatter.format(data, 6);
StatusTable = new 
google.visualization.Table(document.getElementById('table_div'));
google.visualization.events.addListener(StatusTable, 'ready', function ()
{
resetStyling('table_div');
});
google.visualization.events.addListener(StatusTable, 'sort', function (ev)
{    
var parentRow = $('#table_div td.TotalCell').parent();
if (!parentRow.is(':last-child'))
{
parentRow.siblings().last().after(parentRow);
}
resetStyling('table_div');
});

StatusTable.draw(data, 
{
allowHtml: true,
showRowNumber: false,
width: '100%',
height: 'auto'
});

}


TOTAL RESULT: 
Time1:    42.62
Time2:  136.15
Time3:     1.70
Time4:   39.90
Time5:   40.00
Time6:     0.45

THANKS+++

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/a75f90e9-c3f9-41d9-b43b-ee606af46874%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to