我已经执行了所有的查询功能,首先对帐户进行身份验证,然后从 Google Analytics 获取查询结果。
我在下面的表格代码中输出结果;
//To Get the Profile ID first
function queryCoreReportingApi(profileId) {
updatePage('Querying Core Reporting API.');
gapi.client.analytics.data.ga.get({
'ids': 'ga:' + profileId,
'start-date': lastNDays(14),
'end-date': lastNDays(0),
'dimensions': 'ga:date,ga:year,ga:month,ga:week,ga:day',
'metrics': 'ga:visitors'
}).execute(handleCoreReportingResults);
}
//To Show the Result
function handleCoreReportingResults(response) {
if (!response.code) {
if (response.rows && response.rows.length) {
var output = [];
// Profile Name.
output.push('Profile Name: ', response.profileInfo.profileName, '<br>');
var table = ['<table>'];
// Put headers in table.
table.push('<tr>');
for (var i = 0, header; header = response.columnHeaders[i]; ++i) {
table.push('<th>', header.name, '</th>');
}
table.push('</tr>');
// Put cells in table.
for (var i = 0, row; row = response.rows[i]; ++i) {
table.push('<tr><td>', row.join('</td><td>'), '</td></tr>');
}
table.push('</table>');
output.push(table.join(''));
outputToPage(output.join(''));
} else {
outputToPage('No results found.');
}
} else {
updatePage('There was an error querying core reporting API: ' +
response.message);
}
}
function outputToPage(output) {
document.getElementById('output').innerHTML = output;
}
function updatePage(output) {
document.getElementById('output').innerHTML += '<br>' + output;
}
现在的问题是我如何才能将这个返回的结果显示在谷歌图表(条形图 - 饼图等)中。我厌倦了使用 googlecharts.js,但不知道用户如何集成。任何人都可以帮忙吗