jeudi 25 octobre 2018

Laravel - unable to get value from google pie chart listener

In here I need to get the data.text of the google pie chart. I have added an listener to get the value from pie chart selection. In my case that method return only the percentage of that selected part of the pie chart. Below is the code

index.blade.php

function load_chart_data() 
{
    $.ajax({
        url: "", // provide correct url
        type: 'GET',
        dataType: 'JSON', 
        success: function(chart_values) 
        {   
          var data = google.visualization.arrayToDataTable(chart_values);
          var options = {
                     'width':650,
                     'height':550,
                  };
          var chart = new google.visualization.PieChart(document.getElementById('catwiseChart'));
          google.visualization.events.addListener(chart, 'select', 
            function(){


              console.log(this.getSelection().focusNode.data);


          });    
          chart.draw(data, options);         

              }
          });
}

within 'console.log(this.getSelection().focusNode.data);' line I need to return the label name of that selection.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire