add highcharts j

This commit is contained in:
Li Jianxuan 2015-01-21 08:34:48 +00:00
parent 72e03e97c0
commit 2f91e5afee
1 changed files with 68 additions and 30 deletions

View File

@ -3,7 +3,10 @@ $this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->data); $this->headTitle($this->config->title->data);
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$theme = new Theme; $theme = new Theme;
$theme->appendPlus($this,'highstock'); if(isset($this->data['chartjs']) && $this->data['chartjs']=='highstock')
$theme->appendPlus($this,'highstock');
if($this->data['chartjs'] == 'highcharts')
$theme->appendPlus($this,'highcharts');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/data">数据与服务</a>'); $this->breadcrumb('<a href="/data">数据与服务</a>');
$this->breadcrumb('数据可视化'); $this->breadcrumb('数据可视化');
@ -73,40 +76,75 @@ $(function() {
useUTC: _this.utctimezone useUTC: _this.utctimezone
} }
}); });
$('#datachart').highcharts('StockChart', {
rangeSelector : {
selected : 1,
inputEnabled: $('#container').width() > 480
},
credits : {
enabled : false
},
xAxis: {
type: 'datetime'
},
tooltip : {
formatter: function() {
var s = '<b>'+ Highcharts.dateFormat('%Y-%m-%d %A %H:%M:%S', this.x) +'</b>';
$.each(this.points, function(i, point) { <?php if(isset($this->data['chartjs']) && $this->data['chartjs']=='highstock') { ?>
s += '<br /><span style="color: '+point.series.color+';">' + point.series.name + ': ' + point.y +'</span>';
}); $('#datachart').highcharts('StockChart', {
return s; rangeSelector : {
selected : 1,
inputEnabled: $('#container').width() > 480
},
credits : {
enabled : false
},
xAxis: {
type: 'datetime'
},
tooltip : {
formatter: function() {
var s = '<b>'+ Highcharts.dateFormat('%Y-%m-%d %A %H:%M:%S', this.x) +'</b>';
$.each(this.points, function(i, point) {
s += '<br /><span style="color: '+point.series.color+';">' + point.series.name + ': ' + point.y +'</span>';
});
return s;
} }
}, }
}); });
var chart = $('#datachart').highcharts(); var chart = $('#datachart').highcharts();
<?php } ?>
<?php if($this->data['chartjs'] == 'highcharts') { ?>
$('#datachart').highcharts({
title: {
text: '<?= $this->info['title'] ?>',
x: -20 //center
},
credits : {
enabled : false
},
xAxis: {
type: 'datetime'
},
tooltip : {
formatter: function () {
var s = '<b>' + Highcharts.dateFormat('%Y-%m-%d %A %H:%M:%S', this.x) + '</b>';
$.each(this.points, function () {
s += '<br/><span style="color: '+ this.series.color+';">' + this.series.name + ': ' + this.y + '</span>';
});
return s;
},
shared: true
}
});
var chart = $('#datachart').highcharts();
<?php } ?>
$(".control-btn").click(function(){ $(".control-btn").click(function(){
uuid = '<?= $this->info['uuid'] ?>'; uuid = '<?= $this->info['uuid'] ?>';
@ -137,7 +175,7 @@ $(function() {
type : _this.linetype, type : _this.linetype,
dataGrouping: { dataGrouping: {
enabled: false, enabled: false,
forced: false, forced: false
} }
}); });