Fix legend hover bug
parent
f6e6c90311
commit
6587d1dcac
|
@ -236,6 +236,7 @@ class Dygraph extends Component {
|
|||
const newTime = this.eventToTimestamp(e)
|
||||
this.props.onSetHoverTime(newTime)
|
||||
}
|
||||
|
||||
this.setState({isHoveringThisGraph: true})
|
||||
}
|
||||
|
||||
|
@ -243,23 +244,13 @@ class Dygraph extends Component {
|
|||
if (this.props.onSetHoverTime) {
|
||||
this.props.onSetHoverTime(NULL_HOVER_TIME)
|
||||
}
|
||||
|
||||
this.setState({isHoveringThisGraph: false})
|
||||
}
|
||||
|
||||
handleHideLegend = e => {
|
||||
const {top, bottom, left, right} = this.graphRef.getBoundingClientRect()
|
||||
|
||||
const mouseY = e.clientY
|
||||
const mouseX = e.clientX
|
||||
|
||||
const mouseInGraphY = mouseY <= bottom && mouseY >= top
|
||||
const mouseInGraphX = mouseX <= right && mouseX >= left
|
||||
const isMouseHoveringGraph = mouseInGraphY && mouseInGraphX
|
||||
|
||||
if (!isMouseHoveringGraph) {
|
||||
handleHideLegend = () => {
|
||||
this.setState({isHidden: true})
|
||||
}
|
||||
}
|
||||
|
||||
getLineColors = () => {
|
||||
return [...(this.props.overrideLineColors || LINE_COLORS)]
|
||||
|
|
Loading…
Reference in New Issue