gpt4 book ai didi

google-visualization - 谷歌图表 API arrayToDataTable

转载 作者:行者123 更新时间:2023-12-01 11:32:56 25 4
gpt4 key购买 nike

我需要一些有关创建 Google API 数据数组的帮助。请参阅以下详细信息:我有以下动态创建的数组。

schoolYear = [ 2014,2015,];
schoolReading = [420.5,520.5,];
schoolWriting = [436.5,536.5,];
schoolSpelling = [425.1,525.1,];
schoolNumeracy = [395.5,495.5,];
schoolGramPunc = [436,536,];
schoolTotAvg = [437,537,];

我正在尝试像这样创建 google.visualization.arrayToDataTable:

for (i = 0; i < schoolTotAvg.length; i++) {
var data = google.visualization.arrayToDataTable([
['Year', 'Reading', 'Numeracy', 'Grammar/Punctuation', 'Writing', 'Spelling', 'Total Average'],
[schoolYear, schoolReading, schoolNumeracy, schoolGramPunc, schoolWriting, schoolSpelling, schoolTotAvg]
]);
}

当我看到页面源代码时,我没有得到正确的数组。

有人可以帮忙吗?

--潘卡吉

最佳答案

我找到了解决方案:-)

var dataArray = [['Year', 'Reading', 'Numeracy', 'Grammar/Punctuation', 'Writing', 'Spelling', 'Total Average']];

for (var n = 0; n < schoolTotAvg.length; n++) {
dataArray.push([schoolYear[n], schoolReading[n], schoolNumeracy[n], schoolGramPunc[n], schoolWriting[n], schoolSpelling[n], schoolTotAvg[n]]);
}

var data = new google.visualization.arrayToDataTable(dataArray);

var options = {
title: 'School Performance',
curveType: 'function',
legend: { position: 'bottom' }
};

var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

chart.draw(data, options);

关于google-visualization - 谷歌图表 API arrayToDataTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30690136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com