I need to transform data from first format to second for my ui library. But I can't completely understand how I should do this. I need to add arrays "data" each id
My data:
[
{id: 'Battery charging', time: '2021-0903T14:10:00Z', value: 3890.019022727273, table: 0}
{id: 'Battery charging', time: '2021-09-03T14:15:00Z', value: 3594.3097145454544, table: 0}
{id: 'Battery charging', time: '2021-09-03T14:20:00Z', value: 4069.6454163636363, table: 0}
{id: 'Battery charging', time: '2021-09-03T14:25:00Z', value: 4090.7089309090907, table: 0}
{id: 'Battery charging', time: '2021-09-03T14:30:00Z', value: 3530.3841, table: 0}
{id: 'Battery charging', time: '2021-09-03T14:35:00Z', value: 4154.7032509090905, table: 0}
{id: 'Battery charging', time: '2021-09-03T14:40:00Z', value: 4752.12578, table: 0}
{id: 'Battery charging', time: '2021-09-03T14:45:00Z', value: 5906.133650000001, table: 0}
{id: 'Battery charging', time: '2021-09-03T14:50:00Z', value: 4148.342200000001, table: 0}
{id: 'Battery discharging', time: '2021-09-03T14:10:00Z', value: 0, table: 1}
{id: 'Battery discharging', time: '2021-09-03T14:15:00Z', value: 0, table: 1}
{id: 'Battery discharging', time: '2021-09-03T14:20:00Z', value: 0, table: 1}
{id: 'Battery discharging', time: '2021-09-03T14:25:00Z', value: 0, table: 1}
{id: 'Battery discharging', time: '2021-09-03T14:30:00Z', value: 0, table: 1}
{id: 'Battery discharging', time: '2021-09-03T14:35:00Z', value: 0, table: 1}
{id: 'Battery discharging', time: '2021-09-03T14:40:00Z', value: 0, table: 1}
{id: 'Battery discharging', time: '2021-09-03T14:45:00Z', value: 0, table: 1}
{id: 'Battery discharging', time: '2021-09-03T14:50:00Z', value: 45.93099, table: 1}
]
Need to transform to this:
[
{id: 'Battery charging',
data: [
{time: '2021-09-03T14:10:00Z', value: 3890.019022727273}
{time: '2021-09-03T14:15:00Z', value: 3594.3097145454544}
{time: '2021-09-03T14:20:00Z', value: 4069.6454163636363}
{time: '2021-09-03T14:25:00Z', value: 4090.7089309090907}
{time: '2021-09-03T14:30:00Z', value: 3530.3841}
{time: '2021-09-03T14:35:00Z', value: 4154.7032509090905}
{time: '2021-09-03T14:40:00Z', value: 4752.12578}
{time: '2021-09-03T14:45:00Z', value: 5906.133650000001}
{time: '2021-09-03T14:50:00Z', value: 4148.342200000001}
]
{id: 'Battery discharging',
data: [
{time: '2021-09-03T14:10:00Z', value: 0}
{
time: '2021-09-03T14:15:00Z', value: 0}
{
time: '2021-09-03T14:20:00Z', value: 0}
{time: '2021-09-03T14:25:00Z', value: 0}
{time: '2021-09-03T14:30:00Z', value: 0}
{
time: '2021-09-03T14:35:00Z', value: 0}
{
time: '2021-09-03T14:40:00Z', value: 0}
{
time: '2021-09-03T14:45:00Z', value: 0}
{time: '2021-09-03T14:50:00Z', value: 45.93099}
]
]