In a JSON file, there is an object called "lineChart" with multiple keys and values. Each value contains various other objects. Here's an example:
"lineChart": {
"Fri Jul 28, 2017": {
"renewalFee_EUR": 1165,
"extensionFee_EUR": 0,
"renewalFee_USD": 5941.5,
"extensionFee_USD": 0,
"processingFee_USD": 25,
"expressFee_USD": 0,
"urgentFee_USD": 0,
"latePayPenalty_USD": 0,
"fxRate": 5.1,
"subTotal_USD": 5966.5
},
"Tue Aug 1, 2017": {
"renewalFee_EUR": 1165,
"extensionFee_EUR": 0,
"renewalFee_USD": 2411.55,
"extensionFee_USD": 0,
"processingFee_USD": 25,
"expressFee_USD": 0,
"urgentFee_USD": 0,
"latePayPenalty_USD": 0,
"fxRate": 2.07,
"subTotal_USD": 2436.55
}
}
I have managed to extract the key values like Fri Jul 28, 2017
and store them in an Array for chart data representation.
var caLine = vm.graph.lineChart;
lineLabelArr = [];
for (var prop in caLine) {
if (caLine.hasOwnProperty(prop)) {
lineLabelArr.push(prop)
}
}
vm.labels = lineLabelArr;
Now, I want to specifically access the data under the subTotal_USD
key in the JSON file and display it on my chart.
Question
How can I iterate through each property in the lineChart
object, retrieve the values from the subTotal_USD
key, and save them in an Array for chart data usage? I feel like I might be overcomplicating things.