From 58e2bb5045d8135822914b8a4a59237a79529eb3 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 3 Nov 2023 14:21:39 +0800 Subject: [PATCH] * pivot: refactor the preview method. --- module/chart/control.php | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/module/chart/control.php b/module/chart/control.php index 50c5139a80..e67ead14d4 100644 --- a/module/chart/control.php +++ b/module/chart/control.php @@ -19,23 +19,21 @@ class chart extends control * @access public * @return void */ - public function preview($dimensionID = 0, $groupID = 0) + public function preview(int $dimensionID = 0, int $groupID = 0) { $dimensionID = $this->loadModel('dimension')->getDimension($dimensionID); - if(!$groupID) $groupID = $this->chart->getFirstChartGroupID($dimensionID); + if(!$groupID) $groupID = $this->chart->getFirstGroup($dimensionID); - list($chartTree, $charts) = $this->chart->getPreviewCharts($groupID); - $this->setFeatureBar($dimensionID); - - if(!empty($_POST)) + $charts = array(); + if($this->post->charts) { - $charts = array(); - foreach($this->post->charts as $value) + foreach($this->post->charts as $chartID) { - $chartID = explode('_', $value); - $group = $chartID[0]; - $chartID = $chartID[1]; + $idList = explode('_', $chartID); + if(count($idList) != 2) continue; + + list($group, $chartID) = $idList; $chart = $this->chart->getByID($chartID); $chart->currentGroup = $group; @@ -44,17 +42,14 @@ class chart extends control } } - foreach($charts as $id => $chart) - { - $charts[$id]->echartOptions = $this->chart->getEchartOptions($chart->id); - $charts[$id]->filterOptions = $this->chart->getFilterOptions($chart->id); - } + if(!$charts) $charts = $this->chart->getDefaultCharts($groupID); - $this->view->title = $this->lang->chart->preview; - $this->view->dimensionID = $dimensionID; - $this->view->group = $this->loadModel('tree')->getByID($groupID); - $this->view->chartTree = $chartTree; - $this->view->charts = $charts; + $this->view->title = $this->lang->chart->preview; + $this->view->groups = $this->loadModel('tree')->getGroupPairs($dimensionID, 0, 1); + $this->view->treeMenu = $this->chart->getTreeMenu($groupID); + $this->view->charts = $charts; + $this->view->dimensionID = $dimensionID; + $this->view->groupID = $groupID; $this->display(); }