Adding FontAwesome icons to a D3 graph

后端 未结 9 2208
既然无缘
既然无缘 2020-11-27 12:07

I am trying to set an icon with FontAwesome instead of text in my D3 nodes. This is the original implmentation, with text:

g.append(\'svg:text\')
    .attr(\         


        
9条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 12:33

    Font awesome 4.x versions are not supporting if we use as follows

    svg.append('text')
       .attr('x', 15)
       .attr('y', -17)
       .attr('fill', 'black')
       .attr('font-family', 'FontAwesome')
       .attr('font-size', function (d) { return '20px' })
       .text(function (d) { return '\uf2b9' });
    

    so replace this

    .attr('font-family', 'FontAwesome')
    

    with

    .attr("class", "fa")
    

    Hope it helps for FA 4.x

提交回复
热议问题