From f6165b9e4b071b9edfe0b5d163bc16e7d038532d Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Mon, 9 Apr 2018 20:17:42 -0700 Subject: [PATCH] Remove need for annotationsRef --- ui/src/shared/components/Annotation.js | 8 ++++---- ui/src/shared/components/Annotations.js | 5 +++-- ui/src/shared/components/Dygraph.js | 11 +++-------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ui/src/shared/components/Annotation.js b/ui/src/shared/components/Annotation.js index 40f87f05ba..c3b5ffd351 100644 --- a/ui/src/shared/components/Annotation.js +++ b/ui/src/shared/components/Annotation.js @@ -16,18 +16,18 @@ const Annotation = ({
{annotation.startTime === annotation.endTime ? ( ) : ( )} diff --git a/ui/src/shared/components/Annotations.js b/ui/src/shared/components/Annotations.js index bded63a866..f129249f97 100644 --- a/ui/src/shared/components/Annotations.js +++ b/ui/src/shared/components/Annotations.js @@ -24,7 +24,9 @@ class Annotations extends Component { } componentDidMount() { - this.props.annotationsRef(this) + this.props.dygraph.updateOptions({ + drawCallback: this.heartbeat, + }) } heartbeat = () => { @@ -94,7 +96,6 @@ Annotations.propTypes = { dygraph: shape({}), mode: string, isTempHovering: bool, - annotationsRef: func, handleUpdateAnnotation: func.isRequired, handleDismissAddingAnnotation: func.isRequired, handleAddingAnnotationSuccess: func.isRequired, diff --git a/ui/src/shared/components/Dygraph.js b/ui/src/shared/components/Dygraph.js index 8b8a1d4501..36405bd20e 100644 --- a/ui/src/shared/components/Dygraph.js +++ b/ui/src/shared/components/Dygraph.js @@ -152,7 +152,6 @@ class Dygraph extends Component { colors: this.lineColors, series: this.colorDygraphSeries, plotter: isBarGraph ? barPlotter : null, - drawCallback: this.annotationsRef.heartbeat, } dygraph.updateOptions(updateOptions) @@ -270,10 +269,8 @@ class Dygraph extends Component { } handleMouseMove = e => { - if (this.props.handleSetHoverTime) { - const newTime = this.eventToTimestamp(e) - this.props.handleSetHoverTime(newTime) - } + const newTime = this.eventToTimestamp(e) + this.props.handleSetHoverTime(newTime) this.setState({isHoveringThisGraph: true}) } @@ -287,8 +284,6 @@ class Dygraph extends Component { this.setState({isHidden: false}) } - handleAnnotationsRef = ref => (this.annotationsRef = ref) - handleReceiveStaticLegendHeight = staticLegendHeight => { this.setState({staticLegendHeight}) } @@ -314,7 +309,6 @@ class Dygraph extends Component {
{}, onZoom: () => {}, + handleSetHoverTime: () => {}, staticLegend: { type: null, },