bar.append("rect")
.attr("width", x)
.attr("height", barHeight - 1);
bar.append("text")
.attr("x", function(d) { return x(d) - 3; })
.attr("y", barHeight / 2)
.attr("dy", ".35em")
.text(function(d) { return d; });
Hi, I am new to charting with D3. Now I am trying out many tutorials from d3.com. Now I get the 2 errors displayed in the title when trying to make a svg bar chart. Is there anyone who could help me?
你好,我对D3的制图很陌生。现在我正在尝试许多来自d3.com的教程。现在,当我试图创建svg条形图时,我得到了标题中显示的两个错误。有谁能帮助我吗?
1 个解决方案
#1
0
I ran into a similar problem when I was setting my width with a value that was NaN
. You need to check that you are setting the x
variable correctly. Try pasting console.log(x)
above this line:
我在设置宽度值为NaN时遇到了类似的问题。您需要检查您是否正确地设置了x变量。尝试粘贴console.log(x)上面:
.attr("width", x)
and checking your console in your browser's dev tools.
并在浏览器的开发工具中检查控制台。
#1
0
I ran into a similar problem when I was setting my width with a value that was NaN
. You need to check that you are setting the x
variable correctly. Try pasting console.log(x)
above this line:
我在设置宽度值为NaN时遇到了类似的问题。您需要检查您是否正确地设置了x变量。尝试粘贴console.log(x)上面:
.attr("width", x)
and checking your console in your browser's dev tools.
并在浏览器的开发工具中检查控制台。