Last active
May 30, 2017 13:37
-
-
Save christiannwamba/02f1833717154228925402dc8891fa5f to your computer and use it in GitHub Desktop.
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 client = deepstream('APP--URL') | |
// Login | |
client.login() | |
client.rpc.make( 'price-chart', { }, ( err, results ) => { | |
var dataPoints = results; | |
console.log(dataPoints) | |
var chart = new CanvasJS.Chart("chartContainer", { | |
title : { | |
text : "BTC Realtime Price" | |
}, | |
axisY: { | |
title: "Price in BTC", | |
titleFontColor: "rgb(0,75,141)", | |
minimum: 750, | |
maximum: 1700, | |
}, | |
data : [{ | |
type : "area", | |
color: "rgba(0,75,141,0.7)", | |
dataPoints : dataPoints | |
}] | |
}); | |
chart.render(); | |
var curPrice = client.record.getRecord('BTC/price'); | |
curPrice.subscribe('price', price => { | |
dataPoints.length > 300 && dataPoints.shift() | |
dataPoints.push({y: price}) | |
console.log(price) | |
chart.render() | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment