hide specific column after sum

10 views
Skip to first unread message

Chris Lee

unread,
May 24, 2017, 1:31:40 AM5/24/17
to Google Visualization API
Can anyone out there know how to show "Total" only when hover the chart?

Right now when point to the chart, it will show both date and total.. For example, "Jan 1, 2017, Total:13" for first bar on column chart.  I tried the tooltip on below 3 ways but still failed. 

Thanks in advance for all your helps.

  function drawChart () {
var data = google.visualization.arrayToDataTable([
['Category', 'Name', 'Value'],
// ['Category', 'Name', {label: 'Value', role: 'tooltip'}],
[new Date(2017,0), 'A', 5],
[new Date(2017,0), 'B', 2],
[new Date(2017,0), 'C', 2],
[new Date(2017,0), 'D', 2],
[new Date(2017,0), 'E', 2],
[new Date(2017,1), 'A', 5],
[new Date(2017,1), 'B', 2],
[new Date(2017,1), 'C', 2],
[new Date(2017,1), 'D', 2],
[new Date(2017,1), 'E', 3],
[new Date(2017,2), 'A', 5],
[new Date(2017,2), 'B', 2],
[new Date(2017,2), 'C', 2],
[new Date(2017,2), 'D', 2],
[new Date(2017,2), 'E', 4],
[new Date(2017,3), 'A', 5],
[new Date(2017,3), 'B', 2],
[new Date(2017,3), 'C', 2],
[new Date(2017,3), 'D', 2],
[new Date(2017,3), 'E', 5],
[new Date(2017,4), 'A', 5],
[new Date(2017,4), 'B', 2],
[new Date(2017,4), 'C', 2],
[new Date(2017,4), D', 2],
[new Date(2017,4), 'E', 6],
[new Date(2017,5), 'A', 5],
[new Date(2017,5), 'B', 2],
[new Date(2017,5), 'C', 2],
[new Date(2017,5), 'D', 2],
[new Date(2017,5), 'E', 7],
]);

var aggregateData = google.visualization.data.group(data, [0], [{
// role: 'tooltip',
type: 'number',
label: 'Total',
column: 2,
aggregation: google.visualization.data.sum
}]);

// aggregateData.setColumnProperty(1, 'role', 'tooltip');

var chart = new google.visualization.ColumnChart(document.querySelector('#chart'));
var options = {
height: 300,
width: 400,
legend: 'none'
};
          
chart.draw(aggregateData, options);


Reply all
Reply to author
Forward
0 new messages