I am trying to use d3.js to draw line chart.
function lineChart(){
...
}
function update(){
...
var lineChart = lineChart()
.x(d3.scale.linear().domain([2011, 2014]))
.y(d3.scale.linear().domain([0, 1000000]));
...
}
But the console says that Uncaught TypeError: lineChart is not a function
.
How to fix this?
You are shadowing your function.
This happens when you declare another variable/function with the same name of an upper one. What you should do is to give another name to the second one declaration just like @andlrc says in his comment.
var lineChartResult = lineChart()...
You can learn more about shadowing in here: Setting & Shadowing Properties
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With