我正在为自己制作一个仪表板,我想在其中查看从特定站点下载项目的次数,该站点在其站点上显示此信息。它使用 Google API 以图形形式显示信息,因此值在<script>
标签内。
看起来像这样
<html>
<body>
<!-- ...somehtml -->
<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 data = new google.visualization.DataTable();
data.addColumn('string', 'Date');
data.addColumn('number', 'Uses');
data.addRows([['9 May', 1],['22 May', 14],['23 May', 27],['24 May', 23],['25 May', 5],['26 May', 10],['27 May', 20],['28 May', 14],['29 May', 9],['30 May', 8],['31 May', 3],['1 Jun', 2],['2 Jun', 4],['4 Jun', 4],['5 Jun', 2],['6 Jun', 4],['7 Jun', 6],['8 Jun', 7],['9 Jun', 9],['10 Jun', 14],['11 Jun', 6],['12 Jun', 8],['13 Jun', 14],['14 Jun', 13],['15 Jun', 13],['16 Jun', 19],['17 Jun', 4],['18 Jun', 4],['19 Jun', 3],['20 Jun', 1],['22 Jun', 3],['23 Jun', 10],['24 Jun', 3],['25 Jun', 8],['26 Jun', 5],['27 Jun', 10],['28 Jun', 45],['29 Jun', 23]]);
var options = {
width: 277, height: 136,
title: 'Usage Statistics This Month',
titlePosition: 'none',
legend: {position:'none'},
chartArea: {left:0, top:24, width:277, height: 110},
hAxis: {textPosition: 'none'}, vAxis: {textPosition: 'in'}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
...somehtml
</body>
</html>
我想要的数据是“data.addRows”之后的数据。我是新手,所以我找不到这样做的方法。我想知道是否可以将值存储在这种格式的数组中:
例子 :
对于 -> ['5 月 9 日',1]
我需要它在以'23 Jun'为键和10为值的数组中