var differDay = "<?=$differDay?>";
var isRegion = <?=$isRegion?>;
//单条曲线图付费金额数据和配置
var myDate = new Date();
var time = myDate.getTime();
console.log(time);
var date = new Date(time - 15 * 24 * 3600 * 1000);//15天前的时间戳
var param = {'time': time};
if(differDay!=1){//区间日期筛选时
time = "<?=($etime+1)*1000?>";
date = new Date(<?=$stime*1000?>);
param = {'time': time,'differDay':differDay};
}
if(isRegion==1&&differDay==1){
time = "<?=($etime+1)*1000?>";
date = new Date(<?=$stime*1000?> - 15 * 24 * 3600 * 1000);//15天前的时间戳
param = {'time': time,'differDay':differDay};
}
var xAxis = {
type: 'datetime',
tickInterval: 24 * 36e5, // one day
labels: {
format: '{value: %m/%d}',
align: 'right',
rotation: -30
}
};
var yAxis = {
max: 0
};
var series= [{
data: [],
pointInterval: 24 * 36e5,
// 比当前时间差4天
pointStart: Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
}];
var opt1 = {
plotOptions: {
series: {
label: {
connectorAllowed: false
},
}
},
// 前15天
// 设置x轴
xAxis: xAxis,
yAxis: yAxis,
series:series,
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
},
};
$(function(){
var url = $('#a-tab-1').attr('data-url');
MXHY.send(url, param, 'get', function (res) {
eval("opt1").yAxis.max = res['max'];
eval("opt1").series[0].name = '付费金额';
eval("opt1").series[0].data = res['data'];
MXHY.hchart('container1', eval("opt1"));
});
});
/**
* 图表.
*
* @param obj
* @param opt
*/
this.hchart = function (id, opts) {
var options = {};
// 公共配置
var common = {
title: {
text: ''
},
subtitle: {
text: ''
},
yAxis: {
title: {
text: ''
}
},
credits: {
enabled: false // 禁用版权信息
},
tooltip: {
enabled: true,
},
legend: {
enabled:false,
},
};
// 合并参数
$.extend(options, common, opts);
try {
Highcharts.chart(id, options);
} catch (e) {
console.error('对像不存在');
}
};