2

So, I have this rickshaw line chart set up on my html script:

var data = [];

var graph = new Rickshaw.Graph( {
    element: document.querySelector("#chart"), 
    width: 1000, 
    height: 100, 
    renderer: 'line',
    series: [{
        color: 'red',
        data: data
    }]
});

graph.render();

And on my node server I have data, structured as an object with x and y properties, streaming in from a mobile phone through a socket:

var rawData = io
.of('/swift')
.on('connection', function (socket) {
  console.log('new connection');
  socket.on('message', function (data, fn) {
    fn('woot');
    console.log(data);
  });
  socket.emit('node.js', {
    "hello": "from node"
  });
});

But what I am unsure about is, how do I populate my data array (in the html) with the incoming data objects?

david
  • 39
  • 3

1 Answers1

1

I found that the problem was very simple. The reason the data wasn't coming through was because, I just needed to use io.sockets.emit instead of socket.emit, so that the socket event could be heard by more than just the original socket connection.

david
  • 39
  • 3