0

Я работаю на панели управления с помощью Bootstrap и Google Charts. У меня проблема с переполнением диаграмм. Я впервые заметил проблему на страницах, где все содержимое не помещается на экране, и появляется вертикальная полоса прокрутки. После загрузки страницы, если я изменил размер окна браузера, диаграммы снова рисуют, и все выглядит хорошо. Как я могу обойти эту проблему?Google Charts overflow with Bootstrap

Bootstrap Googlechart responsive dashboard

Я включил образец кода с гистограммой, которая появляется на картинке:

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Site1.com Analytics</title> 

    <!-- Bootstrap --> 
    <link href="css/bootstrap.min.css" rel="stylesheet"> 
    <link href="css/styles.css" rel="stylesheet"> 

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
    <!--[if lt IE 9]> 
     <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
    <![endif]--> 

     <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
     <script type="text/javascript"> 
      // Load the Visualization API and the chart package. 
      google.load('visualization', '1', {'packages':['corechart']}); 

      // Set a callback to run when the Google Visualization API is loaded. 
      google.setOnLoadCallback(drawChart_google_user_count); 

      function drawChart_google_user_count() { 
       var json = $.ajax({ 
        url: 'google_analytics_user_count_data.php', // make this url point to the data file 
        dataType: 'json', 
        async: false 
       }).responseText; 

       // Create our data table out of JSON data loaded from server. 
       var data = new google.visualization.DataTable(json); 
       var options = { 
             height: 300, 
             chartArea: {width: '98%', height: '80%'}, 
             hAxis: {showTextEvery: 7, textStyle: {fontSize: '10'}}, 
             legend: {position: 'top', textStyle: {color: 'blue', fontSize: 12}}, 
             lineWidth: 4, 
             pointShape: 'circle', 
             pointSize: 6, 
             vAxis: {textPosition: 'in', gridlines: {count: 3}, minorGridlines: {count: 2}, textStyle: {fontSize: 12}}, 
       }; 
       // Instantiate and draw our chart, passing in some options. 
       //do not forget to check ur div ID 
       var chart = new google.visualization.AreaChart(document.getElementById('chart_div_google_user_count')); 
       chart.draw(data, options); 
      } 

         $(window).resize(function(){ 
          drawChart_google_user_count(); 
         })         
      </script> 

    </head> 
    <body> 

     <div class="container-fluid"> 
      <div class = "row voffsetpercent"> 
       <div class = "col-md-12"> 
        <div class = "chart-title">Visitors Per Day</div> 
        <div id="chart_div_google_user_count"></div> 
       </div> 
      </div> 
     </div> 

     <!-- Include all compiled plugins (below), or include individual files as needed --> 
     <script src="js/bootstrap.min.js"></script> 

    </body> 
</html> 
+0

Код, пожалуйста ... – isherwood

ответ

1

Я установил высоту в рх на каждом из Div тегов, содержащих диаграммы, как так:

<div id="chart_div_google_user_count" style="height:300px;"></div> 

Это, похоже, очищает график от переполнения div при начальной загрузке страницы.