$(function() {
var echart = {
//折线图 echartLine: function() {
var myChart = echarts.init(document.getElementById('echart-cont'));
var line = {
// color: ['#76A6D3', '#90C177', '#747AB4'], title: {
text: '',
x: 'center' },
tooltip: {
trigger: 'axis',
formatter: '' },
legend: {
data: ['访客数', '浏览量', '新访客数'],
bottom: '1%',
show: true },
toolbox: {
show: true,
feature: {
magicType: { show: true, type: ['line', 'bar'] },
}
},
grid: {
left: '1%',
right: '1%',
bottom: '10%',
top: '5%',
containLabel: true },
xAxis: [{
type: 'category',
// boundaryGap: true, data: [20171228, 20171229, 20171230, 20171231, 20180101, 20180102, 20180103],
show: true }],
yAxis: [{
type: 'value',
show: true }],
series: [{
name: '访客数',
data: [8118, 7276, 7462, 7465, 8714, 9372, 8118],
type: 'line',
smooth: true },
{
name: '浏览量',
data: [28761, 24123, 26751, 25563, 29376, 31858, 26751],
type: 'line',
smooth: true },
{
name: '新访客数',
data: [826, 745, 722, 740, 840, 820, 826],
type: 'line',
smooth: true }
]
};
myChart.setOption(line);
},
//指标面板内容 indexModule: function() {
// var oLeft = document.getElementById("index_tool_more").offsetLeft; // if (oLeft < 500) { // list.style.left = "0px"; // } var selecArr = []; //存放选中项的数组 //点击右下方菜单的时候,当前面板显示 $(".index_tool_more>span").click(function() {
$(this).next().show();
$(this).parents(".b5bg").siblings().find(".index_list").hide();
});
//点击确定的时候,当前面板隐藏 $(".index_tool_table").on("click", function() {
$(this).parent().hide();
});
//点击面板里面的内容的时候 $(".selected_box").click(function() {
$(this).toggleClass("selected");
});
},
}
//页面初始化显示折线图 echart.echartLine();
//指标面板执行 echart.indexModule();
//日期格式化函数 function changeDate(val) {
var date = new Date().getTime() - (val * 24 * 60 * 60 * 1000);
var ndate = new Date(date);
var Y = ndate.getFullYear() + "-";
var M = (ndate.getMonth() + 1 < 10 ? '0' + (ndate.getMonth() + 1) : ndate.getMonth() + 1) + "-";
var D = (ndate.getDate() < 10 ? '0' + (ndate.getDate()) : ndate.getDate());
ndate = Y + M + D;
return ndate;
}
//日期转化,去 "-" function toStr(str) {
var toStr = str.split("-").join("");
return toStr;
}
//日期初始化 $("#date-start").val(changeDate(7));
$("#date-end").val(changeDate(0));
//定义日期变量 var time = {
startTime: "",
endTiem: "" }
//点击日期确定按钮 $("#date-btn").click(function() {
time.startTime = Number(toStr($("#date-start").val()));
time.endTiem = Number(toStr($("#date-end").val()));
if (time.startTime > time.endTiem) {
alert("开始时间不能大于结束时间")
return;
}else {
time.startTime = $("#date-start").val();
time.endTiem = $("#date-end").val();
var dateNum=DateDiff(time.endTiem, time.startTime);//计算两个时间的天数 var betweenTime=changeDate(dateNum*2);
var newStartTime=toStr($("#date-start").val());
var newEndTime=toStr($("#date-end").val());
var newBetweenTime=toStr(betweenTime);
console.log(newStartTime);
console.log(newEndTime);
console.log(newBetweenTime);
}
$.ajax({
})
})
//计算天数差的函数,通用 function DateDiff(sDate1, sDate2){ //sDate1和sDate2是2002-12-18格式 var aDate, oDate1, oDate2, iDays
aDate = sDate1.split("-")
oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式 aDate = sDate2.split("-")
oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24) //把相差的毫秒数转换为天数 return iDays
}
})
还没有评论,来说两句吧...