如何删除c3js折线图中的轴线溢出
How to remove axis line overflow in c3js line graph
如果你看一下那些红色圆圈区域,你会发现轴在左下角溢出,并且在 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
}
}
},
....
请注意在 x 和 y 刻度上添加了 outer: false
。
如果你看一下那些红色圆圈区域,你会发现轴在左下角溢出,并且在 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
}
}
},
....
请注意在 x 和 y 刻度上添加了 outer: false
。