Thibaud Colas - @thibaud_colas
Slides: thib.me/talks/
This approach is inspired by a blog post from Nicolas Hery. It has also been taken for a spin by the folks at sift science.
Use this approach if you value the ability to use the chart outside of React and idiomatic D3 code over the performance gains you'll have by using React's virtual DOM for SVG.
export default class ProgressChart extends Chart {
create() {
const svg = super.createRoot();
}
update(state) {
const scales = this._scales(state.domain);
this._drawBar(scales, state.data);
}
componentDidMount() {
this.createChart();
window.addEventListener('resize', this.createChart);
},
shouldComponentUpdate() {
if (this.state.chart) {
this.state.chart.update(this.getChartState());
}
return false;
},
componentWillUnmount() {
this.state.chart.destroy();
window.removeEventListener('resize', this.createChart);
},