neighbourhoodie / voice-of-interconnect

Offline First demo app for IBM InterConnect 2017
https://voiceofinterconnect.com/
Apache License 2.0
9 stars 1 forks source link

Add sentiment quantity + hour in sentiment object for streaming to chart #50

Closed kidfribble closed 7 years ago

kidfribble commented 7 years ago

In this function, which is aiming to stream new data to the chart, could you provide a sentiment.number (or however you'd prefer it titled) that can provide me with the quantity of sentiments being received? It would also be awesome if sentiment.at simply returned an hour (1–24 or 0–23) that I can easily map to the corresponding shape.

To stream data to the chart, it should be much easier if I can snag all of this from the sentiment object, whereas right now I'm creating three separate variables for time, number, and sentiment values to draw it. Getting this in the object will require some updates to my d3 code, but it'll be worth it!

From on-new-sentiment.js

function generateSentiment (handler) {
  setTimeout(() => {
    handler({
      score: Math.random() * 2 - 1,
      at: new Date()
    })
    generateSentiment(handler)
  }, Math.random() * 5000 + 2000)
}