Clickable pie chart

15 views
Skip to first unread message

Prakash joshi

unread,
Mar 8, 2019, 7:35:31 AM3/8/19
to Google Visualization API
I Want to open my data on a div on the same page, when clicked on chart's area or petals of pie chart. please anybody help me.
<html>
 
<head>
   
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
   
<script type="text/javascript">
      google
.charts.load('current', {'packages':['corechart']});
      google
.charts.setOnLoadCallback(drawChart);

     
function drawChart() {

       
var data = google.visualization.arrayToDataTable([
         
['Task', 'Hours per Day'],
         
['Work',     11],
         
['Eat',      2],
         
['Commute',  2],
         
['Watch TV', 2],
         
['Sleep',    7]
       
]);

       
var options = {
          title
: 'My Daily Activities'
       
};

       
var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart
.draw(data, options);
     
}
   
</script>
 
</head>
 
<body>
   
<div id="piechart" style="width: 900px; height: 500px;"></div>
 
</body>
</html>

Heywood Buzzfuddle

unread,
Mar 13, 2019, 5:33:00 PM3/13/19
to Google Visualization API


I would guess that deep in the Java Script there is something that a tool tip attaches to which represents a slice of a par or a segment of a bar or whatever.  It is probably possible to write a script that would load a div on mouseover of that item if you knew what it was called in the DOM. I is waaaaay beyond my understanding and abilities.

Perhaps you could just put a data table below the graphic on the page?
Reply all
Reply to author
Forward
0 new messages