gpt4 book ai didi

javascript - 水平 ChartJS 条形图的垂直间距

转载 作者:行者123 更新时间:2023-12-04 16:11:00 25 4
gpt4 key购买 nike

我希望水平条形图中的条形之间有更多间距。它在移动设备上看起来很糟糕,在桌面浏览器上几乎无法接受。我怎样才能做到这一点?

ChartJs 版本:2.4.0

    function renderBarChart(chartDomID, title, labels, dataPoints, barColor) {
var ctx = document.getElementById(chartDomID).getContext("2d");

var chart = new Chart(ctx, {
type: 'horizontalBar',
data: {
labels: labels,
datasets: [
{
label: title,
data: dataPoints,
fill: false,
pointBorderColor: barColor,
backgroundColor: barColor,
borderColor: barColor
}
]
},
options: {
responsive: true,
scales: {
yAxes: [{
display: true,
ticks: {
// Suggest to start the y-axis at 0, if ChartJS thinks it makes sense.
suggestedMin: 0
}
}]
},
legend: {
display: false
}
}
});

移动 View Mobile View

桌面 View Desktop View

最佳答案

您必须在此处添加宽度和高度作为示例。

<canvas id="myChart" width="700" height="900"></canvas>

关于javascript - 水平 ChartJS 条形图的垂直间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41602598/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com