chartjs-plugin-datalabels: Font Awesome icons not rendering
I’m trying to show font awesome (4.7) icons as data labels, which seems like it should work because other unicode characters in other font families seem to work ok. Is there something else I should be doing besides the following?
this.options = {
plugins: {
datalabels: {
color: 'white',
display: context => {
return context.dataset.data[context.dataIndex] > 15;
},
font: {
weight: 'bold',
family: 'FontAwesome',
style: 'normal'
},
formatter: (value, context) => {
return `\\u${context.dataset.icon_code}`;
}
}
},
...
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (6 by maintainers)
fontshould be underdatalabels, in your file it’s underpluginsandfont.sizeshould be a number, not a string (same forlineHeight).Yes, however for this app the datasets are being dynamically generated, and for various reasons the associated icon codes are only stored in the db as
f0c3(for example). As a result I need to build the unicode values at runtime.Ok, there must be other issues going on in my code then because as you showed it obviously should work just fine. My apologies, and thank you for a wonderful plugin!