I am trying to create a bar chart for the roles by their count using dc.js and crossfilter. Need to deal with nested JSON.
Sample data set
[ { "user":"Mani"
"age":55,
"area":"NORTH",
"role": [
{
"roleId": 15,
"role": "Operator",
"at": "2018-10-30T07:53:10.433Z",
"createdAt": "2018-10-30T07:53:10.449Z"
},
{
"statusId": 16,
"status": "Supervisor",
"at": "2018-10-30T07:53:18.359Z",
"createdAt": "2018-10-30T07:53:18.359Z"
},
{
"statusId": 26,
"status": "Manager",
"at": "2018-10-30T13:01:50.296Z",
"createdAt": "2018-10-30T13:01:50.296Z"
}
]
}, {
"user":"Kandan"
"age":65,
"area":"SOUTH",
"role": [
{
"roleId": 15,
"role": "Operator",
"at": "2018-10-30T07:53:10.433Z",
"createdAt": "2018-10-30T07:53:10.449Z"
},
{
"statusId": 16,
"status": "Supervisor",
"at": "2018-10-30T07:53:18.359Z",
"createdAt": "2018-10-30T07:53:18.359Z"
}
]
}
]
I tried creating a chart by using values from the root level of each user but when I tried accessing the role
key I am somehow able to use only one role not all the roles on other hand it returns the array to the dimension. The basic idea is to have role.role under x-axis and their count on the y-axis. How do I achieve this?
Sample output