我有一个CSV文件,其值为date value1 value2
。我想用这些数据填充Google图表。使用jquery-csv.js,我正在读取值。
<script type="text/javascript" src="js/jquery.csv.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
$.get("data.csv", function(csvString) {
// transform the CSV string into a 2-dimensional array
var arrayData = $.csv.toArrays(csvString, {onParseValue: $.csv.hooks.castToScalar});
//alert(arrayData);
// this new DataTable object holds all the data
var data = new google.visualization.arrayToDataTable(arrayData);
alert(data.getColumnLabel(0));
//Here I alert like 06/11/201522
The usual google chart code follows
});
}
</script>
当我提醒data.getColumnLabel(0)时,我得到第一行的所有值的组合。我该如何拆分?我希望每个列数据都在一个单独的变量中。任何帮助表示赞赏。