【发布时间】:2019-01-30 06:18:28
【问题描述】:
我使用以下 c3 代码构建图表
c3.generate({
bindto: '#total_revenue',
data: {
x : 'x',
columns: [
['Total Revenue',1.7,1.7,2.0,2.1,0],
['x','Less than 10M', '10M - 20M','20M - 40M','40M - 100M','More than 100M'],
],
type: 'bar',
labels:{
format:{
'Total Revenue': function (v, id, i, j){
return (v);
}
}
},
colors: {
'Total Revenue': function(d) {
if(d.value > 3){
return '#0075BD';
}
if(d.value > 2){
return '#B0D1F2';
} else {
return '#F7A71A';
}
}
},
},
size: {
height: 220,
},
axis: {
rotated: true,
x: {
type: 'category',
tick: {
rotate: 75,
multiline: false
},
},
y: {
min: 1,
max: 4,
tick: {
values: [1, 2, 3, 4]
}
},
},
legend: {
show: false
},
});
这向我显示了以下输出响应。
所以现在我可以看到我想看到的结果。但是栏中的标签颜色不正确。我需要将条形颜色设为黄色、蓝色等,而需要将条形值标签保持为黑色。
这方面的任何帮助都会有帮助!谢谢
JS FIDDLE:https://jsfiddle.net/k5acudeg/4/
【问题讨论】: