Javascript examples for Google Chart:Legend
Show tooltip on Google chart legend
<html> <head> <title>Bar Chart Example</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script> </head> <body> <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}"></script> <div id="chart_div" style="width: 900px; height: 500px;"></div> <script type="text/javascript"> google.setOnLoadCallback(drawChart); function drawChart() {/*from w w w. j a v a2 s .c o m*/ var data = google.visualization.arrayToDataTable([ ['Year', 'Sales', 'Expensesytfttyftyttytyfttytyftytytfty'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] ]); var options = { title: 'Company Performance', vAxis: {title: 'Year', titleTextStyle: {color: 'red'}} }; var chart = new google.visualization.BarChart(document.getElementById('chart_div')); function myReadyHandler(){ $('g text').mouseenter(function(e){ if($(this).text().indexOf('...')!= -1) return; $('.charts-tooltip').hide(); $('body').append('<div style="position: absolute; visibility: visible; left: '+(e.pageX-50)+'px; top: '+(e.pageY+20)+'px;" class="charts-tooltip"><div style="background-color: infobackground; padding: 1px; border: 1px solid infotext; font-size: 14px; margin: 14px; font-family: Arial; background-position: initial initial; background-repeat: initial initial;">'+$(this).text()+'</div></div>'); }) $('g').mouseleave(function(e){ $('.charts-tooltip').hide(); }) } google.visualization.events.addListener(chart, 'ready', myReadyHandler); chart.draw(data, options); } </script> </body> </html>