From 04c26e7a86effe68cc33938c949ff086f24ea089 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Mon, 7 Jul 2025 07:53:39 +0000 Subject: [PATCH 1/2] * [unittest] add getaxisrotateoption. --- .../screen/test/model/getaxisrotateoption.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 module/screen/test/model/getaxisrotateoption.php diff --git a/module/screen/test/model/getaxisrotateoption.php b/module/screen/test/model/getaxisrotateoption.php new file mode 100644 index 0000000000..e58361754a --- /dev/null +++ b/module/screen/test/model/getaxisrotateoption.php @@ -0,0 +1,61 @@ +#!/usr/bin/env php +getAxisRotateOption(); +timeout=0 +cid=1 + +- 判断折线图x轴旋转角度 @30 +- 判断折线图y轴旋转角度 @30 +- 判断折线图仅设置x轴旋转时x轴旋转角度 @30 +- 判断折线图仅设置x轴旋转时y轴旋转角度 @0 +- 判断雷达图是否设置x轴旋转角度 @0 +- 判断雷达图是否设置y轴旋转角度 @0 + +*/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/screen.unittest.class.php'; + +$screen = new screenTest(); + +global $tester; + +$chart1 = new stdClass(); +$chart1->type = 'line'; +$chart1->settings = json_encode(array(array('rotateX' => 'use', 'rotateY' => 'use'))); + +$component = new stdClass(); +$component->chartConfig = new stdClass(); + +$component = $screen->getAxisRotateOption($chart1, $component); + +r($component->chartConfig->xAxis->axisLabel->rotate) && p('') && e('30'); // 判断折线图x轴旋转角度 +r($component->chartConfig->yAxis->axisLabel->rotate) && p('') && e('30'); // 判断折线图y轴旋转角度 + +$chart2 = new stdClass(); +$chart2->type = 'line'; +$chart2->settings = json_encode(array(array('rotateX' => 'use'))); + +$component = new stdClass(); +$component->chartConfig = new stdClass(); + +$component = $screen->getAxisRotateOption($chart2, $component); + +r($component->chartConfig->xAxis->axisLabel->rotate) && p('') && e('30'); // 判断折线图仅设置x轴旋转时x轴旋转角度 +r($component->chartConfig->yAxis->axisLabel->rotate) && p('') && e('0'); // 判断折线图仅设置x轴旋转时y轴旋转角度 + +$chart3 = new stdClass(); +$chart3->type = 'radar'; +$chart3->settings = json_encode(array(array('rotateX' => 'use'))); + +$component = new stdClass(); +$component->chartConfig = new stdClass(); + +$component = $screen->getAxisRotateOption($chart3, $component); + +r(isset($component->chartConfig->xAxis->axisLabel->rotate)) && p('') && e('0'); // 判断雷达图是否设置x轴旋转角度 +r(isset($component->chartConfig->yAxis->axisLabel->rotate)) && p('') && e('0'); // 判断雷达图是否设置y轴旋转角度 \ No newline at end of file From 8e92627c1784f441f2b2a6fa384cc096cb847240 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Mon, 7 Jul 2025 08:12:10 +0000 Subject: [PATCH 2/2] * [misc] move setSelectFilter to zen. --- module/screen/control.php | 2 +- module/screen/model.php | 19 ------------------- module/screen/zen.php | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/module/screen/control.php b/module/screen/control.php index e411c48722..bf3242a64c 100644 --- a/module/screen/control.php +++ b/module/screen/control.php @@ -194,7 +194,7 @@ class screen extends control $this->screen->filter->month = $month; $this->screen->filter->dept = $dept; $this->screen->filter->account = $account; - $this->screen->setSelectFilter($sourceID, $selectFilter); + $this->filter->charts = $this->screenZen->setSelectFilter($sourceID, $selectFilter); $type = $this->screen->getChartType($type); diff --git a/module/screen/model.php b/module/screen/model.php index 0597012cd8..d26dbd943c 100644 --- a/module/screen/model.php +++ b/module/screen/model.php @@ -1894,25 +1894,6 @@ class screenModel extends model } } - /** - * Set select filter. - * - * @param string $sourceID - * @param array $filters - * @access public - * @return void - */ - public function setSelectFilter($sourceID, $filters) - { - if(empty($filters)) return; - - foreach($filters as $filter) - { - if(!isset($this->filter->charts[$sourceID])) $this->filter->charts[$sourceID] = array(); - $this->filter->charts[$sourceID][$filter['type']] = $filter['field']; - } - } - /** * Set SQL filter * diff --git a/module/screen/zen.php b/module/screen/zen.php index 4f4b4d097f..65309b6e4a 100644 --- a/module/screen/zen.php +++ b/module/screen/zen.php @@ -45,4 +45,27 @@ class screenZen extends screen return $screens; } + + /** + * Set select filter. + * + * @param string $sourceID + * @param array $filters + * @access protected + * @return array + */ + protected function setSelectFilter($sourceID, $filters) + { + if(empty($filters)) return; + + $chartFilters = array(); + + foreach($filters as $filter) + { + if(!isset($chartFilters[$sourceID])) $chartFilters[$sourceID] = array(); + $chartFilters[$sourceID][$filter['type']] = $filter['field']; + } + + return $chartFilters; + } }