| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace UCore\DcatAdmin\Metrics\Sys;
- use App\Module\Statistics\Base;
- use Dcat\Admin\Widgets\Metrics\Line;
- use Illuminate\Http\Request;
- /**
- * 队列运行情况
- * apex-charts
- */
- class JobDuiChart extends Line
- {
- /**
- * 初始化卡片内容
- *
- * @return void
- */
- protected function init()
- {
- parent::init();
- $this->title('任务堆积');
- $this->height(330);
- $this->chartHeight(320);
- }
- /**
- * 处理请求
- *
- * @param Request $request
- *
- * @return mixed|void
- */
- public function handle(Request $request)
- {
- $list = Base::getList('job', 'wait',20);
- $datas =[];
- $xd = [];
- foreach ($list as $value){
- array_unshift($datas, $value->number);
- array_unshift($xd, $value->pvar);
- }
- // 图表数据
- $this->withChart($datas,$xd);
- }
- /**
- * 设置图表数据.
- *
- * @param array $data
- *
- * @return $this
- */
- public function withChart(array $data, array $categories)
- {
- $this->chart([
- 'chart' => [
- 'type' => 'area',
- 'toolbar' => [
- 'show' => false,
- ],
- ],
- 'series' => [
- [
- 'name' => $this->title,
- 'data' => $data,
- ],
- ],
- 'dataLabels' => [
- 'enabled' => true
- ],
- 'xaxis' => [
- 'type' => 'number',
- 'categories' => $categories,
- 'labels' => [
- 'show' => true,
- ],
- 'axisBorder' => [
- 'show' => true,
- ],
- ],
- 'tooltip' => [
- 'x' => [
- 'show' => true
- ]
- ],
- ]);
- }
- }
|