[Vuejs]-VueJS โ€“ Push data into array in V-Bind

0๐Ÿ‘

โœ…

Will something like the following suit your requirements:

var socket = io.connect();
socket.on('stream', function(sensorData) {
    app.devices = sensorData.deviceList;
});

var app = new Vue({
    el: "#app",
    data: {
        devices: {},
        chartData: {}
    },
    watch: {
        devices (newValue) {
            let chartData = this.chartData
            for(device in newValue) {
                let deviceValue = newValue[device]
                if(!chartData[device])
                    chartData[device] = []
                chartData[device].push([deviceValue.timestamp, parseInt(deviceValue.lux)])
            }
        }
    }
});

With v-for="device in chartData" ?

Leave a comment