Remove need for annotationsRef

pull/10616/head
Andrew Watkins 2018-04-09 20:17:42 -07:00
parent 044dcfc7fd
commit f6165b9e4b
3 changed files with 10 additions and 14 deletions

View File

@ -16,18 +16,18 @@ const Annotation = ({
<div> <div>
{annotation.startTime === annotation.endTime ? ( {annotation.startTime === annotation.endTime ? (
<AnnotationPoint <AnnotationPoint
lastUpdated={lastUpdated}
annotation={annotation}
mode={mode} mode={mode}
dygraph={dygraph} dygraph={dygraph}
annotation={annotation}
lastUpdated={lastUpdated}
staticLegendHeight={staticLegendHeight} staticLegendHeight={staticLegendHeight}
/> />
) : ( ) : (
<AnnotationSpan <AnnotationSpan
lastUpdated={lastUpdated}
annotation={annotation}
mode={mode} mode={mode}
dygraph={dygraph} dygraph={dygraph}
annotation={annotation}
lastUpdated={lastUpdated}
staticLegendHeight={staticLegendHeight} staticLegendHeight={staticLegendHeight}
/> />
)} )}

View File

@ -24,7 +24,9 @@ class Annotations extends Component {
} }
componentDidMount() { componentDidMount() {
this.props.annotationsRef(this) this.props.dygraph.updateOptions({
drawCallback: this.heartbeat,
})
} }
heartbeat = () => { heartbeat = () => {
@ -94,7 +96,6 @@ Annotations.propTypes = {
dygraph: shape({}), dygraph: shape({}),
mode: string, mode: string,
isTempHovering: bool, isTempHovering: bool,
annotationsRef: func,
handleUpdateAnnotation: func.isRequired, handleUpdateAnnotation: func.isRequired,
handleDismissAddingAnnotation: func.isRequired, handleDismissAddingAnnotation: func.isRequired,
handleAddingAnnotationSuccess: func.isRequired, handleAddingAnnotationSuccess: func.isRequired,

View File

@ -152,7 +152,6 @@ class Dygraph extends Component {
colors: this.lineColors, colors: this.lineColors,
series: this.colorDygraphSeries, series: this.colorDygraphSeries,
plotter: isBarGraph ? barPlotter : null, plotter: isBarGraph ? barPlotter : null,
drawCallback: this.annotationsRef.heartbeat,
} }
dygraph.updateOptions(updateOptions) dygraph.updateOptions(updateOptions)
@ -270,10 +269,8 @@ class Dygraph extends Component {
} }
handleMouseMove = e => { handleMouseMove = e => {
if (this.props.handleSetHoverTime) { const newTime = this.eventToTimestamp(e)
const newTime = this.eventToTimestamp(e) this.props.handleSetHoverTime(newTime)
this.props.handleSetHoverTime(newTime)
}
this.setState({isHoveringThisGraph: true}) this.setState({isHoveringThisGraph: true})
} }
@ -287,8 +284,6 @@ class Dygraph extends Component {
this.setState({isHidden: false}) this.setState({isHidden: false})
} }
handleAnnotationsRef = ref => (this.annotationsRef = ref)
handleReceiveStaticLegendHeight = staticLegendHeight => { handleReceiveStaticLegendHeight = staticLegendHeight => {
this.setState({staticLegendHeight}) this.setState({staticLegendHeight})
} }
@ -314,7 +309,6 @@ class Dygraph extends Component {
<div className="dygraph-addons"> <div className="dygraph-addons">
<Annotations <Annotations
dygraph={this.dygraph} dygraph={this.dygraph}
annotationsRef={this.handleAnnotationsRef}
staticLegendHeight={staticLegendHeight} staticLegendHeight={staticLegendHeight}
/> />
<DygraphLegend <DygraphLegend
@ -377,6 +371,7 @@ Dygraph.defaultProps = {
overrideLineColors: null, overrideLineColors: null,
dygraphRef: () => {}, dygraphRef: () => {},
onZoom: () => {}, onZoom: () => {},
handleSetHoverTime: () => {},
staticLegend: { staticLegend: {
type: null, type: null,
}, },