Javascript uncaught typeerror undefined不是函数flotjs
我一直在尝试使用实时绘图。外部数据来自arduino。我的问题是出现以下错误:未捕获类型错误未定义不是函数Javascript uncaught typeerror undefined不是函数flotjs,javascript,plot,flot,typeerror,Javascript,Plot,Flot,Typeerror,我一直在尝试使用实时绘图。外部数据来自arduino。我的问题是出现以下错误:未捕获类型错误未定义不是函数 var socket = io.connect('http://localhost:8000'); socket.on('pulse', function(data){ var datas = [], totalPoints = 300; function getData() {
var socket = io.connect('http://localhost:8000');
socket.on('pulse', function(data){
var datas = [],
totalPoints = 300;
function getData() {
if (datas.length > 0)
datas = datas.slice(1);
// Do a random walk
while (datas.length < totalPoints) {
datas.push(data);
}
// Zip the generated y values with the x values
var res = [];
for (var i = 0; i < datas.length; ++i) {
res.push([i, datas[i]]);
}
return res;
}
var plot = $.plot("#placeholder", [ getData() ], {
series: {
shadowSize: 0 // Drawing is faster without shadows
},
yaxis: {
min: 0,
max: 100
},
xaxis: {
show: false
}
});
function update() {
plot.setData([getData()]);
// Since the axes don't change, we don't need to call plot.setupGrid()
plot.draw();
setTimeout(update, updateInterval);
}
update();
var socket=io.connect('http://localhost:8000');
socket.on('pulse',函数(数据){
var数据=[],
总积分=300;
函数getData(){
如果(datas.length>0)
数据=数据片(1);
//散散步
while(datas.length
此行出现错误:var plot=$.plot(#占位符“,[getData()],{
问题是什么?我解决了。它不只是提供静态文件。发布最终解决方案;)