所以我想在我的网站中嵌入以下代码,其目的是以表格形式显示每日和每月的网站指标。
我试图模拟页面,但我遇到了障碍:我似乎找不到使用谷歌图表 API 呈现两个不同谷歌图表的方法。
我敢肯定这是一个非常愚蠢的错误,我只是没有看到,但我已经研究了大约一个小时,只是无法弄清楚如何显示两个表格。
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['table']});
google.setOnLoadCallback(drawDailyTable);
function drawDailyTable() {
var Dailydata = new google.visualization.DataTable();
Dailydata.addColumn('string', 'Metric');
Dailydata.addColumn('number', 'Number');
Dailydata.addRows([
['Total Daily Unique Users', {v: 462, f: '462'}],
['Total Daily Visits', {v:6702, f: '6,702'}]
]);
var Dailytable = new google.visualization.Table(document.getElementById('table_div'));
Dailytable.draw(Dailydata, {showRowNumber: true});
}
</script>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['table']});
google.setOnLoadCallback(drawMonthlyTable);
function drawMonthlyTable() {
var Monthlydata = new google.visualization.DataTable();
Monthlydata.addColumn('string', 'Metric');
Monthlydata.addColumn('number', 'Number');
Monthlydata.addRows([
['Total Monthly Unique Users', {v: 12875, f: '12,875'}],
['Total Monthly Visits', {v:37980, f: '37,980'}]
]);
var Monthlytable = new google.visualization.Table(document.getElementById('table_div'));
Monthlytable.draw(Monthlydata, {showRowNumber: true});
}
</script>
</head>
<body>
<div id='table_div'></div>
</body>
</html>