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}";