option = $this->id = 7; $this->data = $data; parent::__construct(); } protected function init() { parent::init(); // 设置标题 $this->title('销售总数量'); // 设置下拉菜单 // $this->dropdown([]); } /** * 处理请求 * 如果你的图表类中包含此方法,则可以通过此方法处理前端通过ajax提交的获取图表数据的请求 * * @param Request $request * @return mixed|void */ public function handle(Request $request) { // dd($request); // 数据查询逻辑 $data = ['total' => $this->data['total'] ?? 0 ]; $this->withData($data); } /** * 这里返回需要异步传递到 handler 方法的参数 * * @return array */ public function parameters(): array { return [ 'id' => $this->id, 'option' => $this->option, ]; } public function withData($data) { $this->data = $data; } /** * 渲染卡片内容. * * @return string */ public function renderContent() { $total = $this->data['total'] ?? 0 ; return <<

{$total}

HTML; } }