Javascript 图表JS错误:未捕获类型错误:无法读取属性';顶部';未定义的
这是我第一次使用JS,需要使用jQuery和Chart JS来绘制时间序列,但我一直遇到以下错误:Javascript 图表JS错误:未捕获类型错误:无法读取属性';顶部';未定义的,javascript,jquery,chart.js,Javascript,Jquery,Chart.js,这是我第一次使用JS,需要使用jQuery和Chart JS来绘制时间序列,但我一直遇到以下错误: Uncaught TypeError: Cannot read property 'top' of undefined at callFllSamplesApi (plot.js:105) 代码块: //包含在body标记之前的脚本(Chart.js 2.4、jQuery 3.4、本地文件plot.js和callFllSamplesApi()) 生成FLL图 函数callFLLSamp
Uncaught TypeError: Cannot read property 'top' of undefined
at callFllSamplesApi (plot.js:105)
代码块:
//包含在body标记之前的脚本(Chart.js 2.4、jQuery 3.4、本地文件plot.js和callFllSamplesApi())
生成FLL图
函数callFLLSamplesApi如下所示,其中有一行抛出错误
function callFllSamplesApi() {
var request = new XMLHttpRequest()
request.open('GET', 'http://193.142.33.4/api/samples', true)
request.onload = function(){
... Parsing code
}
request.send()
var ctx = document.getElementById("line-chart");
var myChart = new Chart(ctx, { <- Line 105 which throws an error
... More code for plotting
}
}
});
}
函数调用fllsamplesapi(){
var请求=新的XMLHttpRequest()
request.open('GET','http://193.142.33.4/api/samples",对)
request.onload=函数(){
…解析代码
}
请求发送()
var ctx=document.getElementById(“折线图”);
var myChart=new Chart(ctx,{您的折线图元素缺少getContext()
var ctx = document.getElementById("line-chart").getContext('2d');
您的折线图元素缺少getContext()
var ctx = document.getElementById("line-chart").getContext('2d');