How to change the labels to the image (icon) in bar chart.js

前端 未结 2 2057
借酒劲吻你
借酒劲吻你 2020-12-17 05:21

Help me, please. How to change the labels to the image (icon) in bar chart.js ? I mean, change from this change labels: \"LifeWall_files/logo.png\",\"Bodily Functions\",\"S

2条回答
  •  忘掉有多难
    2020-12-17 05:34

    The easiest way to do this would be to get a font that includes these icons and then set the font family for the ticks

      ...
      options: {
        scales: {
          xAxes: [{
            ticks: {
              fontFamily: 'FontAwesome'
            }
          }]
        }
      }
    };
    

    and then specify the appropriate character codes in your labels

    labels: ["\uf24e", "\uf1b9", "\uf242", "\uf0fc", "\uf236"],
    

    With the FontAwesome CSS, the above would give you

提交回复
热议问题