首页 > 解决方案 > 如何根据主题或 email_id 创建条形图 highchart?

问题描述

我想使用 highchart 制作电子邮件发送报告。这是我已经创建的图表。

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

报告.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
     ]
]);

电子邮件控制器.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 
                 ]);
}

这是数据库

谢谢 :)

标签: phpmysqlhighchartsyii2chart.js

解决方案


推荐阅读