Ensure hoverTime is a valid time range for the dygraph

pull/10616/head
Iris Scholten 2018-06-21 13:43:11 -07:00
parent 6d1e3ae82f
commit 38e64be3af
1 changed files with 10 additions and 2 deletions

View File

@ -34,9 +34,17 @@ class Crosshair extends PureComponent<Props> {
}
private get isVisible() {
const {hoverTime} = this.props
const {dygraph, hoverTime} = this.props
const timeRanges = dygraph.xAxisRange()
return hoverTime !== 0 && _.isFinite(hoverTime)
const minTimeRange = timeRanges[0]
const isBeforeMinTimeRange = hoverTime < minTimeRange
const maxTimeRange = timeRanges[1]
const isPastMaxTimeRange = hoverTime > maxTimeRange
const isValidHoverTime = !isBeforeMinTimeRange && !isPastMaxTimeRange
return hoverTime !== 0 && _.isFinite(hoverTime) && isValidHoverTime
}
private get crosshairLeft(): number {