d3 Missing first value in array

后端 未结 1 545
北海茫月
北海茫月 2020-12-21 15:00

I think I have a question that\'s pretty simple but I can\'t figure it out. My array is as follows:

var wordcount = [1, 2, 3, [{name: \'A\', values: [0,1,3,9         


        
相关标签:
1条回答
  • 2020-12-21 15:52

    You need to select the non-existent elements as well for the selections to work properly. That is, your code should be

    d3.select("#tooltippos").selectAll("div")                
          .data(d[3])
          .enter()
          .append("div")
          .text(function(d) { return d.name; });
    

    At the moment, the selection you're matching data against contains only the one element ("#tooltippos"), which is matched with the first element of the data. Hence, this is not in the enter selection and not drawn.

    0 讨论(0)
提交回复
热议问题