javascript - 设置高度时Chartjs条形图模糊
问题描述
我正在使用 chartjs 2.7.3,在设置包含画布的 div 的大小时出现问题,图像模糊且字母不可见,如下面的屏幕截图:
<div class="stackedChartClass">
<canvas #stackedChart></canvas>
</div>
let stackedChartOptions: any = {
responsive: false,
legend: {
position: 'right' // place legend on the right side of chart
},
scales: {
xAxes: [{
stacked: true // this should be set to make the bars stacked
}],
yAxes: [{
stacked: true // this also..
}]
}
}
this.stackedChart = new Chart(pieCtx,
{
type: 'bar',
data: this.stackedChartData,
options: stackedChartOptions,
responsive: true
}
);
和CSS
.stackedChartClass>canvas {
width: 100% !important;
height: 50vh !important;
}
如何解决这个问题?
解决方案
推荐阅读
- perl - “在数字 eq (==) 中使用未初始化的值”在 perl 脚本的特定行报告
- java - 如何访问在另一个类中定义的 java.util.prefs.Preferences 对象
- duplicates - 如何在此功率数据透视表中编写一个仅对唯一值旁边的值求和的度量?
- html - 我如何包装按钮?
- powershell - 如何在PowerShell中更新集群?
- windows - 从带有 PDB 的 DLL 在 Visual Studio 中显示枚举常量
- php - 在 PHP 中获取当前页面上的 h1 标签
- azure-data-factory - 获取管道名称及其活动
- object - 如何从 Kotlin 中的函数返回对象?
- python - 拥抱面部标记器无法正确加载文件