Skip to content

Instantly share code, notes, and snippets.

@christiannwamba
Last active May 30, 2017 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christiannwamba/02f1833717154228925402dc8891fa5f to your computer and use it in GitHub Desktop.
Save christiannwamba/02f1833717154228925402dc8891fa5f to your computer and use it in GitHub Desktop.
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