У меня есть следующий массив объектов
[
{"questionText":"Are you working from home?","answerText":"Yes","answerCode":"A_0003_1","count":8},
{"questionText":"Are you working from home?","answerText":"No","answerCode":"A_0003_2","count":8},
{"questionText":"Are you working today?","answerText":"Yes, working from home","answerCode":"A_0002_1","count":21},
{"questionText":"Are you working today?","answerText":"Yes, working from office","answerCode":"A_0002_2","count":40},
{"questionText":"Are you working today?","answerText":"I am not working","answerCode":"A_0002_3","count":16},
{"questionText":"Why are you working in the office?","answerText":"My job requires it","answerCode":"A_0012_2","count":12},
{"questionText":"Why are you working in the office?","answerText":"My choice","answerCode":"A_0012_1","count":9},
{"questionText":"How are you feeling today?","answerText":"Neutral","answerCode":"A_0001_2","count":29},
{"questionText":"How are you feeling today?","answerText":"Good","answerCode":"A_0001_1","count":37},
{"questionText":"How are you feeling today?","answerText":"Not So Good","answerCode":"A_0001_3","count":21},
{"questionText":"How are you finding working from the office?","answerText":"Not So Good","answerCode":"A_0011_3","count":11},
{"questionText":"How are you finding working from the office?","answerText":"Good","answerCode":"A_0011_1","count":10},
{"questionText":"How are you finding working from the office?","answerText":"Neutral","answerCode":"A_0011_2","count":11},
{"questionText":"How are you finding working from home?","answerText":"Neutral","answerCode":"A_0004_2","count":3},
{"questionText":"How are you finding working from home?","answerText":"Not So Good","answerCode":"A_0004_3","count":5},
{"questionText":"How are you finding working from home?","answerText":"Good","answerCode":"A_0004_1","count":16}
]
Мне нужно преобразовать этот массив в следующую структуру, чтобы построить столбчатую диаграмму с накоплением с использованием API диаграмм Google
Ожидаемый результат
[
[
'Question(s)',
'Yes',
'No',
'Yes, working from home',
'Yes, working from office',
'I am not working',
'My job requires it',
'Neutral',
'Good',
'Not So Good',
{ role: 'annotation' }
],
['Are you working from home?', 8, 8, 0, 0, 0, 0, 0, 0, 0, ''],
['Are you working today?', 0, 0, 21, 40, 16, 0, 0, 0, 0, ''],
['Why are you working in the office?', 0, 0, 0, 0, 0, 12, 9, 0, 0, ''],
['How are you feeling today?', 0, 0, 0, 0, 0, 0, 29, 37, 21, ''],
['How are you finding working from the office?', 0, 0, 0, 0, 0, 0, 11,10,11,''],
['How are you finding working from home?', 0, 0, 0, 0, 0, 0, 3, 16, 5, '']
]
Я лучше всего пробовал свой уровень, используя различные циклы, массивы, наборы и т. Д. c. Но не удалось сгенерировать ожидаемый результат.