Olá pessoal preciso construir um arrayarray
da seguinte forma para um plugin
var data = [{ "label": "Follows", "color": "#aad874", "data": [ ["Seg", 50], ["Ter", 84], ["Qua", 52], ["Qui", 88], ["Sex", 69], ["Sab", 92], ["Dom", 58] ] }, { "label": "UnFollows", "color": "#7dc7df", "data": [ ["Seg", 13], ["Ter", 44], ["Qua", 44], ["Qui", 27], ["Sex", 38], ["Sab", 11], ["Dom", 39] ] }];
já tentei varias coisas como:
$staticWeeks = self::statisticstaWeeks();
var data = [{
$staticsDays['Follow'] "label": "Follows",
="color": [];"#aad874",
$staticsDays['FollowBy']"data": [
= []; ["Seg", 50],
["Ter", 84],
if(count($staticWeeks) > 0): ["Qua", 52],
foreach($staticWeeks["Qui", as88],
$weeks) ["Sex", 69],
["Sab", 92],
["Dom", 58]
]
}, {
"label": "UnFollows",
"color": "#7dc7df",
"data": [
array_push($staticsDays['Follow'] ["Seg", $weeks->ins_sta_follow);13],
["Ter", 44],
array_push($staticsDays['FollowBy'] ["Qua", $weeks->ins_sta_following);44],
endforeach;["Qui", 27],
endif; ["Sex", 38],
["Sab", 11],
["Dom", 39]
]
}];
Já tentei varias coisas como:
$staticWeeks = self::statisticstaWeeks();
$staticsDays['Follow'] = $diasFollow[];
$staticsDays['FollowBy'] = [[];
if(count($staticWeeks) > 0):
foreach($staticWeeks as $weeks):
array_push($staticsDays['Follow'], $weeks->ins_sta_follow);
array_push($staticsDays['FollowBy'], $weeks->ins_sta_following);
endforeach;
endif;
$staticsDays['Follow'] = $diasFollow = [
"Seg" => (!empty($staticsDays['Follow'][0]) ? $staticsDays['Follow'][0] : 0),
"Ter" => (!empty($staticsDays['Follow'][1]) ? $staticsDays['Follow'][1] : 0),
"Qua" => (!empty($staticsDays['Follow'][2]) ? $staticsDays['Follow'][2] : 0),
"Qui" => (!empty($staticsDays['Follow'][3]) ? $staticsDays['Follow'][3] : 0),
"Sex" => (!empty($staticsDays['Follow'][4]) ? $staticsDays['Follow'][4] : 0),
"Sab" => (!empty($staticsDays['Follow'][5]) ? $staticsDays['Follow'][5] : 0),
"Dom" => (!empty($staticsDays['Follow'][6]) ? $staticsDays['Follow'][6] : 0)];
$staticsDays['FollowBy'] = $diasFollowBy = [
"Seg" => (!empty($staticsDays['FollowBy'][0]) ? $staticsDays['FollowBy'][0] : 0),
"Ter" => (!empty($staticsDays['FollowBy'][1]) ? $staticsDays['FollowBy'][1] : 0),
"Qua" => (!empty($staticsDays['FollowBy'][2]) ? $staticsDays['FollowBy'][2] : 0),
"Qui" => (!empty($staticsDays['FollowBy'][3]) ? $staticsDays['FollowBy'][3] : 0),
"Sex" => (!empty($staticsDays['FollowBy'][4]) ? $staticsDays['FollowBy'][4] : 0),
"Sab" => (!empty($staticsDays['FollowBy'][5]) ? $staticsDays['FollowBy'][5] : 0),
"Dom" => (!empty($staticsDays['FollowBy'][6]) ? $staticsDays['FollowBy'][6] : 0)];
$follow = [(object)[
"label" => "Seguindo",
"color" => "#aad874",
"data" => $staticsDays['Follow']
]];
$followBy = [(object)[
"label" => "Seguidores",
"color" => "#7dc7df",
"data" => $staticsDays['FollowBy']
]];
$result = array_merge($follow, $followBy);
return json_encode( $result );
E mesmo assim não retorna como eu quero.