Change attribute in Jquery

1

I wanted to know if you can modify the attributes of a charts of Google with a Jquery. Example:

google.load("visualization", "1", {packages:["corechart"]});
  google.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: 'teste',
      pieHole: 0.4,
    };

    var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
    chart.draw(data, options);
  }

  $(window).resize(function() {
    if( $(window).width() < 500){

      Alterar aqui!!!!
  }

  });

I wanted to change title there in var options for example.

    
asked by anonymous 06.05.2015 / 20:59

1 answer

0

To make the graph responsive you should call the function resizeCharts() within the function drawChart() .

google.load("visualization", "1", {packages:["corechart"]});
google.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: 'teste',
      pieHole: 0.4,
    };

    var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
    chart.draw(data, options);

    function resizeCharts() {
      // redraw charts, dashboards, etc here
      chart.draw(data, options);
    }

    $(window).resize(resizeCharts);
}
    
12.09.2016 / 16:32