Google Charts - Tooltips Treemaps

You are Here:

How to Draw a Tooltips Treemaps?

Note: Left click to zoom in and Right click to zoom out

Please wait google chart is loading...

In this example, we will draw a tooltips treemaps. Please hover the sections in the above chart to view tooltip.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://www.gstatic.com/charts/loader.js"></script> <style> .myTooltip{ background:#fd9; padding:10px; border-style:solid } </style> </head> <body> <div id="point"> </div> <script> google.charts.load('current', {'packages':['treemap']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Location', 'Parent', 'Market trade volume (size)', 'Market increase/decrease (color)'], ['Global', null, 0, 0], ['America', 'Global', 0, 0], ['Europe', 'Global', 0, 0], ['Asia', 'Global', 0, 0], ['Australia', 'Global', 0, 0], ['Africa', 'Global', 0, 0], ['Brazil', 'America', 11, 10], ['USA', 'America', 52, 31], ['Mexico', 'America', 24, 12], ['Canada', 'America', 16, -23], ['France', 'Europe', 42, -11], ['Germany', 'Europe', 31, -2], ['Sweden', 'Europe', 22, -13], ['Italy', 'Europe', 17, 4], ['UK', 'Europe', 21, -5], ['China', 'Asia', 36, 4], ['Japan', 'Asia', 20, -12], ['India', 'Asia', 40, 63], ['Laos', 'Asia', 4, 34], ['Mongolia', 'Asia', 1, -5], ['Israel', 'Asia', 12, 24], ['Iran', 'Asia', 18, 13], ['Pakistan', 'Asia', 11, -52], ['Egypt', 'Africa', 21, 0], ['S. Africa', 'Africa', 30, 43], ['Sudan', 'Africa', 12, 2], ['Congo', 'Africa', 10, 12], ['Zaire', 'Africa', 8, 10] ]); var options = { height: 400, minColor: '#e7711c', midColor: '#fff', maxColor: '#4374e0', showScale: true, generateTooltip: showStaticTooltip }; var tree = new google.visualization.TreeMap(document.getElementById('point')); tree.draw(data, options); function showStaticTooltip(row, size, value) { return '<div class="myTooltip">' + 'Learn Google charts at <a href="/">Wikimass.com</a></div>'; } } </script> </body> </html>

Reminder

Hi Developers, we almost covered 98% of Google Charts Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in Google Charts.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author