score:2

Accepted answer

just three problems:

  1. you are repeating the enter() function:

    var f_sel = svgtopitems.selectall("g")
        .data(topdata,function(d){ return d.item_name; }).enter();
    //this is an enter selection...
    
    var f_ent = f_sel.enter().append("g");
    //and you have enter() again here
    

    so, remove the first enter: f_sel should be just the data-binding selection.

  2. move your merged selection to before appending the rectangles

  3. your translate has an extra parenthesis:

    return "translate( 0, "+ i*25 +")" + ")";
    

with that problems corrected, this is your updated fiddle: https://jsfiddle.net/utf5hva2/


Related Query