<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Widget\Chart; use ModStart\Core\Util\ColorUtil; use ModStart\Core\Util\RandomUtil; use ModStart\Core\Util\TimeUtil; use ModStart\Widget\AbstractWidget; use ModStart\Widget\Traits\DSTrait; class Line extends AbstractWidget { use DSTrait; protected $view = 'modstart::widget.chart'; protected $height = 300; protected $option = array('grid' => array('top' => '5%', 'right' => '1%', 'left' => '1%', 'bottom' => '10%', 'containLabel' => true), 'legend' => array('data' => array()), 'tooltip' => array('trigger' => 'axis'), 'xAxis' => array('type' => 'category', 'data' => array()), 'yAxis' => array('type' => 'value', 'minInterval' => 1), 'series' => array()); public function __construct() { parent::__construct(); } public static function make() { return new static(); } public function random() { goto OIqjA; OIqjA: $this->option['xAxis']['data'] = RandomUtil::dateCollection(); goto ekg8I; ekg8I: $this->ySeries(0, RandomUtil::numberCollection()); goto NHPir; NHPir: return $this; goto heV7h; heV7h: } public function xData($FT9zA, $Kp99R = array()) { $this->option['xAxis']['data'] = $FT9zA; return $this; } public function yData($FT9zA, $Kp99R = array()) { return $this->ySeries(0, $FT9zA, '数量', $Kp99R); } public function ySeries($eQWJY, $FT9zA, $rPkIY = '数量', $Kp99R = array()) { goto ra7b2; Xz5kl: $this->option['series'][$eQWJY] = array('name' => $rPkIY, 'data' => $FT9zA, 'type' => 'line', 'smooth' => true, 'itemStyle' => array('normal' => array('color' => $Kp99R['lineColor'], 'lineStyle' => array('color' => $Kp99R['lineColor'])))); goto UKZl9; UKZl9: return $this; goto Ui7Nf; ra7b2: if (!isset($Kp99R['lineColor'])) { $Kp99R['lineColor'] = ColorUtil::pick('L-' . $eQWJY); } goto BZDLZ; BZDLZ: $this->option['legend']['data'][$eQWJY] = $rPkIY; goto Xz5kl; Ui7Nf: } protected function variables() { return array('option' => $this->option, 'height' => $this->height); } public function tableDailyCountLatest($Jwra6 = array(), $qodot = 15) { goto W22af; ekXkd: $mTKI1 = date('Y-m-d', $Pfgjd); goto UwmIH; awHim: $m8O6r = strtotime($ineBL); goto TrSfx; W22af: $ineBL = date('Y-m-d'); goto awHim; TrSfx: $Pfgjd = $m8O6r - ($qodot - 1) * TimeUtil::PERIOD_DAY; goto ekXkd; UwmIH: return $this->tableDailyCount($mTKI1, $ineBL, $Jwra6); goto o_m7T; o_m7T: } public function tableDailyCount($mTKI1, $ineBL, $Jwra6 = array()) { goto HoxA4; l0wXT: foreach ($EdQjV['values'] as $vTPD6 => $FT9zA) { $elnS6 = isset($Jwra6[$vTPD6]['color']) ? $Jwra6[$vTPD6]['color'] : ColorUtil::randomColor(); $this->option['series'][] = array('name' => $Jwra6[$vTPD6]['title'], 'data' => $FT9zA, 'type' => 'line', 'smooth' => true, 'itemStyle' => array('normal' => array('color' => $elnS6, 'lineStyle' => array('color' => $elnS6)))); } goto M3O5C; GSXcf: $this->xData($EdQjV['time']); goto UtDPj; HoxA4: $EdQjV = $this->dsTableCountSeriesDaily($mTKI1, $ineBL, $Jwra6); goto GSXcf; M3O5C: return $this; goto JEU1Z; UtDPj: $this->option['series'] = array(); goto l0wXT; JEU1Z: } public function tableDailySumLatest($Jwra6 = array(), $qodot = 15) { goto Jxjif; Snn8k: $mTKI1 = date('Y-m-d', $Pfgjd); goto xCSW6; hcjDY: $Pfgjd = $m8O6r - ($qodot - 1) * TimeUtil::PERIOD_DAY; goto Snn8k; NdxWN: $m8O6r = strtotime($ineBL); goto hcjDY; xCSW6: return $this->tableDailySum($mTKI1, $ineBL, $Jwra6); goto bEx_P; Jxjif: $ineBL = date('Y-m-d'); goto NdxWN; bEx_P: } public function tableDailySum($mTKI1, $ineBL, $Jwra6 = array()) { goto vMWqv; vMWqv: $EdQjV = $this->dsTableSumSeriesDaily($mTKI1, $ineBL, $Jwra6); goto PIuSN; PIuSN: $this->xData($EdQjV['time']); goto XFG8b; D73_Y: foreach ($EdQjV['values'] as $vTPD6 => $FT9zA) { $elnS6 = isset($Jwra6[$vTPD6]['color']) ? $Jwra6[$vTPD6]['color'] : ColorUtil::randomColor(); $this->option['series'][] = array('name' => $Jwra6[$vTPD6]['title'], 'data' => $FT9zA, 'type' => 'line', 'smooth' => true, 'itemStyle' => array('normal' => array('color' => $elnS6, 'lineStyle' => array('color' => $elnS6)))); } goto uPvne; uPvne: return $this; goto PGJSf; XFG8b: $this->option['series'] = array(); goto D73_Y; PGJSf: } }