I have an array that is used to track status of certain documents. This looks like the following when outputted from a Mongo Aggregate function. k is the status, and v is the count of documents with this status.
[
{
"legal": [
{ "k": "", "v": 6 },
{ "v": 3},
{ "k": "To be uploaded", "v": 5 },
{ "k": "To be reviewed", "v": 96 }
],
"operations": [
{ "v": 1 },
{ "k": "To be uploaded", "v": 3 },
{ "k": "To be reviewed", "v": 24 }
],
"accounting": [
{ "k": "To be reviewed", "v": 137 },
{ "k": "", "v": 3 },
{ "v": 2 },
{ "k": "To be uploaded", "v": 24 },
{ "k": "Not Required", "v": 1 }
]
}
]
I want to graph these on a stacked bar chart, and require the following format. The data array is in the order ["legal", "operations", "accounting"]
[
{
name: "", // no status specified
data: [9, 1, 5]
},
{
name: "To be uploaded",
data: [5, 3, 24]
},
{
name: "To be reviewed",
data: [96, 24, 137]
},
{
name: "Not Required",
data: [0, 0, 1]
},
]