I am working on a web app which will display some time series data in a graph using ember-cli-chart (ChartJS wrapper). I am using socket.io to send current data to the web app to be displayed.
socket.on('timeSeriesData', function(data){
chart1.set('outdoorTemp', data); //Sets data on signal from socket.io
});
var chart1 = Ember.Object.create({
outdoorTemp: null, //This variable is successfully set on the signal above
data: {
labels: [], //Don't need labels for now
datasets: [
{
label: "Energy Consumption in KW/H",
fillColor: "rgba(219, 66, 0, .25)",
strokeColor: "rgba(209, 0, 0, 1)",
pointColor: "rgba(209, 0, 0, 1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(209, 0, 0, 1)",
data: Ember.computed.alias('outdoorTemp') //This value does not get set to outdoorTemp
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scaleFontColor: '#fff',
scaleShowGridLines: false,
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: 'probability'
}
}]
}
}});
My goal for this was that the graph should be updated in real time every time new data is received from socket.io. I am attempting to bind the data property to the outdoorTemp property within the chart1 object, however this data binding does not seem to work. I've read through the documentation on this matter and it looks like what I am doing should work but it does not. Would there be a more elegant solution to this problem?
Aucun commentaire:
Enregistrer un commentaire