需要重写c3js函数generateDrawBar并提供获取圆角的逻辑,一般c3js路径元素由四个点组成,对应条形的四个角。
现在您需要提供逻辑,在标准杆的左上角和右上角有多个点,以平滑杆角。
还有几种情况:-
1) 堆积条形图的圆角。
2) 负值的圆角,指向下方或相反方向的条形。
rounded corner bars jsFiddle
圆角 c3js 条形图快照
var chart = c3.generate({
bindto: '#chart',
padding: {
left: 200,
right: 100,
top: 20,
bottom: 20
},
data: {
x: 'x',
labels: true,
columns: [
['data1',40, 30, 200, 100, 400, 150, 250, 50, 100, 250,67,190,48,123,76,54,254],
['x','Travel and Hospitality','Life Science and Pharma', 'Saas and Cloud', 'Hi-tech Manufacturing', 'Software', 'Business Services', 'Govt/Public Sector', 'Energy', 'Manufacturing', 'Healthcare','Media','Internet','Retail','Biotech','Automobile','Consumer Goods','Financial Services']
],
type: 'bar'
},
axis: {
rotated: true,
x: {
type: 'category',
tick:{
multiline: false
}
}
},
legend: {
show: false
},
tooltip: {
show: false
},
bar: {
width: {
ratio: .7
},
spacing: 2
}
});