how to add links to google pie chart slices and send that variable to new page once clicked

152 Views Asked by At
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

<script type="text/javascript">

var jsvar = '<?=$count?>';
// Load google charts
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);

// Draw the chart and set the chart values
function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['Task', 'Rating'],
  ['Good',  <?php echo $count; ?>], 
  ['Average', <?php echo $count1; ?>],
  ['Bad',  <?php echo $count2; ?>],


]);

  // Optional; add a title and set the width and height of the chart
  var options = {'title':'Windoek' , 'width':400, 'height':400};

  // Display the chart inside the <div> element with id="piechart"
  var chart = new google.visualization.PieChart(document.getElementById('piechart1'));
  chart.draw(data, options);
  

  google.visualization.events.addListener(chart, 'select', function() {
    var selection = chart.getSelection();
    window.open("table.php?myvar=" + encodeURI(selection));
});

I would like to get the selected task header and send it to new page ......

Example , If someone clicks the bad pie chart slice , The variable Bad and Title of pie chart should be send via link to new page for processing ....if someone selects Good than the variable Good with title of pie chart send to new page

0

There are 0 best solutions below