Im trying to figure out how to use highcharts with the dates. Im doing an API call and have in one variable clicks and in another variable the dates. I want to concatenate these 2 arrays but following the index.
For example
array1 = [timestamp1 , timestamp2, timestamp3]
array2 =[ clicks1, clicks2, clicks3 ]
I want to have then an array that is
data = 0: [timestamp1, click1],
1: [timestamp2, click2],
2: [timestamp3, click3]
I tried doing var data = array1.concat(array2);
but it concatenates in order
data = [timestamp1 , timestamp2, timestamp3 , clicks1, clicks2, clicks3 ]
my original code looks like this:
getChartData(){
axios.get("http://localhost:3003/desktop").then(api =>{
const data = api.data;
// console.log(data)
var date =[];
var clicks = []
var impressions =[]
for ( var i in data)
{
date.push(data[i].Date)
clicks.push(data[i].Clicks)
impressions.push(data[i].Impressions)
}
var cd = date.concat(clicks);
console.log(cd)
this.setState({
clicks:clicks,
date:date,
impressions:impressions,
cd: cd
})
});
}
This might be a very basic question, but I'm a beginner and could not find anything related.Any help would be appreciated.