Reputation:
I have been trying to plot graphics in real time with flotjs.The external data is coming from arduino.My problem is getting this error:uncaught typeerror undefined is not a function
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();
the error has occured this line:
var plot = $.plot("#placeholder", [ getData() ], {
...
what is the problem?
Upvotes: 1
Views: 762