I'm trying to filter some data for a chart with date-sensitive information
if I select a date range, with no date, that would return an empty array of results, the application doesn't crash, but as soon as there is data withing the range of the FilterDate and gte (hence, there are points made after the filterDate), then the application crashes on that line.
axisChange : function(){
//set date from period
var filterDate = new Date();
switch(this.get('selectedPeriod'))
{
case 'week':
filterDate.setMonth(filterDate.getMonth()-1);
break;
case 'day':
filterDate.setDate(filterDate.getDate()-7);
break;
case 'hour':
filterDate.setDate(filterDate.getDate()-1);
break;
}
/*var chart = jQuery("#chart").data("kendoChart");
chart.setOptions({ categoryAxis: { baseUnit: this.get('selectedCategory') }});*/
dataSource.filter({
"field": "CreatedAt",
"operator": "gt",
"value": filterDate
});
}
EDIT
ON closer inspection this is an issue with dataSource.filter, specific to the date, if I try to use another filter like:
dataSource.filter({
"field": "Note",
"operator": "contains",
"value": 'e'
});
everything is updated okay according to the filter.
FOR DETAILED CODE, PLEASE VISIT GITHUB REPO
https://github.com/Danelund/NeuroHelper/blob/master/NeuroHelper/scripts/app.js
My first thought about this problem is about date format. Place a breakpoint before
dataSource.filter
line and check what is the date format. Probably you should also convert this date object to string using some kind ofdate.toString()
function.