0

The code below shows expected result, however, when i try o resize the window the chart is not resizing I don't know what i have missed and how to do it, please help. Thanks in advance.

enter code h<div class="custom-bar-chart">
        <script>
            
            google.charts.load('current', {'packages':['bar']});
            google.charts.setOnLoadCallback(drawChart);
      
            function drawChart() {
              var data = google.visualization.arrayToDataTable([
                ['secção', 'ValorTotal','totalcds'],
                <?php
                  $query="select valor, secção,  count(secção) as totalcds,sum(valor) as ValorTotal  from tbl_cds GROUP by secção";
                  $res=mysqli_query($con,$query);
                  while($data=mysqli_fetch_array($res)){
                    $sessao=$data['secção'];
                    $valor=$data['ValorTotal'];
                    $totalcds=$data['totalcds'];
                 ?>
                 ['<?php echo $sessao;?>','<?php echo $valor;?>',<?php echo $totalcds;?>],   
                 <?php   
                  }
                 ?> 
              ]);
      
              var options = {
                chart: {
                  // title: 'Company Performance',
                  subtitle: ' total de comunicacoes',
                },
                bars: 'vertical' // Required for Material Bar Charts.
              };
      
             
                var chart = new google.charts.Bar(document.getElementById('barchart_material'));
                chart.draw(data,google.charts.Bar.convertOptions(options));
            window.onload = resize;
            window.onresize = resize;
            
              
            }
            
            </script>
            <div id="barchart_material" style="height: 290px; width:1239px; margin-top: -37px; margin-left: -10px; position: relative;border-bottom: 1px solid #c9cdd7;"></div>
ere
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Abcode
  • 25
  • 1
  • 7

0 Answers0