Search code examples
angularjsd3.jsjsfiddle

t.apply is not a function


In updating this chart from D3.V3 to D3.V4 I'm hitting this error:

TypeError: t.apply is not a function

https://jsfiddle.net/horacebury/bygscx8b/16/

I can't see where to change the code as I'm not actually using a D3 function 'apply'. The Angular code has not changed and was working fine with D3.V3.


Solution

  • Instead of this (I think its a mix of d3.v3 and d3.v4):

      var xAxis = d3.select(".axis").call(d3.axisBottom(x).ticks(5));
      var xAxis = d3.select(".axis").call(d3.axisLeft(y).ticks(5));
    

    should have been this as below (since you using d3 v4)

      var yAxis = d3.axisLeft(y).ticks(5);
      var xAxis = d3.axisBottom(x).ticks(5)
    

    working code here