如何基于主题或email_id创建条形图highchart?

时间:2018-08-07 05:10:42

标签: php mysql highcharts yii2 chart.js

我想使用highchart使电子邮件发送报告。 This is the chart that i've already create.

18,19,20 ...是email_id。因此,该图表显示了所有电子邮件报告。但我想显示每个email_id的图表。

report.php

<?php

use dosamigos\highcharts\HighCharts;
use backend\models\Email;

$this->title = 'Megablast Statistics';

foreach($dreport as $values) { 
    $a[0]= ($values['email_id']);
    $c[]= ($values['email_id']); 
    $b[]= array('type'=> 'column', 'name' =>$values['email_id'], 'data' => array((int)$values['number_of_recipient'], 
(int)$values['number_of_delivery'],(int)$values['number_of_open'], (int)$values['number_of_click'], (int)$values['number_of_complain'], (int)$values['number_of_bounces']) ); 
}

echo

Highcharts::widget([
    'clientOptions' => [
         'chart'=>[
               'type'=>'pie'
         ],
         'title' => ['text' => 'Megablast Statistics'],
         'xAxis' => [
               'categories' => ['number_of_recipient', 'number_of_delivery', 'number_of_open', 'number_of_click', 'number_of_complain', 'number_of_bounces']
         ],
         'yAxis' => [
               'title' => ['subject' => '']
         ],
         'series' => $b
     ]
]);

EmailController.php

public function actionReport()
{

    $data = Yii::$app->db->createCommand('select email_id,
                 number_of_recipient,
                 number_of_delivery,
                 number_of_open,
                 number_of_click,
                 number_of_complain,
                 number_of_bounces
                 from email

                 group by email_id')->queryAll();
                 //print_r($data);
                 return $this->render('report', [
                     'dreport' => $data 
                 ]);
}

This is the database

谢谢:)

0 个答案:

没有答案