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()
})
});