4 changed files with 149 additions and 6 deletions
-
118app/Admin/Actions/Metrics/Market.php
-
4app/Admin/Actions/Metrics/Shipping.php
-
20app/Admin/Common/Order.php
-
13app/Admin/Controllers/v3/DataReport.php
@ -0,0 +1,118 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions\Metrics; |
|||
|
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Widgets\Metrics\Donut; |
|||
|
|||
class Market extends Donut |
|||
{ |
|||
protected $labels = ['东沟岭市场', '铜鼓岭市场', '华园菜市', '平西市场']; |
|||
protected $market; |
|||
|
|||
public function __construct($market) |
|||
{ |
|||
|
|||
$this->market = $market; |
|||
parent::__construct($title = null, $icon = null); |
|||
} |
|||
|
|||
public function init() |
|||
{ |
|||
parent::init(); // TODO: Change the autogenerated stub
|
|||
$color = Admin::color(); |
|||
$colors = [$color->primary(), $color->alpha('blue2', 0.5),$color->warning(),'rebeccapurple']; |
|||
//$this->title('<small>配送数据</small>');
|
|||
$this->height = 153; |
|||
$this->chartLabels($this->labels); |
|||
// 设置图表颜色
|
|||
$this->chartColors($colors); |
|||
} |
|||
|
|||
/** |
|||
* 渲染模板 |
|||
* |
|||
* @return string |
|||
*/ |
|||
public function render() |
|||
{ |
|||
$this->fill(); |
|||
return parent::render(); // TODO: Change the autogenerated stub
|
|||
} |
|||
|
|||
/** |
|||
* 写入数据. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function fill() |
|||
{ |
|||
$total = array_sum($this->market); |
|||
|
|||
// 图表数据
|
|||
|
|||
$this->withChart($this->market); |
|||
|
|||
$this->withContent($this->market[0], $this->market[1], $this->market[2], $this->market[3]); |
|||
} |
|||
|
|||
/** |
|||
* 设置图表数据. |
|||
* |
|||
* @param array $data |
|||
* |
|||
* @return $this |
|||
*/ |
|||
public function withChart(array $data) |
|||
{ |
|||
return $this->chart([ |
|||
'series' => $data |
|||
]); |
|||
} |
|||
|
|||
/** |
|||
* 设置卡片头部内容. |
|||
* |
|||
* @param mixed $desktop |
|||
* @param mixed $mobile |
|||
* |
|||
* @return $this |
|||
*/ |
|||
protected function withContent($s1, $s2, $s3, $s4) |
|||
{ |
|||
$blue = Admin::color()->alpha('blue2', 0.5); |
|||
|
|||
$style = 'margin-bottom: 8px'; |
|||
$labelWidth = 120; |
|||
|
|||
return $this->content( |
|||
<<<HTML |
|||
<div class="d-flex pl-1 pr-1 " style="{$style}"> |
|||
<div style="width: {$labelWidth}px"> |
|||
<i class="fa fa-circle text-primary"></i> {$this->labels[0]} |
|||
</div> |
|||
<div>{$s1}</div> |
|||
</div> |
|||
<div class="d-flex pl-1 pr-1" style="{$style}"> |
|||
<div style="width: {$labelWidth}px"> |
|||
<i class="fa fa-circle" style="color: $blue"></i> {$this->labels[1]} |
|||
</div> |
|||
<div>{$s2}</div> |
|||
</div> |
|||
|
|||
<div class="d-flex pl-1 pr-1 " style="{$style}"> |
|||
<div style="width: {$labelWidth}px"> |
|||
<i class="fa fa-circle text-warning"></i> {$this->labels[2]} |
|||
</div> |
|||
<div>{$s3}</div> |
|||
</div> |
|||
<div class="d-flex pl-1 pr-1" style="{$style}"> |
|||
<div style="width: {$labelWidth}px"> |
|||
<i class="fa fa-circle" style="color: rebeccapurple"></i> {$this->labels[3]} |
|||
</div> |
|||
<div>{$s4}</div> |
|||
</div> |
|||
HTML |
|||
); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue