嗨,伙计们真的在这里挣扎。尝试使用csv文件和Google Chart API来显示csv,但保留错误消息“Uncaught TypeError:无法在Object.success中读取未定义的属性'钩子'”。一直在搜索,但可以找到解决方案。“查看下面的代码。
@extends( 'layouts.app')
@section( '内容')
<script src="https://www.google.com/jsapi"></script>
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js"></script>
<script type="text/javascript"> // Reads in the csv file
/*$(function() { // grab the CSV
$.get("ifr.csv", function(csvString) { // display the contents of the CSV
$("#chart").html(csvString); }); });*/
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() { // grab the CSV
$.get("ifr.csv", function(csvString) {
var arrayData = $.csv2Arrays(csvString, {onParseValue: $.csv.hooks.castToScalar});
var data = new google.visualization.arrayToDataTable(arrayData);
var view = new google.visualization.DataView(data); view.setColumns([0,1]);
var options = { title: "Perfume Reports", 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' };
var chart = new google.visualization.ScatterChart(document.getElementById('chart')); chart.draw(view, options); }); }
</script>
</head>
<body>
<div id="chart"> </div>
</body>
@endsection