이 코드를 사용하여 csv 파일에서 Google 차트를 만들려고합니다. 이 코드는 대부분의 자습서에서 사용되는 것으로 나타났습니다. 그러나 거기에 몇 가지 문제로 인해, 나는 그것을 제대로 실행할 수 없습니다.Google Charts API : 'toArrays'속성을 읽을 수 없습니다. 정의되지 않음
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// grab the CSV
$.get("Chart1-data.csv", function(csvString) {
// transform the CSV string into a 2-dimensional array
var arrayData = $.csv.toArrays(csvString, {onParseValue: $.csv.hooks.castToScalar});
// this new DataTable object holds all the data
var data = new google.visualization.arrayToDataTable(arrayData);
// this view can select a subset of the data at a time
var view = new google.visualization.DataView(data);
view.setColumns([0,1]);
// set chart options
var options = {
title: "A Chart from a CSV!",
hAxis: {title: data.getColumnLabel(0), minValue: data.getColumnRange(0).min, maxValue: data.getColumnRange(0).max},
vAxis: {title: data.getColumnLabel(1), minValue: data.getColumnRange(1).min, maxValue: data.getColumnRange(1).max},
legend: 'none'
};
// create the chart object and draw it
var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
chart.draw(view, options);
});
}
나는이 튜토리얼로갑니다. 아무도 그 이유를 알고 있다면
Uncaught TypeError: Cannot read property 'toArrays' of undefined
이 날 일이 뭐죠 알려 주시기 바랍니다이 오류에 대한 해결책 :하지만 웹 서버에 실행에 나에게 다음과 같은 오류를 제공합니다.
무엇이 $ .csv입니까? – ebyt
@ebyt API 문서는 https://github.com/evanplaice/jquery-csv/blob/master/docs/api.md –
에서 가져 왔습니까? '' – ebyt