问题
I am trying to render a boxplot from nv.d3.js. v.1.8.5 and d3.js v.3.4.4 . I am adding the d3.js file before nv.d3.js file from the index.html .The code breaks saying boxplots.watchTransition is not a function
The following is my code
d3.selection.prototype.watchTransition = function(renderWatch){
var args = [this].concat([].slice.call(arguments, 1));
return renderWatch.transition.apply(renderWatch, args);
};
And later in the code
boxplots.watchTransition(renderWatch, 'nv-boxplot: boxplots')
.style('stroke-opacity', 1)
.style('fill-opacity', 0.75)
.delay(function(d,i) { return i * duration / data.length })
.attr('transform', function(d,i) {
return 'translate(' + (xScale(getX(d,i)) + xScale.rangeBand() * 0.05) + ', 0)';
});
回答1:
Upgrading npm to latest version worked for me.
Use following command to upgrade npm
npm i -g npm
来源:https://stackoverflow.com/questions/41103056/watchtransition-is-not-a-function-in-nv-d3-js-with-angular-js