<?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), 'tooltip' => array('trigger' => 'axis'), 'xAxis' => array('type' => 'category', 'data' => array()), 'yAxis' => array('type' => 'value', 'minInterval' => 1), 'series' => array(array('name' => '数量', 'data' => array(), 'type' => 'line', 'smooth' => true, 'itemStyle' => array('normal' => array('color' => '#4F7FF3', 'lineStyle' => array('color' => '#4F7FF3')))))); public function __construct() { parent::__construct(); } public static function make() { return new static(); } public function random() { goto nFP9K; SE3k0: $this->option['series'][0]['data'] = RandomUtil::numberCollection(); goto PZPAy; nFP9K: $this->option['xAxis']['data'] = RandomUtil::dateCollection(); goto SE3k0; PZPAy: return $this; goto CiUFT; CiUFT: } public function xData($tzAUI) { $this->option['xAxis']['data'] = $tzAUI; return $this; } public function yData($tzAUI) { $this->option['series'][0]['data'] = $tzAUI; return $this; } protected function variables() { return array('option' => $this->option, 'height' => $this->height); } public function tableDailyCountLatest($bhIH0 = array(), $c0fAD = 15) { goto M7yBR; MlKMU: $VEnMw = date('Y-m-d', $k0RGX); goto prgys; Hqpku: $k0RGX = $iCpJV - ($c0fAD - 1) * TimeUtil::PERIOD_DAY; goto MlKMU; M7yBR: $XoefR = date('Y-m-d'); goto vgMpl; vgMpl: $iCpJV = strtotime($XoefR); goto Hqpku; prgys: return $this->tableDailyCount($VEnMw, $XoefR, $bhIH0); goto Z6rQl; Z6rQl: } public function tableDailyCount($VEnMw, $XoefR, $bhIH0 = array()) { goto NGPpV; iYoG3: $this->option['series'] = array(); goto HJDKM; zDg6C: return $this; goto syPw5; KmydE: $this->xData($Y0YxF['time']); goto iYoG3; NGPpV: $Y0YxF = $this->dsTableCountSeriesDaily($VEnMw, $XoefR, $bhIH0); goto KmydE; HJDKM: foreach ($Y0YxF['values'] as $XIWRg => $tzAUI) { $hLB40 = isset($bhIH0[$XIWRg]['color']) ? $bhIH0[$XIWRg]['color'] : ColorUtil::randomColor(); $this->option['series'][] = array('name' => $bhIH0[$XIWRg]['title'], 'data' => $tzAUI, 'type' => 'line', 'smooth' => true, 'itemStyle' => array('normal' => array('color' => $hLB40, 'lineStyle' => array('color' => $hLB40)))); } goto zDg6C; syPw5: } public function tableDailySumLatest($bhIH0 = array(), $c0fAD = 15) { goto sVih4; YzIJn: return $this->tableDailySum($VEnMw, $XoefR, $bhIH0); goto bzlsh; fqfS6: $k0RGX = $iCpJV - ($c0fAD - 1) * TimeUtil::PERIOD_DAY; goto A4OOL; qwziP: $iCpJV = strtotime($XoefR); goto fqfS6; sVih4: $XoefR = date('Y-m-d'); goto qwziP; A4OOL: $VEnMw = date('Y-m-d', $k0RGX); goto YzIJn; bzlsh: } public function tableDailySum($VEnMw, $XoefR, $bhIH0 = array()) { goto NG0WP; ZsAIm: $this->option['series'] = array(); goto iHXTe; NG0WP: $Y0YxF = $this->dsTableSumSeriesDaily($VEnMw, $XoefR, $bhIH0); goto GQKdq; GQKdq: $this->xData($Y0YxF['time']); goto ZsAIm; JGgGd: return $this; goto WGR3e; iHXTe: foreach ($Y0YxF['values'] as $XIWRg => $tzAUI) { $hLB40 = isset($bhIH0[$XIWRg]['color']) ? $bhIH0[$XIWRg]['color'] : ColorUtil::randomColor(); $this->option['series'][] = array('name' => $bhIH0[$XIWRg]['title'], 'data' => $tzAUI, 'type' => 'line', 'smooth' => true, 'itemStyle' => array('normal' => array('color' => $hLB40, 'lineStyle' => array('color' => $hLB40)))); } goto JGgGd; WGR3e: } }