Title: Error while previewing statistics
Last modified: April 7, 2020

---

# Error while previewing statistics

 *  Resolved [Budiony Damyanov](https://wordpress.org/support/users/budiony/)
 * (@budiony)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/error-while-previewing-statistics/)
 * The browser console show the following error, I assume it is JavaScript error:
 * `admin.php?page=qmn_stats:358 Uncaught TypeError: (intermediate value).Line is
   not a function at window.onload (admin.php?page=qmn_stats:358) window.onload 
   @ admin.php?page=qmn_stats:358 load (async) (anonymous) @ admin.php?page=qmn_stats:
   356`
 * Consequently, the statistics page is blank.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [expresstechsupport](https://wordpress.org/support/users/expresstechsupport/)
 * (@expresstechsupport)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/error-while-previewing-statistics/#post-12642136)
 * Hi Budiony,
 * Please share the quizz’s URL with me so that I can look into the issue.
 * Regards,
    Kriti
 *  Thread Starter [Budiony Damyanov](https://wordpress.org/support/users/budiony/)
 * (@budiony)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/error-while-previewing-statistics/#post-12665261)
 * Hi, the problem is not with the quiz, but with the **Admin panel -> Statistics**,
   i.e. (admin.php?page=qmn_stats). Unfortunately I cannot share the internal credentials.
   The JavaScript error is (I assume you are using Chart.js library to display data?):
 *     ```
       window.onload = function(){
         var graph_ctx = document.getElementById("graph_canvas").getContext("2d");
         window.stats_graph = new Chart(graph_ctx).Line(graph_data, {
         responsive: true
         });
        }
       ```
   
 * So the error means that either the charting library **is not loaded** when you
   are trying to create a line graph, or the library was loaded, but **the syntax**
   of the command is different. As far as I can see from the source code at line
   120-142 in **stats-page.php**, the library is loaded **before** the request to
   create canvas, so it is the latter option.
    -  This reply was modified 6 years, 1 month ago by [Budiony Damyanov](https://wordpress.org/support/users/budiony/).
    -  This reply was modified 6 years, 1 month ago by [Budiony Damyanov](https://wordpress.org/support/users/budiony/).
    -  This reply was modified 6 years, 1 month ago by [Budiony Damyanov](https://wordpress.org/support/users/budiony/).
    -  This reply was modified 6 years, 1 month ago by [Budiony Damyanov](https://wordpress.org/support/users/budiony/).
    -  This reply was modified 6 years, 1 month ago by [Budiony Damyanov](https://wordpress.org/support/users/budiony/).
    -  This reply was modified 6 years, 1 month ago by [Budiony Damyanov](https://wordpress.org/support/users/budiony/).
    -  This reply was modified 6 years, 1 month ago by [Budiony Damyanov](https://wordpress.org/support/users/budiony/).
 *  Thread Starter [Budiony Damyanov](https://wordpress.org/support/users/budiony/)
 * (@budiony)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/error-while-previewing-statistics/#post-12665408)
 * The resolution of the problem is as follows (edit was made in file **stats-page.
   php **between lines 120-142):
 *     ```
       window.onload = function(){
          var graph_ctx = document.getElementById("graph_canvas").getContext("2d");
          var myLineChart = new Chart(graph_ctx, {
                       type: 'line',
                       data: {
                         labels : [<?php echo $labels; ?>],
                         datasets : [
                           {
                           label: "",
                           fillColor : "rgba(220,220,220,0.2)",
                           strokeColor : "rgba(220,220,220,1)",
                           pointColor : "rgba(220,220,220,1)",
                           pointStrokeColor : "#fff",
                           pointHighlightFill : "#fff",
                           pointHighlightStroke : "rgba(220,220,220,1)",
                           data : [<?php echo rtrim($value,","); ?>]
                           }						      ]                
                       },
                       options: {
                           title: {
                             display: true,
                             text: "<?php _e('Statistics', 'quiz-master-next'); ?>"
                           },
                       }
                   });
                 }
       ```
   
 * As you can see, the problem is that there is new syntax when creating line graph
   with Chart.js library.
 * The old code creates chart line with, which is no longer supported in 2.9.3 version
   of library:
    `new Chart(graph_ctx).Line(graph_data, { responsive: true });`

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Error while previewing statistics’ is closed to new replies.

 * ![](https://ps.w.org/quiz-master-next/assets/icon-128x128.png?rev=3158087)
 * [Quiz and Survey Master (QSM) - Easy Quiz and Survey Maker](https://wordpress.org/plugins/quiz-master-next/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/quiz-master-next/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/quiz-master-next/)
 * [Active Topics](https://wordpress.org/support/plugin/quiz-master-next/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/quiz-master-next/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/quiz-master-next/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Budiony Damyanov](https://wordpress.org/support/users/budiony/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/error-while-previewing-statistics/#post-12665408)
 * Status: resolved