Uncaught TypeError: Cannot read property 'arrayToDataTable' of undefined
ajax, google-visualization, jquery
Solution
Make sure you are loading the Google Visualization API correctly.
Docs here: https://google-developers.appspot.com/chart/interactive/docs/basic_load_libs
You probably need something like this:
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API library and the piechart library.
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
// ... draw the chart...
</script>
Problem
I am facing this error don't know why this error is coming. I am using codeigniter and this is jquery error. This is my view page ``` <script> $(function() { $("#accordion").accordion({ collapsible: true, heightStyle: "content" }); }); var data = google.visualization.arrayToDataTable([ ['Attendance Type', 'Count'], ['Present', <?php echo $student_attendance_count['present']; ?>], ['Absent', <?php echo $student_attendance_count['absent']; ?>], ['On Leave', <?php echo $student_attendance_count['leave']; ?>], ['Attendance Not Maked', <?php echo $attendance_not_marked; ?>] ]); var options = { title: 'My Daily Activities' }; var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, options); </script> ``` This is my HTML page check this for reference. If you need further details I will add here. I don't how this error is coming. ``` <div id="accordion"> <h3><span class="accordion_header">Student Strength</span></h3> <div> <table> <tr> <td> <div id="chart_div" style="width: 500px; height: 300px;"></div> </td> <td style="vertical-align: top"> <table class="list"> <tr> <td style="width: 200px;"><b>Total student</b></td> <td style="width: 50px;" class="text-right"><?php echo $total_student_count; ?></td> </tr> <tr> <td class="attendance_color_present"><b>Present</b></td> <td class="text-right attendance_color_present"><?php echo $student_attendance_count['present']; ?></td> </tr> <tr> <td class="attendance_color_absent"><b>Absent</b></td> <td class="text-right attendance_color_absent"><?php echo $student_attendance_count['absent']; ?></td> </tr> <tr> <td class="attendance_color_leave"><b>Leave</b></td> <td class="text-right attendance_color_leave"><?php echo $student_attendance_count['leave']; ?></td> </tr> <tr> <td><b>Attendance Not Marked</b></td> <td class="text-right"><?php echo $attendance_not_marked = $total_student_count - ($student_attendance_count['present'] + $student_attendance_count['absent'] + $student_attendance_count['leave']); ?></td> </tr> </table> </td> </tr> </table> </div> <h3><span class="accordion_header">Attendance Details</span></h3> <div> <div class="data_listing" style="margin-left: auto"> <table class="list" align="center" style="margin: 0px auto; width: 70%"> <thead> <tr> <th style="width: 10%; text-align:center">Sr. No.</th> <th style="width: 60%">Class Name</th> <th style="width: 30%; text-align: center">Attendance Status</th> </tr> </thead> <?php $i = 1; $attendance_marked = 0; foreach ($class_section_attendance as $class) { if ($class['attendance_marked'] == 1) { $image = '<img src ="' . base_url() . 'resources/images/icons/tick_circle.png" title="Attendance Marked" alt="Attendance Marked"/>'; $attendance_marked++; } else { $image = '<img src ="' . base_url() . 'resources/images/icons/cross.png" title="Attendance Not Marked" alt="Attendance Not Marked"/>'; } echo '<tr>'; echo '<td style="text-align:center">' . $i++ . '</td>'; echo '<td>' . $class['name'] . '</td>'; echo '<td style="text-align:center">' . $image . '</td>'; echo '</tr>'; } $not_marked = count($class_section_attendance) - $attendance_marked; echo '<tr><td colspan="3" style="text-align:center">Total Classes : <b>' . count($class_section_attendance) . '</b> | Attendaced Marked : <b>' . $attendance_marked . '</b> | Not Marked : <b>' . $not_marked . '</b> </td></tr>'; ?> </table> </div> </div> </div> ``` Please help me.