英文:
Chartjs bar chart position
问题
我正在尝试创建一个看起来像这个设计的条形图:
我的当前图表看起来像这样(忽略2个缺失的条形元素):
我有两个问题:
-
如何将这些条形移到紧贴y轴,就像设计中一样?
-
如何删除最后一个条形元素之后多余的x轴?
查看我在绘图上制作的这张图片,可以更好地理解我在说什么:
英文:
I'm trying to make a bar chart that looks like this design:
My current chart looks like this (ignore the 2 missing bar elements):
The two questions I have are:
-
How can I shift the bars so that they're up against the y-axis like in the design?
-
How can I remove the excess x-axis after the last bar element?
Look at this picture I did on paint to get a better idea of what I'm talking about:
答案1
得分: 1
尝试在options
中将offset
设置为false:
const options = {
scales: {
x: {
offset: false,
},
},
};
当offset
等于true时,图表周围会有一些空间。如果为false,将删除该空间。
英文:
Try to set the offset
to false in the options
:
const options = {
scales: {
x: {
offset: false,
},
},
};
when offset
is equal to true, there will be some space around the chart. If it is false, the space will be removed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论