简体   繁体   English

错误:的值无效 <rect> 属性width =“ NaN” 6d3.v3.min.js:1错误:的值无效 <text> 属性x =“ NaN”

[英]Error: Invalid value for <rect> attribute width=“NaN” 6d3.v3.min.js:1 Error: Invalid value for <text> attribute x=“NaN”

    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. 嗨,我是D3图表的新手。 Now I am trying out many tutorials from d3.com. 现在,我正在尝试d3.com提供的许多教程。 Now I get the 2 errors displayed in the title when trying to make a svg bar chart. 现在,当尝试制作svg条形图时,标题中显示了2个错误。 Is there anyone who could help me? 有谁可以帮助我吗?

I ran into a similar problem when I was setting my width with a value that was NaN . 我将宽度设置为NaN时遇到了类似的问题。 You need to check that you are setting the x variable correctly. 您需要检查是否正确设置了x变量。 Try pasting console.log(x) above this line: 尝试将console.log(x)粘贴到此行上方:

.attr("width", x)

and checking your console in your browser's dev tools. 并在浏览器的开发工具中检查控制台。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 d3.js arc.centroid(d):错误:的值无效 <text> 属性transform =“ translate(NaN,NaN)” - d3.js arc.centroid(d) : Error: Invalid value for <text> attribute transform=“translate(NaN,NaN)” 错误:d3.v4.min.js:3错误: <rect> 属性宽度:预期长度,“ NaN” - Error: d3.v4.min.js:3 Error: <rect> attribute width: Expected length, “NaN” 错误:的值无效 <circle> dimple.js中的属性cx =“ NaN” - Error: Invalid value for <circle> attribute cx=“NaN” in dimple.js C3js和D3js错误:的值无效 <g> 属性transform =“ translate(0,NaN)” - C3js and D3js Error: Invalid value for <g> attribute transform=“translate(0,NaN)” d3.js:5942错误:的值无效 <g> 属性transform =“ translate(NaN,0)” - d3.js:5942 Error: Invalid value for <g> attribute transform=“translate(NaN,0)” 无效的值 <circle> 使用D3.js属性cx =“NaN” - Invalid value for <circle> attribute cx=“NaN” using D3.js D3:x轴上的日期名称:的值无效 <text> 属性x =“ NaN” - D3: Day names on x-axis: Invalid value for <text> attribute x=“NaN” 错误:无效的值 <g> attribute transform =“scale(NaN)translate(NaN,NaN)” - Error: Invalid value for <g> attribute transform=“scale(NaN) translate(NaN, NaN)” Highcharts导航器错误:无效的负值 <rect> 属性宽度 - Highcharts navigator error: Invalid negative value for <rect> attribute width 错误: <rect> 属性y:预期长度“ NaN”。 D3 JS - Error: <rect> attribute y: Expected length, “NaN”. D3 JS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM