setUpOptions(); } /** * 初始化图表配置 */ protected function setUpOptions() { $color = Admin::color(); $colors = [$color->primary(), $color->primaryDarker()]; $this->options([ 'colors' => ['#008ffbd9', '#feb019', '#00e396'], 'chart' => [ 'type' => 'bar', "height"=>'315px', //高度 ], 'plotOptions' => [ 'bar' => [ 'horizontal' => false, 'columnWidth' => '80%', 'borderRadius' => 5, 'borderRadiusApplication' => 'end' ] ], 'stroke' => [ 'show' => false, 'width' => 3 ], 'xaxis' => [ 'type' => 'category', ], 'tooltip' => [ 'x' => [ 'formatter' => function ($val) { return $val; } ] ], ]); } /** * 设置图表数据 * @param array $data * @return $this */ public function withData(array $data) { return $this->option('series', $data); } /** * 设置图表类别. * @param array $data * @return $this */ public function withCategories(array $data) { return $this->option('xaxis.categories', $data); } /** * 渲染图表 * @return string */ public function render() { return parent::render(); } }