From 80926fb353421160340335b236093fec37d660e4 Mon Sep 17 00:00:00 2001 From: wlx Date: Thu, 22 Jan 2015 01:21:29 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0highcharts=E4=B8=93=E9=97=A8?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?category=E5=8F=AF=E8=A7=86=E5=8C=96=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=E8=B0=83=E7=94=A8=E6=94=B9=E7=94=A8id?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/VisualController.php | 2 + .../scripts/visual/view-highcharts.phtml | 165 ++++++++++++++++++ .../default/views/scripts/visual/view.phtml | 26 +-- application/models/Theme.php | 3 +- application/module/Westdc/Visual/Record.php | 12 +- 5 files changed, 189 insertions(+), 19 deletions(-) create mode 100644 application/default/views/scripts/visual/view-highcharts.phtml diff --git a/application/default/controllers/VisualController.php b/application/default/controllers/VisualController.php index eb4b8ca1..3c6e2b14 100644 --- a/application/default/controllers/VisualController.php +++ b/application/default/controllers/VisualController.php @@ -82,6 +82,8 @@ class VisualController extends Zend_Controller_Action $this->view->data = $visual->getVisualVars($uuid); + if ($this->view->data['chartjs']=='highcharts') $this->_helper->viewRenderer('view-highcharts'); + if(empty($this->view->data)) { view::Post($this,"此数据不支持可视化",-1); diff --git a/application/default/views/scripts/visual/view-highcharts.phtml b/application/default/views/scripts/visual/view-highcharts.phtml new file mode 100644 index 00000000..a7752635 --- /dev/null +++ b/application/default/views/scripts/visual/view-highcharts.phtml @@ -0,0 +1,165 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->data); +$this->headTitle()->setSeparator(' - '); +$theme = new Theme; +$theme->appendPlus($this,'highcharts'); +$this->nav[] = array('link'=>"/data/visual",'title'=>'数据可视化'); +?> +render('breadcrumbs.phtml'); ?> +
+
+

info['title'] ?> 查看元数据

+

请在需要查看的可视化要素上点击以描绘图表,再次点击可取消显示,绘制图像前可自主选择图像类型

+ +
+
+
+ + + + + + +
+
+ +
+
+ + data['variable'],true);?> + + $v) { ?> + + + + + +
+
+
+ +
+
+
+ +
+ \ No newline at end of file diff --git a/application/default/views/scripts/visual/view.phtml b/application/default/views/scripts/visual/view.phtml index 2c64aa18..de8d41b9 100644 --- a/application/default/views/scripts/visual/view.phtml +++ b/application/default/views/scripts/visual/view.phtml @@ -7,22 +7,21 @@ if(isset($this->data['chartjs']) && $this->data['chartjs']=='highstock') $theme->appendPlus($this,'highstock'); if($this->data['chartjs'] == 'highcharts') $theme->appendPlus($this,'highcharts'); -$this->breadcrumb('首页'); -$this->breadcrumb('数据与服务'); -$this->breadcrumb('数据可视化'); -$this->breadcrumb()->setSeparator(' > '); -$this->nav[] = array('link'=>"/data/visual",'title'=>'可视化数据列表'); +$this->nav[] = array('link'=>"/data/visual",'title'=>'数据可视化'); ?> +render('breadcrumbs.phtml'); ?>
-

info['title'] ?> 数据可视化查看

+

info['title'] ?> 查看元数据

请在需要查看的可视化要素上点击以描绘图表,再次点击可取消显示,绘制图像前可自主选择图像类型

- - + + + +
@@ -33,10 +32,10 @@ $this->nav[] = array('link'=>"/data/visual",'title'=>'可视化数据列表');

- normaldecode($this->data['variable']);?> + data['variable'],true);?> $v) { ?> - + @@ -82,8 +81,9 @@ $(function() { $('#datachart').highcharts('StockChart', { rangeSelector : { + buttons: [{type:'hour',count:1,text:'1h'},{type:'day',count:1,text:'1D'},{type:'month',count:1,text:'1m'},{type:'year',count:1,text:'1Y'},{type:'all',count:1,text:'All'}], selected : 1, - inputEnabled: $('#container').width() > 480 + inputEnabled: $('#datachart').width() > 480 }, credits : { @@ -96,7 +96,7 @@ $(function() { tooltip : { formatter: function() { - var s = ''+ Highcharts.dateFormat('%Y-%m-%d %A %H:%M:%S', this.x) +''; + var s = ''+ Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +''; $.each(this.points, function(i, point) { s += '
' + point.series.name + ': ' + point.y +''; @@ -130,7 +130,7 @@ $(function() { tooltip : { formatter: function () { - var s = '' + Highcharts.dateFormat('%Y-%m-%d %A %H:%M:%S', this.x) + ''; + var s = '' + Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + ''; $.each(this.points, function () { s += '
' + this.series.name + ': ' + this.y + ''; diff --git a/application/models/Theme.php b/application/models/Theme.php index 99425ea9..04e7b99e 100644 --- a/application/models/Theme.php +++ b/application/models/Theme.php @@ -139,7 +139,8 @@ class Theme 'highcharts' => array( $this->ScriptKey => array( - '/js/lib/highcharts/highcharts.js' + '/js/lib/highcharts/highcharts.js', + '/js/lib/highcharts/highcharts-more.js' ) ), diff --git a/application/module/Westdc/Visual/Record.php b/application/module/Westdc/Visual/Record.php index 80f693be..fe7c05ea 100644 --- a/application/module/Westdc/Visual/Record.php +++ b/application/module/Westdc/Visual/Record.php @@ -4,7 +4,7 @@ namespace Westdc\Visual; class Record extends Database { - public $subdataset,$valueFilter,$vars,$uuid,$xaxis; + public $subdataset,$valueFilter,$vars,$uuid,$xaxis,$field; private $sql; function __construct($uuid,$identifier ) @@ -29,7 +29,9 @@ class Record extends Database $this->vars = $var_data['variable']; $this->xaxis=$var_data['xaxis']; $json=json_decode($this->vars,true); - $subvar=array_filter($json,function($sub) { return $sub['name']==$this->subdataset; }); + //$subvar=array_filter($json,function($sub) { return $sub['name']==$this->subdataset; }); + $subvar=$json[$this->subdataset]; + $this->field=$subvar['name']; if (isset($subvar['sql']) && !empty($subvar['sql'])) $this->sql=$this->makeSql($subvar['sql']); elseif(isset($var_data['data']) && !empty($var_data['data'])) @@ -54,8 +56,8 @@ class Record extends Database $data = []; while($row = $rs->fetch(\PDO::FETCH_ASSOC)) { - - $row['utctime'] = $this->utcMsTime(strtotime($row['utctime'])); + if ($this->xaxis!='category') + $row[$this->xaxis] = $this->utcMsTime(strtotime($row[$this->xaxis])); //var_dump($row); $t=[]; foreach($row as $k=>$v) @@ -83,7 +85,7 @@ class Record extends Database } } - $sql = "SELECT {$this->xaxis},{$this->subdataset} + $sql = "SELECT {$this->xaxis},{$this->field} FROM ($table) as tbl $wheresql ORDER BY {$this->xaxis}";