Here is the response I received from my API:
let data = [
{
date: '2021-04-27',
formatted_date: 'Apr 27',
location: [
{
date: '2021-04-27',
formatted_date: 'Apr 27',
country: 'India',
total_views: 6,
formatted_views: '6',
total_watch_duration: 115,
formatted_watch_duration: '0h 1m',
},
{
date: '2021-04-27',
formatted_date: 'Apr 27',
country: 'USA',
total_views: 16,
formatted_views: '16',
total_watch_duration: 1195,
formatted_watch_duration: '0h 1m',
},
{
date: '2021-04-27',
formatted_date: 'Apr 27',
country: 'Canada',
total_views: 16,
formatted_views: '10',
total_watch_duration: 1195,
formatted_watch_duration: '0h 1m',
},
],
},
// More data for different dates and locations
];
I would like the information to be structured in the following format with the assumption that if the location is empty, consider the total_views as 0:
this.geographySeriesData = [
{
name: 'India',
data: [500, 555, 444, 777, 877, 9944, 750],
},
{
name: 'USA',
data: [10, 1000, 1200, 1000, 1200, 1000, 500],
}
];