13 class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
    18     const API_URL = 
'http://chart.apis.google.com/chart';
    53     protected $_simpleEncoding = 
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    60     protected $_extendedEncoding = 
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.';
    93     protected $_template = 
'Magento_Backend::dashboard/graph.phtml';
   114         $this->_dashboardData = $dashboardData;
   115         parent::__construct($context, $collectionFactory, 
$data);
   125         return 'dashboard/graph.phtml';
   136         $this->_dataRows = (array)$rows;
   148         $this->_allSeries[$seriesId] = 
$options;
   159         if (isset($this->_allSeries[$seriesId])) {
   160             return $this->_allSeries[$seriesId];
   186     public function getChartUrl($directUrl = 
true)
   190             'chf' => 
'bg,s,ffffff',
   193             'chxs' => 
'0,676056,15,0,l,676056|1,676056,15,0,l,676056',
   194             'chm' => 
'h,f2ebde,0,0:1:.1,1,-1',
   197         $this->_allSeries = $this->
getRowsData($this->_dataRows);
   199         foreach ($this->_axisMaps as $axis => 
$attr) {
   203         $timezoneLocal = $this->_localeDate->getConfigTimezone();
   207         list($dateStart, $dateEnd) = $this->_collectionFactory->create()->getDateRange(
   214         $dateStart->setTimezone(
new \DateTimeZone($timezoneLocal));
   215         $dateEnd->setTimezone(
new \DateTimeZone($timezoneLocal));
   218             $dateEnd->modify(
'-1 hour');
   220             $dateEnd->setTime(23, 59, 59);
   221             $dateStart->setTime(0, 0, 0);
   227         while ($dateStart <= $dateEnd) {
   231                     $d = $dateStart->format(
'Y-m-d');
   232                     $dateStart->modify(
'+1 day');
   236                     $d = $dateStart->format(
'Y-m');
   237                     $dateStart->modify(
'+1 month');
   240                     $d = $dateStart->format(
'Y-m-d H:00');
   241                     $dateStart->modify(
'+1 hour');
   244                 if (in_array($d, $this->_axisLabels[
'x'])) {
   245                     $datas[
$index][] = (double)array_shift($this->_allSeries[
$index]);
   256         if (count($dates) > 8 && count($dates) < 15) {
   259             if (count($dates) >= 15) {
   269         foreach ($dates as $k => $d) {
   279         $this->_axisLabels[
'x'] = $dates;
   280         $this->_allSeries = $datas;
   283         if ($this->_encoding == 
"s") {
   287             $dataSetdelimiter = 
",";
   293             $dataSetdelimiter = 
",";
   298         $localmaxvalue = [0];
   299         $localminvalue = [0];
   301             $localmaxvalue[
$index] = max($serie);
   302             $localminvalue[
$index] = min($serie);
   305         $maxvalue = max($localmaxvalue);
   306         $minvalue = min($localminvalue);
   315         if ($minvalue >= 0 && $maxvalue >= 0) {
   316             if ($maxvalue > 10) {
   317                 $p = pow(10, $this->
_getPow($maxvalue));
   318                 $maxy = ceil($maxvalue / $p) * $p;
   319                 $yLabels = range($miny, $maxy, $p);
   321                 $maxy = ceil($maxvalue + 1);
   322                 $yLabels = range($miny, $maxy, 1);
   331             $thisdataarray = $serie;
   332             if ($this->_encoding == 
"s") {
   334                 for ($j = 0; $j < 
sizeof($thisdataarray); $j++) {
   335                     $currentvalue = $thisdataarray[$j];
   336                     if (is_numeric($currentvalue)) {
   338                             (strlen($this->_simpleEncoding) - 1) * ($yorigin + $currentvalue) / $yrange
   340                         $chartdata[] = substr($this->_simpleEncoding, $ylocation, 1) . $dataDelimiter;
   342                         $chartdata[] = $dataMissing . $dataDelimiter;
   347                 for ($j = 0; $j < 
sizeof($thisdataarray); $j++) {
   348                     $currentvalue = $thisdataarray[$j];
   349                     if (is_numeric($currentvalue)) {
   351                             $ylocation = 4095 * ($yorigin + $currentvalue) / $yrange;
   355                         $firstchar = floor($ylocation / 64);
   356                         $secondchar = $ylocation % 64;
   357                         $mappedchar = substr(
   358                             $this->_extendedEncoding,
   362                             $this->_extendedEncoding,
   366                         $chartdata[] = $mappedchar . $dataDelimiter;
   368                         $chartdata[] = $dataMissing . $dataDelimiter;
   372             $chartdata[] = $dataSetdelimiter;
   374         $buffer = implode(
'', $chartdata);
   376         $buffer = rtrim($buffer, $dataSetdelimiter);
   377         $buffer = rtrim($buffer, $dataDelimiter);
   378         $buffer = str_replace($dataDelimiter . $dataSetdelimiter, $dataSetdelimiter, $buffer);
   384         if (
sizeof($this->_axisLabels) > 0) {
   385             $params[
'chxt'] = implode(
',', array_keys($this->_axisLabels));
   387             foreach ($this->_axisLabels as $idx => $labels) {
   392                     foreach ($this->_axisLabels[$idx] as $_index => $_label) {
   394                             $period = new \DateTime($_label, 
new \DateTimeZone($timezoneLocal));
   397                                     $this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
   398                                         $period->setTime($period->format(
'H'), 0, 0),
   399                                         \IntlDateFormatter::NONE,
   400                                         \IntlDateFormatter::SHORT
   405                                     $this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
   407                                         \IntlDateFormatter::SHORT,
   408                                         \IntlDateFormatter::NONE
   413                                     $this->_axisLabels[$idx][$_index] = date(
'm/Y', strtotime($_label));
   417                             $this->_axisLabels[$idx][$_index] = 
'';
   421                     $tmpstring = implode(
'|', $this->_axisLabels[$idx]);
   423                     $valueBuffer[] = $indexid . 
":|" . $tmpstring;
   425                     $valueBuffer[] = $indexid . 
":|" . implode(
'|', $yLabels);
   429             $params[
'chxl'] = implode(
'|', $valueBuffer);
   441             return self::API_URL . 
'?' . implode(
'&', $p);
   443             $gaData = urlencode(base64_encode(json_encode(
$params)));
   444             $gaHash = $this->_dashboardData->getChartDataHash($gaData);
   445             $params = [
'ga' => $gaData, 
'h' => $gaHash];
   446             return $this->
getUrl(
'adminhtml/*/tunnel', [
'_query' => 
$params]);
   482         $this->_axisLabels[$axis] = $labels;
   493         $this->_htmlId = $htmlId;
   548         $this->_dataHelper = $dataHelper;
   558         if ($this->_dataHelper !== 
null) {
   559             $availablePeriods = array_keys($this->_dashboardData->getDatePeriods());
   560             $period = $this->
getRequest()->getParam(
'period');
   563                 $period && in_array($period, $availablePeriods) ? $period : 
'24h' 
elseif(isset( $params[ 'redirect_parent']))
 
getRowsData($attributes, $single=false)
 
addSeries($seriesId, array $options)
 
getUrl($route='', $params=[])
 
setDataHelper(\Magento\Backend\Helper\Dashboard\AbstractDashboard $dataHelper)
 
setAxisLabels($axis, $labels)
 
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory, \Magento\Backend\Helper\Dashboard\Data $dashboardData, array $data=[])
 
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
 
if(!isset($_GET['name'])) $name