crossfilter: how to use crossfilters for start date and end date columns simultaneously

后端 未结 2 418
轮回少年
轮回少年 2020-12-21 13:10

I have a similar situation as in this question . Considering the same dataset, how can I perform this functionality through crossfilters. I am new to dc.js and crossfilter.

2条回答
  •  难免孤独
    2020-12-21 13:35

    The solution is quite simple really. Create two dimensions:

    1. by start time -startTimeDim
    2. by end time - endTimeDim

    Now, to filter out intervals that intersect a given range - rangeStart and rangeEnd, apply the following:

    1. startTimeDim.filter([-Infinity, rangeEnd])
    2. endTimeDim.filter([rangeStart, Infinity])

    This basically filters out intervals that start before the range ends & end before the range starts.

提交回复
热议问题