I have a function that is constantly checking for temperature data:
{"a":"43",
"b":"43",
"c":"42",
"d":"43",
"e":"40",
"f":"41",
"g":"100",
"h":"42.6"}
My goal is to graph this data over time, but I'm struggling with how to structure it to fit the format I need:
temps: [{
name: "a",
data: ["43","42","43"]
},
name: "b",
data: ["43","42","43"]
},
etc...
]
I attempted the code below and tried using the JavaScript map function, but I encountered issues with scoping where "this" was not referencing the same object as in the parent:
this.temp_names.forEach(function(e){
if(typeof this.temps[e] == "undefined") {
this.temps[e] = []
}
this.temps.e.unshift(this.sys_telemetry.S.temps)
if (this.temps.e.length > 10) {
this.temps.e.pop()
}
})
The "temp_names" array contained all the keys needed for mapping.
I am working on this within VueJS, where "this" corresponds to the data in my component.