|
|
|
@ -2,12 +2,15 @@ |
|
|
|
|
|
|
|
namespace App\Admin\Metrics\Examples; |
|
|
|
|
|
|
|
use App\Models\Agent; |
|
|
|
use App\Models\Guide; |
|
|
|
use App\Models\Supplier; |
|
|
|
use Dcat\Admin\Admin; |
|
|
|
use Dcat\Admin\Widgets\Metrics\Donut; |
|
|
|
|
|
|
|
class NewDevices extends Donut |
|
|
|
{ |
|
|
|
protected $labels = ['Desktop', 'Mobile']; |
|
|
|
protected $labels = ['代理商', '供应商', '地接']; |
|
|
|
|
|
|
|
/** |
|
|
|
* 初始化卡片内容 |
|
|
|
@ -17,10 +20,9 @@ class NewDevices extends Donut |
|
|
|
parent::init(); |
|
|
|
|
|
|
|
$color = Admin::color(); |
|
|
|
$colors = [$color->primary(), $color->alpha('blue2', 0.5)]; |
|
|
|
$colors = [$color->primary(), $color->alpha('blue2', 0.5),Admin::color()->yellow()]; |
|
|
|
|
|
|
|
$this->title('New Devices'); |
|
|
|
$this->subTitle('Last 30 days'); |
|
|
|
$this->title('入驻比例');; |
|
|
|
$this->chartLabels($this->labels); |
|
|
|
// 设置图表颜色
|
|
|
|
$this->chartColors($colors); |
|
|
|
@ -45,10 +47,13 @@ class NewDevices extends Donut |
|
|
|
*/ |
|
|
|
public function fill() |
|
|
|
{ |
|
|
|
$this->withContent(44.9, 28.6); |
|
|
|
$agent = Agent::query()->count(); |
|
|
|
$supplier = Supplier::query()->count(); |
|
|
|
$guide = Guide::query()->count(); |
|
|
|
$this->withContent($agent, $supplier, $guide); |
|
|
|
|
|
|
|
// 图表数据
|
|
|
|
$this->withChart([44.9, 28.6]); |
|
|
|
$this->withChart([$agent, $supplier, $guide]); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -73,10 +78,10 @@ class NewDevices extends Donut |
|
|
|
* |
|
|
|
* @return $this |
|
|
|
*/ |
|
|
|
protected function withContent($desktop, $mobile) |
|
|
|
protected function withContent($desktop, $mobile, $unkonw) |
|
|
|
{ |
|
|
|
$blue = Admin::color()->alpha('blue2', 0.5); |
|
|
|
|
|
|
|
$yellow = Admin::color()->yellow(); |
|
|
|
$style = 'margin-bottom: 8px'; |
|
|
|
$labelWidth = 120; |
|
|
|
|
|
|
|
@ -94,6 +99,12 @@ class NewDevices extends Donut |
|
|
|
</div> |
|
|
|
<div>{$mobile}</div> |
|
|
|
</div> |
|
|
|
<div class="d-flex pl-1 pr-1" style="{$style}"> |
|
|
|
<div style="width: {$labelWidth}px"> |
|
|
|
<i class="fa fa-circle" style="color: $yellow"></i> {$this->labels[2]} |
|
|
|
</div> |
|
|
|
<div>{$unkonw}</div> |
|
|
|
</div> |
|
|
|
HTML |
|
|
|
); |
|
|
|
} |
|
|
|
|