这是我的第一个问题/请求帮助我的帐户。除了简单的即插即用之外,这是我第一次尝试使用javascript库。随着那说......
我希望构建一个用户信息中心,它可以从Google电子表格源中获取每个数据可视化的不同查询。
但是,我目前仍在尝试每页显示多个Google Charts可视化。虽然我目前只是想要显示多个Google Charts可视化,但未来仪表板页面将包含多个Google Charts可视化。话虽如此,该代码发布在下面。我知道我需要为每个电子表格或电子表格查询创建一个新查询,但我无法弄清楚如何在页面上绘制多个图表。
下面的代码就是我现在所拥有的...它目前没有绘制图形,但是我可以通过一些编辑来绘制它。
这是指向当前页面的链接: http://brentocreates.com/ziftydata/
让我知道我错过了什么。 提前谢谢!
<!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">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Zifty Driver Data</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/navbar-static-top.css" rel="stylesheet">
<link href="css/zifty.css">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="../../assets/js/ie-emulation-modes-warning.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
<!--Load Graphing/Charting JS -->
<script src="js/Chart.Core.js"></script>
<script src="js/Chart.Bar.js"></script>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[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">
google.load("visualization", '1', {packages:['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var queryHourly = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/1Yg7mmdMNkuxFIQ67j4d-digf0qwh4TeEfyBrHIcH5KA/edit?usp=sharing');
queryHourly.send(handleQueryResponse);
var queryMileage = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/1Yg7mmdMNkuxFIQ67j4d-digf0qwh4TeEfyBrHIcH5KA/edit?usp=sharing');
queryMileage.send(handleQueryResponse);
}
function handleQueryResponse(response1, response2) {
if (response1.isError()) {
alert('Error in query: ' + response1.getMessage() + ' ' + response1.getDetailedMessage());
return;
}
if (response2.isError()) {
alert('Error in query: ' + response2.getMessage() + ' ' + response2.getDetailedMessage());
return;
}
var dataHourly = response1.getDataTable();
var chartHourly = new google.visualization.ColumnChart(document.getElementById('hourlychart'));
chartHourly.draw(dataHourly, { legend: { position: 'none' } });
var dataMileage = response2.getDataTable();
var chartMileage = new google.visualization.ColumnChart(document.getElementById('mileagechart'));
chartMileage.draw(dataMileage, { legend: { position: 'none' } });
}
</script>
</head>
<body>
<!-- Static navbar -->
<div class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Zifty Driver Dashboard</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="../navbar/">Default</a></li>
<li class="active"><a href="./">Static top</a></li>
<li><a href="../navbar-fixed-top/">Fixed top</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-5 col-md-offset-1">
<h3>Average Hourly per Day of the Week</h3>
<span id="hourlychart"></span>
</div>
<div class="col-md-5">
<h3>Average Mileage per Day of the Week</h3>
<span id="mileagechart"></span>
</div>
</div>
<div class="row">
<hr />
</div>
<!-- Main component for displaying graphs -->
<div class="jumbotron">
<h1>Average Hourly vs. Mileage, per DotW</h1>
</div>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>