Introducing a time condition for the selector echart laydate time chart of screening data

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_38136817/article/details/102724003

Introducing a time condition for the selector echart laydate time chart (monthly) screening data

Callback 1 laydate components

Method, but can be carried out by laydate can not change the time by the value of JQ when selecting a date and time to listen by JQ send method to get the value, it is silent but is wrong with this component, I tried many times, so it's component to force a callback event help us to achieve the selected date callback service processing
// date selector
. $ (. "laydate-dATE") the each (function () {
var = _this the this;
laydate.render ({
elem: _this,
value: getTime ( ' the getMonth '),
type:' month the ',
// the date selected by the user callback function
DONE: function (value, dATE, endDate) {
echartWeldmsTypeMon (Date.Year, date.month-. 1)
the console.log (value)
the console.log (DATE)
the console.log (endDate)
}
});
});

2 the last day of the month of the date of acquisition

When docking with the background is required in accordance with the start time (exact date to inquire into the case), it is necessary to obtain the day of the month selected by the user, and here I directly to the code

By traditional values to the method, the month and year to
function getSearchMonth (SelectYear, selectMonth) {
// Date format: the MM-dd-YYYY
function the formatDate (DATE) {
var myyear the Date.getFullYear = ();
var = DATE MyMonth .getMonth () +. 1;
var MyWeekDay date.getDate = ();
IF (MyMonth <10) {
MyMonth = "0" + MyMonth;
}
IF (MyWeekDay <10) {
MyWeekDay = "0" + MyWeekDay;
}
return ( myyear + "-" + MyMonth + "-" + MyWeekDay);
}
days // get a month
function getMonthDays (MyMonth) {
var monthStartDate = new new a Date (SelectYear, MyMonth,. 1);
var monthEndDate = new new a Date (SelectYear, MyMonth . 1 +,. 1);
var = Days (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24);
return days;
}
//获得本月的开始日期
var getMonthStartDate = new Date(selectYear, selectMonth, 1);
var getMonthStartDate = formatDate(getMonthStartDate);
//获得本月的结束日期
var getMonthEndDate = new Date(selectYear, selectMonth, getMonthDays(selectMonth));
var getMonthEndDate = formatDate(getMonthEndDate);
console.log(“getMonthStartDate”,getMonthStartDate)
console.log(“getMonthEndDate”,getMonthEndDate)
}

3 echat redraw

After we get the corresponding data, needs to be repainted, call the method here setOption echat on it
myChart here is var myChart = echarts.init (dom); elements acquired when the
redraw month screening and drawing //
.ajax $ ({
// request mode
type: 'POST',
the address and data transfer // transmission request
URL: '',
data: {,},
// server returns the data type
dataType: 'JSON',
Success : function (data) {
var jsonstr = [];
myChart.setOption ({// load data table
Series: [
{
name: 'number:',
type: 'bar',
barWidth: '60% ',
label: {
Normal : {
Show: to true,
position: 'Top',
textStyle: {
Color: '# 0c7bca'
}
}
},
Data: jsonstr
}
]
});
}
});

Guess you like

Origin blog.csdn.net/weixin_38136817/article/details/102724003