[英]How change chart height in chart.js
我将创建一个水平条形图。
问题是我无法更改图表的高度(而不是条形图)
我创建了数据和选项配置:
this.data = {
labels: ['SAF/TGA'],
datasets: [
{
label: 'SAF/TGA',
backgroundColor: '#9CBB65',
borderColor: '#72242',
data: [28],
}
],
}
this.options= {
responsive: true,
maintainAspectRatio: false
scales: {
yAxes: [{
barThickness: 5,
gridLines:{
display: true,
offsetGridLines: false
}
}],
xAxes: [{
gridLines:"rgba(0, 0, 0, 0)"
}]
},
}
}
然后我用高度和宽度选项用HTML调用图表:
<p-chart type="horizontalBar" [data]="data" [options]="options" width="10" height="10px">
</p-chart>
这就是我会
靠近轴的轴。
尝试更改选项以禁用宽高比
var chart = new Chart('bar_charty', {
type: 'bar',
data: {},
options: {
maintainAspectRatio: false,
}
});
当您增大包含元素的高度时,这应该缩放您的图表。
您可能还需要像这样为图表创建一个容器,并在父级中设置其高度。
<div style="height: 300px">
<canvas id="chart"></canvas>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.