Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/lineChart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
y: 'value',
margin: {
left: 200
}
},
ready: function() { console.log('ready'); },
renderStart: function() { console.log('renderStart'); },
renderEnd: function() { console.log('renderEnd'); },
postUpdate: function() { console.log('postUpdate'); }
}),
document.getElementById('lineChart')
);
Expand Down
10 changes: 9 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export default class NVD3Chart extends React.Component {
*/
componentDidUpdate() {
this.renderChart();
if (this.props.postUpdate) { // trigger callback (as nvd3 chart.update does not do this)
this.props.postUpdate(this.chart);
}
}

/**
Expand Down Expand Up @@ -86,7 +89,12 @@ export default class NVD3Chart extends React.Component {
// Update the chart if the window size change.
// Save resizeHandle to remove the resize listener later.
if(!this.resizeHandler)
this.resizeHandler = nv.utils.windowResize(this.chart.update);
this.resizeHandler = nv.utils.windowResize(function() {
this.chart.update();
if (this.props.postUpdate) { // trigger callback (as nvd3 chart.update does not do this)
this.props.postUpdate(this.chart);
}
}.bind(this));

// PieCharts are an special case. Their dispacher is the pie component inside the chart.
// There are some charts do not feature the renderEnd event
Expand Down