vue.js - 在 vuechart.js HorizontalBar 中将默认值设置为 0
问题描述
我正在制作一个 vuechart.js 水平条形图,我希望将最小值/默认值设置为 0。不过,我是个菜鸟。所以我不知道我是否正确地编写了“选项”。我尝试了一些东西,但似乎对 axys 没有任何影响。
我最近的尝试:
export default ({
extends: HorizontalBar,
props: ['agentTickets', 'options'],
mounted() {
this.renderChart({
labels: ['Ferry', 'Carlo', 'Menno', 'Scott'],
datasets: [{
label: 'Yeet', backgroundColor: 'black', data: [10, 20, 30, 40]
}]
},
{
responsive: true, maintainAspectRatio: false
},
{
scales: {
xAxes: [{
ticks: {
beginAtZero: true,
},
stacked: true
}],
yAxes: [{
ticks: {
beginAtZero: true,
},
stacked: true
}]
},
})
}
})
我的另一个尝试:
export default {
extends: HorizontalBar,
props: ['agentTickets', 'options'],
mounted() {
this.renderChart({
labels: ['Ferry', 'Carlo', 'Menno', 'Scott'],
scales: {
xAxes: [{
ticks: {
beginAtZero: true,
},
stacked: true
}],
yAxes: [{
ticks: {
beginAtZero: true,
},
stacked: true
}]
},
datasets: [
{label: 'Yeet', backColor: 'black', data: [10, 20, 30, 40]}
]
}, {responsive: true, maintainAspectRatio: false})
}
}
还有一个只是因为!
export default {
extends: HorizontalBar,
props: ['agentTickets', 'options'],
mounted() {
this.renderChart({
labels: ['Ferry', 'Carlo', 'Menno', 'Scott'],
options: {
scale: {
xAxes: [{
ticks: {
min: 0,
},
stacked: true
}],
yAxes: [{
ticks: {
min: 0,
},
stacked: true
}]
}
},
datasets: [
{label: 'Yeet', backdropColor: 'black', data: [10, 20, 30, 40]}
]
}, {responsive: true, maintainAspectRatio: false})
}
}
(我也尝试过使用 beginAtZero 的最新示例)
以上是当前结果,我想要的是一个从 0 开始的图表,而不是 10。
解决方案
固定的。显然,选项已经创建(其中定义了响应和维护AspectRatio)。只需复制那些卷曲护腕之间的刻度就可以了!
推荐阅读
- python - 在 Numpy 中存储大量大整数的最佳方法
- python - 如果值重复超过 10 秒,我想打印时间
- c# - 在特定委托类型的接口中实现 T 参数约束的方法
- r - 将 SVM 分类器应用于看不见的新数据时,我遇到了错误消息。(R 用户)
- heroku-cli - 一分钟不活动后,与测功机内转发端口的连接关闭
- python - 为什么python超类构造函数调用失败?
- java - 我在连接到 Oracle SQL Developer HR 数据库时遇到问题
- flutter - 如何在颤动中设置具有背景和通知支持的简单音频播放器
- python - 如何最好地处理 MongoEngine 中的不同文档模式?
- postgresql - Postgresql:减号运算符不能与参数一起使用吗?只有硬编码的值?