contentWidth(0, 12); // 标题 //$this->title('财务统计'); $this->chartHeight = 500; // 设置下拉选项 $this->dropdown([ '7' => '日', '30' => '月', '365' => '年', ]); // 设置图表颜色 $this->chartColors([ $color->green(), ]); } /** * 处理请求 * * @param Request $request * * @return mixed|void */ public function handle(Request $request) { switch ($request->get('option')) { case '7': default: // 图表数据 $this->withChart( [75, 125, 225, 175, 125, 75, 25] ); } } /** * 设置图表数据. * * @param array $data * * @return $this */ public function withChart(array $data) { return $this->chart([ 'series' => [[ 'name' => '金额', 'data' => $data ]], 'chart' => [ //'width' => '180%', 'type' => 'bar', 'events' => [ ], 'toolbar' => ['show' => false], ], 'colors' => $this->colors, 'plotOptions' => [ 'bar' => [ //'columnWidth' => '45%', 'distributed' => true, ] ], 'dataLabels' => [ 'enabled' => false ], 'legend' => [ 'show' => false ], 'xaxis' => [ 'categories' => [75, 125, 225, 175, 125, 75, 25] , 'labels' => [ 'show' => true, 'style' => [ 'colors' => $this->colors, 'fontSize' => '12px' ] ], ], 'yaxis' => [ 'show' => true ], 'tooltip' => [ 'x' => ['show' => true], ], ]); } }