12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Admin\Metrics\Examples;
- use Dcat\Admin\Admin;
- use Dcat\Admin\Widgets\Metrics\Donut;
- class NewDevices extends Donut
- {
- protected $labels = ['Desktop', 'Mobile'];
- /**
- * 初始化卡片内容
- */
- protected function init()
- {
- parent::init();
- $color = Admin::color();
- $colors = [$color->primary(), $color->alpha('blue2', 0.5)];
- $this->title('New Devices');
- //$this->subTitle('Last 30 days');
- $this->chartLabels($this->labels);
- // 设置图表颜色
- // $this->chartColors($colors);
- }
- /**
- * 渲染模板
- *
- * @return string
- */
- public function render()
- {
- $this->fill();
- return parent::render();
- }
- /**
- * 写入数据.
- *
- * @return void
- */
- public function fill()
- {
- $this->withContent(44.9, 28.6);
- // 图表数据
- //$this->withChart([44.9, 28.6]);
- }
- /**
- * 设置图表数据.
- *
- * @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($desktop, $mobile)
- {
- $blue = Admin::color()->alpha('blue2', 0.5);
- $style = 'margin-bottom: 8px';
- $labelWidth = 120;
- return $this->content(
- <<<HTML
- <div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
- <h2 class="ml-1 font-lg-1">1000</h2>
- </div>
- HTML
- );
- }
- }
|