0
我試圖通過拉取頁面上已有的數據來填充Google圖表中的數組。這是我想要填充數組:從谷歌圖表列表中填充JavaScript數組
var data = google.visualization.arrayToDataTable([
['Month', 'Target', 'Actual'],
['barchartTitle', ($barchartTarget), ($barchartActual)],
]);
這裏是我的一切目前都(包括數組):
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
$(document).ready(function() {
$("li.dfwp-item .neo-cqwp-barchart .neo-cqwp-barchartTitle").each(function() {
barchartTitle = $(this).html();
});
$("li.dfwp-item .neo-cqwp-barchart .neo-cqwp-barchartTarget").each(function() {
barchartTarget = $(this).html();
});
$("li.dfwp-item .neo-cqwp-barchart .neo-cqwp-barchartActual").each(function() {
barchartActual = $(this).html();
});
});
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Month', 'Target', 'Actual'],
['barchartTitle', ($barchartTarget), ($barchartActual)],
]);
var options = {
title: '',
colors: ['#515254', '#00B0F0'],
legend: { position: 'top', alignment: 'center', maxLines: 3 }
};
var chart = new google.visualization.ColumnChart(document.getElementById('revenuetarget'));
chart.draw(data, options);
}
</script>
<div id="revenuetarget" style="width: 100%; height: 300px;"></div>
什麼是你的問題/問題? – neuronaut
我希望有人會引導我從barchartTitle,barchartTarget,barchartActual獲取數值並構建出頁面頂部提到的數組: var data = google.visualization.arrayToDataTable(['Month', 'Target','Actual'], ['barchartTitle',($ barchartTarget),($ barchartActual)], ]); 我有什麼不工作。 –