market = $market; parent::__construct($title = null, $icon = null); } public function init() { parent::init(); // TODO: Change the autogenerated stub $color = Admin::color(); $colors = [$color->primary(), $color->alpha('blue2', 0.5),$color->warning(),'rebeccapurple']; //$this->title('配送数据'); $this->height = 153; $this->chartLabels($this->labels); // 设置图表颜色 $this->chartColors($colors); } /** * 渲染模板 * * @return string */ public function render() { $this->fill(); return parent::render(); // TODO: Change the autogenerated stub } /** * 写入数据. * * @return void */ public function fill() { $total = array_sum($this->market); // 图表数据 $this->withChart($this->market); $this->withContent($this->market[0], $this->market[1], $this->market[2], $this->market[3]); } /** * 设置图表数据. * * @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($s1, $s2, $s3, $s4) { $blue = Admin::color()->alpha('blue2', 0.5); $style = 'margin-bottom: 8px'; $labelWidth = 120; return $this->content( <<
{$this->labels[0]}
{$s1}
{$this->labels[1]}
{$s2}
{$this->labels[2]}
{$s3}
{$this->labels[3]}
{$s4}
HTML ); } }