دنبال کننده ها

۱۳۹۶ دی ۱۲, سه‌شنبه

php - how to get 30 days chart of campaign in laravel using echarts

[ad_1]



i am using to get 24 hr open rate and its working.




public function chart24h(Request $request)

$campaign = stayintouchModelCampaign::findByUid($request->uid);

// authorize
if (Gate::denies('read', $campaign))
return $this->notAuthorized();


$result = [
'columns' => [],
'data' => [],
'bar_names' => [trans('messages.opened'), trans('messages.clicked')],
];

$hours = [];

// columns
for ($i = 23; $i >= 0; --$i)
$result['columns'][] = stayintouchLibraryTool::dateTime(CarbonCarbon::now())->subHours($i)->format('h:A');
$hours[] = stayintouchLibraryTool::dateTime(CarbonCarbon::now())->subHours($i)->format('H');


// 24h collection
$openData24h = $campaign->openUniqHours(stayintouchLibraryTool::dateTime(CarbonCarbon::now())->subHours(24), CarbonCarbon::now());
$clickData24h = $campaign->clickHours(stayintouchLibraryTool::dateTime(CarbonCarbon::now())->subHours(24), CarbonCarbon::now());

// datas
foreach ($result['bar_names'] as $key => $bar)
$data = [];
if ($key == 0)
foreach ($hours as $ohour)
$num = isset($openData24h[$ohour]) ? count($openData24h[$ohour]) : 0;
$data[] = $num;

else
foreach ($hours as $chour)
$num = isset($clickData24h[$chour]) ? count($clickData24h[$chour]) : 0;
$data[] = $num;



$result['data'][] = [
'name' => $bar,
'type' => 'line',
'smooth' => true,
'data' => $data,
'itemStyle' => [
'normal' => [
'areaStyle' => [
'type' => 'default',
],
],
],
];


return json_encode($result);





but i want for 30days .
how can i do it . to difficult for me.




[ad_2]

لینک منبع