I am currently working on a function in d3 that aims to evaluate the "time" of my data and determine if it falls within specific time intervals. This will then allow me to filter the data accordingly.
//begin with a function that checks if the time for each data point is within specified time intervals
function timeInterval(data, start, end) {
var time = data.Time
if (start <= time <= end) {
return "inline";
} else {
return "none";
};
}
//set the visibility of points to either inline or none based on time interval
function updateTime(value) {
d3.selectAll(".events")
.style("display", timeInterval("20:00", "24:00"));
}
//Toggle update function when radio button is selected
d3.selectAll("#timeFilterRadioButton").on("change", function() {
updateTime()
});
My issue arises when attempting to call timeInterval
with the start and end parameters. The problem occurs when I try to input
timeInterval("20:00", "24:00")
, as it results in an undefined time variable. Surprisingly, omitting any parameters allows the function to execute successfully:
function updateTime(value) {
d3.selectAll(".events")
.style("display", timeInterval); //when calling timeInterval like this, the console.log shows the data's time property
}
Can anyone assist in identifying where my mistake lies?