<?php
 namespace ModStart\Widget\Chart; use ModStart\Core\Util\RandomUtil; use ModStart\Widget\AbstractWidget; class Line extends AbstractWidget { protected $view = 'modstart::widget.chart'; protected $height = 300; protected $option = [ "grid" => [ "top" => "5%", "right" => "1%", "left" => "1%", "bottom" => "10%", "containLabel" => true ], "tooltip" => [ "trigger" => "axis" ], "xAxis" => [ "type" => "category", "data" => [] ], "yAxis" => [ "type" => "value", "minInterval" => 1 ], "series" => [ [ "name" => "数量", "data" => [], "type" => "line", "smooth" => true, "itemStyle" => [ "normal" => [ "color" => "#4F7FF3", "lineStyle" => [ "color" => "#4F7FF3" ] ] ] ] ] ]; public function __construct() { parent::__construct(); $this->option['xAxis']['data'] = RandomUtil::dateCollection(); $this->option['series'][0]['data'] = RandomUtil::numberCollection(); } public static function make() { return new static(); } public function xData($value) { $this->option['xAxis']['data'] = $value; return $this; } public function yData($value) { $this->option['series'][0]['data'] = $value; return $this; } protected function variables() { return [ 'option' => $this->option, 'height' => $this->height, ]; } }