目前我在c3.js中生成的图表的图例是颜色的矩形,我想用圆圈更改它。我怎么能这样做?
var chart = c3.generate({
data: {
columns: [
['data1', 30],
['data2', 120],
],
type : 'donut',
onclick: function (d, i) { console.log("onclick", d, i); },
onmouseover: function (d, i) { console.log("onmouseover", d, i); },
onmouseout: function (d, i) { console.log("onmouseout", d, i); },
label:true,
},
donut: {
title: "Iris Petal Width",
label: {
/*format: function(value, ratio, id)
{
return d3.format('')(value)
},*/
show: false
}
}
});
答案 0 :(得分:2)
有办法(可怕的?!)做你想做的事:
CSS更改:
.c3-legend-item-tile {
stroke-linecap: round;
}
JS改变:
const legendTiles = document.getElementsByClassName('c3-legend-item-tile');
for (const tile of legendTiles) {
const x1 = tile.getAttribute('x1');
tile.setAttribute('x2', x1);
}
请参阅this Plunker