Search code examples
javascriptkeen-io

Why does keen.io object timeline default days to one day?


Quick question here hopefully. I have outlined a small document which builds a chart for a given "defined_range". I have set this to 10. I am also building the chart for "daily" intervals. Because of all this and the fact that I am using the "this_10_days" as the timeframe, I should be seeing data across the last 10 days, for each day.

As you can see (jsfiddle.net/L1j08tr7/1/), the object is defaulting to December 31. Clearly I am missing something here. Any help at approaching this issue would be greatly welcomed as I cannot seem to find anything indicating this type of behavior within their documentation (https://keen.io/docs/data-analysis/timeframe/)

Another approach would be to pass dates to each event: jsfiddle.net/L1j08tr7/2/

Edit: Specific days charted here: sfiddle.net/qarxnxk1/2/


Solution

  • Since the start date is the same every time you generate your random data, it will be graphed on the same day. I just added one line to change the start date each time you generate new data (line 26): date_begin.setDate(i),

    for (i = 0; i < days; i++)
        {  
            date_begin.setDate(i);
            chart_data.push({
                "value": genValue(),
                "interval":interval,
                "timeframe":
                {
                    "start":date_begin.toISOString().replace('Z','') + timezone_offset,
                    "end":date_end.toISOString().replace('Z','') + timezone_offset
                }
            });
        }
    

    and I think that should give you what you are looking for. Here is my result: http://jsfiddle.net/qarxnxk1/