Despite thinking I had resolved this issue earlier, it seems that I was mistaken. I have an array of objects that I successfully grouped using lodash. Subsequently, I attempted to create a summary table from it which should resemble the following:
https://i.sstatic.net/wFaYq.jpg
The desired format is simply grouping by 'program' and displaying a breakdown of each company within the 'program'.
Unfortunately, the company breakdown is not displaying correctly, unlike the example in the link above. I suspect that the issue lies with my buildSummary() method. This problem has been consuming me for the past couple of days, leaving me unable to think clearly.
Below is a snippet of my code:
new Vue({
el: "#app",
data: {
test:'hello',
myData: myData,
companiesSummary: {},
myObjData: ''
},
created: function(){
this.buildSummary();
},
methods: {
groupData: function(d){
return _.groupBy(d, "program");
},
buildSummary: function(){
this.myObjData = this.groupData(this.myData)
console.log(this.myObjData);
for (const company of Object.keys(this.myObjData)) {
this.companiesSummary[company] = {
totalCount: 0,
expectedFunding: 0,
fundedOnIKNS: 0,
};
for (const { TotalCount, expectedFunding, fundedOnIKNS } of this.myObjData[company]) {
this.companiesSummary[company].totalCount += 1;
this.companiesSummary[company].expectedFunding += expectedFunding === "Yes";
this.companiesSummary[company].fundedOnIKNS += fundedOnIKNS === "Yes";
}
}
console.log(this.companiesSummary)
}
}
})
I would greatly appreciate any assistance provided. Thank you!
Here's the link to the pen
Just to clarify, the TotalCount should indicate how many times a company appears within its respective group. Please disregard 'Total Count > 3'.