控制器,得到数据
//5天收益率
public function FiveIncome()
{
$data = [];
//5日detail
$detail = $this->stock->getColumnDetail(2);
$data['tulist1'] = $this->ColumnIncome($detail['list'],2);
$data['detail1'] = $detail;
$staticPic = STATIC_File_url.'images/head.png';
//榜table
$list = $this->stock->getColumnRank(2);
foreach($list as $key =>&$value){
$value['nickname']= isset($value['nickname'])?mb_strcut($value['nickname'],0,6,'utf-8'):"";
$value['win_rate'] = sprintf("%.2f", $value['win_rate']);
$value['stock_avg_profits'] = sprintf("%.2f", $value['stock_avg_profits'])."%";
$value['stock_profits_rate'] = sprintf("%.2f", $value['stock_profits_rate'])."%";
$value['avatarurl'] = $this->common->check_remote_file_exists($value['avatarurl'])?$value['avatarurl']:$staticPic;
}
$data['list1'] = $list;
$this->load->view('column/fiveincome',$data);
}
//拆线图
public function ColumnIncome($data,$type)
{
$currentYear = date('Y-', time());
$dateY = array();
$line1 = array();
$line2 = array();
$datas = [];
if($data){
//横坐标
$dateValue = $data;
foreach($dateValue as $key =>$value){
if($value['date']){
$dateY[] = str_replace($currentYear,"",$value['date']);
}
//line1
if(isset($value['profits'])){
$line1[] = $value['profits'];
}
//line2
if(isset($value['HS300'])){
$line2[] = $value['HS300'];
}
}
$StrLine1 = implode(",",$line1);
$Strline2 = implode(",",$line2);
$SdateY = implode("','",$dateY);
$datas = [$StrLine1,$Strline2,"'".$SdateY."'"];
}else{
$datas = array('0'=>'','1'=>'','2'=>'');
}
return $datas;
}
<div id="container" style="min-width:400px;height:170px"></div>
<script type="text/javascript" src="<?php echo STATIC_File_url;?>js/jquery.js?st=20160824" ></script>
<script type="text/javascript" src="<?php echo STATIC_File_url;?>js/highcharts.js"></script>
<script>
$(function () {
var tudata = [];
tudata[1] = [<?= $tulist1[0]?>];
tudata[2] = [<?= $tulist1[1]?>];
tudata[3] = [<?= $tulist1[2]?>];
$('#container').highcharts({
chart:{
backgroundColor:'rgba(0,0,0,0)'
},
credits: {
text: '',
href: ''
},
title: {
text: '',
x: -20 /*center*/
},
subtitle: {
x: -20
},
xAxis: {
labels: {
style: {
color: '#ffffff'
}
},
lineColor:'#ffffff',/*设置坐标颜色*/
gridLineWidth: 0,
categories: tudata[3],
title: {
text: '',
color:'#ffffff'
}
},
yAxis: {
labels: {
style: {
color: '#ffffff'
},
formatter: function() {
return this.value+"%";
}
},
gridLineWidth: 0,
lineColor:'#ffffff',/*设置坐标颜色*/
lineWidth:1,
title: {
text: '',
color:'#ffffff'
},
plotLines: [{
value: 0
/*width: 10,
color: '#808080'*/
}]
},
tooltip: {
valueSuffix: ''
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
lineWidth:1,
showInLegend: false,
name: '平均收益',
color:"#df10ed",
data: tudata[1]
}, {
lineWidth:1,
showInLegend: false,
name: '涨幅',
color:'#ffe400',
data: tudata[2]
}]
});
});
$("#kng").live("click", function(){
$("#ngts2").click();
})
$("#xgu").live("click", function(){
var url ="/m_stock/index?uid="+userId+"&sessid="+sessId+"&type=6";
window.location =url;
})
</script>