Time series annotations need millsecs, not Date objects #782

Open
raybellis opened this Issue Sep 30, 2016 · 4 comments

Projects

None yet

3 participants

@raybellis

The x value associated with an annotation in a time series needs to be the numeric value of the timestamp, not the Date object itself. Dygraphs knows how to deal with the latter for normal data sets, but not for annotations.

The cause is the string concatenation used to produce the compound key that indexes the layout module's set of annotated points.

https://github.com/danvk/dygraphs/blob/2.0.0-dev1/src/dygraph-layout.js#L330

@danvk
Owner
danvk commented Sep 30, 2016

Is this a bug report or a request for an API change?

@raybellis

At the very least it needs a documentation change, or alternately have the layout module perform an explicit conversion to milliseconds if the passed x point is a Date object.

@danvk
Owner
danvk commented Oct 1, 2016

Is there something specific you can point to in the documentation that's incorrect?

@SantanMaddi

When the x-axis is "date", annotation's x value cannot be a date object. Instead timestamp (date in epoch) must be used in the annotation's x value.
Eg: below would not work

ann= {
   x: new Date()
}

instead use

ann = {
   x: new Date().getTime()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment