I'm trying to use d3.js inside of a React app.
this.animateFirstStep gets called fine in componentDidMount but inside animateFirstStep, this.animateSecondStep never gets called.
import React, { Component, PropTypes } from 'react';
var d3 = require("d3");
export default class App extends Component {
constructor() {
super();
this.state = {};
}
animateFirstStep() {
d3.select(this)
.transition()
.delay(0)
.duration(1000)
.attr("r", 10)
this one does not get called
.on("end", this.animateSecondStep);
}
animateSecondStep() {
console.log("hello");
d3.select(this)
.transition()
.duration(1000)
.attr("r", 40);
}
componentDidMount() {
this.sampleSVG = d3.select(".d3")
.append("svg")
.attr("width", 100)
.attr("height", 100);
this.sampleSVG.append("circle")
.style("stroke", "gray")
.style("fill", "white")
.attr("r", 40)
.attr("cx", 50)
.attr("cy", 50)
.on("mouseover", function(){d3.select(this).style("fill", "aliceblue");})
.on("mouseout", function(){d3.select(this).style("fill", "white");})
this gets called fine
.on("mousedown", this.animateFirstStep);
}
render() {
return (<div className="d3"></div>);
}
}
.on("end", this.animateSecondStep.bind(this));Uncaught TypeError: this.getAttribute is not a function at App.<anonymous> (bundle.js:40083) at App.tween (bundle.js:40150) at start (bundle.js:39918) at schedule (bundle.js:39859) at timerFlush (bundle.js:39724) at wake (bundle.js:39734)