How do I display an icon at a point on a line chart using d3.js

后端 未结 2 1387
孤城傲影
孤城傲影 2021-01-24 07:46

I am creating a simple line chart using d3, ... but instead of the standard points along the path, I\'d like to display a fon-awesome icon such as \'fa-arrow-up\'.

I\'ve

2条回答
  •  无人共我
    2021-01-24 08:12

    Under the hood, FontAwesome and libraries like it are just setting the CSS content of their tag to a unicode character from their font family.

    If you inspect an icon ::before you'll see something like this:

    .fa-camera-retro:before {
      content: "\f083";
    }
    

    In SVG this would be equal to:

    
    

    Translating this into d3 then becomes:

    
    
    
    

    Here's a similar answer I gave about Highcharts.

    See d3.js example here.

    enter image description here

提交回复
热议问题