diff --git a/src/index.js b/src/index.js index 878a596..0127a4c 100644 --- a/src/index.js +++ b/src/index.js @@ -36,6 +36,9 @@ export default class NVD3Chart extends React.Component { */ componentDidUpdate() { this.renderChart(); + if (this.props.renderEnd) { // trigger callback (as nvd3 chart.update does not do this) + this.props.renderEnd(this.chart); + } } /** @@ -76,7 +79,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.renderEnd) { // trigger callback (as nvd3 chart.update does not do this) + this.props.renderEnd(this.chart); + } + }.bind(this)); // PieCharts are an special case. Their dispacher is the pie component inside the chart. dispacher = (this.props.type === 'pieChart') ? this.chart.pie : this.chart; diff --git a/src/utils.js b/src/utils.js index e0a64e6..da9d1fe 100644 --- a/src/utils.js +++ b/src/utils.js @@ -91,7 +91,9 @@ export function bindFunctions(o, context) { out = Array.isArray(o) ? [] : {}; for (key in o) { v = o[key]; - if(typeof v === 'object' && v !== null && v.type !== 'function') { + if(v == null) { + continue; + } else if(typeof v === 'object' && v !== null && v.type !== 'function') { out[key] = bindFunctions(v, context); } else if(v.type === 'function'){ out[key] = context[v.name];