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

给你一囗甜甜゛ 提交于 2019-12-03 21:27:50

问题


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","Sleep"

to this bottom icons


回答1:


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



来源:https://stackoverflow.com/questions/36979474/how-to-change-the-labels-to-the-image-icon-in-bar-chart-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!