如果查看那些红色圆圈区域,则可以看到该轴在左下角溢出,并且在Y轴的顶部和X轴的末端都有轴刻度。
我为轴和c3图表配置提供的唯一自定义CSS:
.tick line {
display: none;
}
var rateConfig = {
bindto: '#line-chart',
data: {
x: 'date',
xFormat: '%m%d',
columns: [],
},
legend: {
show: false,
},
point: {
r: 4,
},
axis: {
y: {
tick: {
format: function (d) { return d + '%'; },
count: 5,
},
max: 100,
padding: {
top: 0,
bottom: 0,
},
},
x: {
type: 'timeseries',
tick: {
culling: false,
},
},
},
color: {
pattern: [colors['Rate1'], colors['Rate2'], colors['Rate3']],
},
grid: {
y: {
lines: [
{value: 25},
{value: 50},
{value: 75},
{value: 100},
],
},
},
看看这个:
http://c3js.org/reference.html#axis-x-tick-outer
您只需要像这样更改对rateConfig的调用:
....
axis: {
y: {
tick: {
format: function (d) { return d + '%'; },
count: 5,
outer: false
},
max: 100,
padding: {
top: 0,
bottom: 0
}
},
x: {
type: 'timeseries',
tick: {
culling: false,
outer: false
}
}
},
....
请注意,outer: false
x和y刻度都添加了。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句