javascript - Confused about D3.js : SVGAnimatedLengthList is not a function error -


i trying make bar plot object using d3.js can seem work.

i defined x-scale this:

    var barplot = function(){             this.x = d3.linear().....      ... 

and try use scale this

    this.bar.append("text")         .attr("x", function(d){              return this.x(d) + 5;         }  

however when run error ->

    typeerror: svganimatedlengthlist not function (evaluating 'this.x(d)' ). 

and have no idea why since work if change this.x var x.

this refers 2 different things. inside attribute function, this refers current dom element (see the documentation). if need refer outer this, save in variable (e.g. var = this) , use that.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -