Skip to content

Instantly share code, notes, and snippets.

@imclint21
Last active April 23, 2020 16:53
Show Gist options
  • Save imclint21/68e588c4de52172682f1db486f8996cd to your computer and use it in GitHub Desktop.
Save imclint21/68e588c4de52172682f1db486f8996cd to your computer and use it in GitHub Desktop.
Consume Lucid KV SSE with Chartist
var labelData = [];
var serieData = [];
var chart = new Chartist.Line('#ct-chart', { labels: labelData, series: [serieData] },
{
fullWidth: true,
chartPadding: { left: 0, right: 0 }
});
// Connect to the SSE (Public node on Heroku)
var eventSource = new EventSource("https://lucid-kv.herokuapp.com/notifications");
eventSource.addEventListener("rasp_poc_temp", function(e) {
labelData.push(new Date().toLocaleTimeString());
serieData.push(e.data);
chart.update();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment