Twitter bootstrap 谷歌图表溢出与引导
我一直在使用Bootstrap和Google图表制作仪表板。我遇到了一个图表溢出的问题。我第一次注意到这个问题是在所有内容都不适合屏幕的页面上,出现了垂直滚动条。加载页面后,如果我重新调整浏览器窗口的大小,图表就会重新绘制,一切看起来都很好。我如何解决这个问题 我已经在图片中显示的面积图中包含了一个代码示例:Twitter bootstrap 谷歌图表溢出与引导,twitter-bootstrap,google-analytics,google-visualization,Twitter Bootstrap,Google Analytics,Google Visualization,我一直在使用Bootstrap和Google图表制作仪表板。我遇到了一个图表溢出的问题。我第一次注意到这个问题是在所有内容都不适合屏幕的页面上,出现了垂直滚动条。加载页面后,如果我重新调整浏览器窗口的大小,图表就会重新绘制,一切看起来都很好。我如何解决这个问题 我已经在图片中显示的面积图中包含了一个代码示例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">
<!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>
Site1.com分析
//加载可视化API和图表包。
load('visualization','1',{'packages':['corechart']});
//将回调设置为在加载Google Visualization API时运行。
setOnLoadCallback(绘图图\谷歌\用户\计数);
函数绘图图\谷歌\用户\计数(){
var json=$.ajax({
url:'google\u analytics\u user\u count\u data.php',//使此url指向数据文件
数据类型:“json”,
异步:false
}).responseText;
//使用从服务器加载的JSON数据创建我们的数据表。
var data=new google.visualization.DataTable(json);
变量选项={
身高:300,
图表区:{宽度:“98%”,高度:“80%”,
hAxis:{showTextEvery:7,textStyle:{fontSize:'10'},
图例:{位置:'top',文本样式:{颜色:'blue',字体大小:12}},
线宽:4,
点形状:“圆”,
点数:6,
变量:{textPosition:'in',网格线:{count:3},最小网格线:{count:2},textStyle:{fontSize:12},
};
//实例化并绘制图表,传入一些选项。
//别忘了检查你的部门ID
var chart=new google.visualization.AreaChart(document.getElementById('chart\u div\u google\u user\u count');
图表绘制(数据、选项);
}
$(窗口)。调整大小(函数(){
绘图图\谷歌\用户\计数();
})
每日访客
我在每个包含图表的div标记上设置了一个高度(以px为单位),如下所示:
<div id="chart_div_google_user_count" style="height:300px;"></div>
这似乎可以清除图表在初始加载页面时溢出div的问题