Last active
April 23, 2020 16:53
-
-
Save imclint21/68e588c4de52172682f1db486f8996cd to your computer and use it in GitHub Desktop.
Consume Lucid KV SSE with Chartist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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