I want my bar graph to have different coloured versions of the same icon for the legend tiles. I am currently using font-awesome 5 for text in my HTML document but I do not mind using other icon libraries if I must (as long as it's free). At the moment my graph has squares for the legend tiles as that is the default. In font-awesome the icon I want is class="fa fa-bar-chart". The class for the legend tile is called .c3-legend-item-tile
I tried code from Use Font Awesome Icons in CSS but the code there didn't help change the legend tiles. Neither did Using Font Awesome icon for bullet points, with a single list item element
I don't want my icons to float above the bar chart like the example from Adding icons to bar charts made using c3js I just want the tiles to change from the default square to an icon.
https://jsfiddle.net/SharonM/k49gbs13/25/ has a rough example of what I've tried. (Labels show what I want the actual tiles to look like but I do not actually want labels)
.c3-chart-text .c3-text {
font-family: 'FontAwesome';
}
.c3-legend-item-tile::before {
font-family: 'FontAwesome';
content: '\uf080'!important;
font-weight: 900!important;
margin: 0 5px 0 -15px!important;
}
I've tried before and after and also just the class itself.
Update:
I also tried:
d3.select(string).insert('div', '.chart').attr('class', 'legend').selectAll('span')
.data(this.allIDs)
.enter().append('span')
.attr('data-id', function (id) { return id; })
.html(function (id) { return '<i class="fa fa-bar-chart" aria-hidden="true"> </i>'+ id; })
.each(function (id) {
d3.select(this).style('background-color', chart.color(id));
})
.on('mouseover', function (id) {
chart.focus(id);
})
.on('mouseout', function (id) {
chart.revert();
})
.on('click', function (id) {
chart.toggle(id);
});
where string is the name of my container class but that did not do what I wanted at all. It created new 'legends' on the side with the icon I wanted but that bypassed my onclick checks when toggling which I could re-implement in this function but it just looks really bad. I'd rather the original little square was replaced by the icon.