Home  >  Q&A  >  body text

javascript - chart.js (intermediate value).Line is not a function(…)

$(function(){

var ctx = $("#chatbox").get(0).getContext("2d");
window.myNewChart = new Chart(ctx).Line(data);;
new Chart(ctx).Line(data);
var data = {
     labels : ["January","February","March","April","May","June","July"],
     datasets : [
         {
             fillColor : "rgba(220,220,220,0.5)",
             strokeColor : "rgba(220,220,220,1)",
             pointColor : "rgba(220,220,220,1)",
             pointStrokeColor : "#fff",
             data : [65,59,90,81,56,55,40]
         },
         {
             fillColor : "rgba(151,187,205,0.5)",
             strokeColor : "rgba(151,187,205,1)",
             pointColor : "rgba(151,187,205,1)",
             pointStrokeColor : "#fff",
             data : [28,48,40,19,96,27,100]
         }
     ]

}
});

新手求助...刚学这个..为什么会出现 (intermediate value).Line is not a function(…)
引入的文件是Chart.js

PHPzPHPz2640 days ago585

reply all(1)I'll reply

  • 阿神

    阿神2017-04-11 10:31:15

    var ctx = document.getElementById("myChart").getContext("2d");
            var myChart = new Chart(ctx, {
                type: 'line',
                data: {
                     labels : ["January","February","March","April","May","June","July"],
                     datasets : [
                         {
                             fillColor : "rgba(220,220,220,0.5)",
                             strokeColor : "rgba(220,220,220,1)",
                             pointColor : "rgba(220,220,220,1)",
                             pointStrokeColor : "#fff",
                             data : [65,59,90,81,56,55,40]
                         },
                         {
                             fillColor : "rgba(151,187,205,0.5)",
                             strokeColor : "rgba(151,187,205,1)",
                             pointColor : "rgba(151,187,205,1)",
                             pointStrokeColor : "#fff",
                             data : [28,48,40,19,96,27,100]
                         }
                     ]
                },
                options: {
                    scales: {
                        yAxes: [{
                            ticks: {
                                beginAtZero:true
                            }
                        }]
                    }
                }
            });

    reply
    0
  • Cancelreply