Angular chartjs高度不跟随父容器
注意:我已修复问题2,数据错误。我仍然面临问题1。 我有下面的折线图配置。数据集的示例数据是 {x:'29/01/2017',y:'0.00234'}Angular chartjs高度不跟随父容器,angular,chart.js,angular-flex-layout,chartjs-2.6.0,Angular,Chart.js,Angular Flex Layout,Chartjs 2.6.0,注意:我已修复问题2,数据错误。我仍然面临问题1。 我有下面的折线图配置。数据集的示例数据是 {x:'29/01/2017',y:'0.00234'} options: { responsive: true, maintainAspectRatio: false, scales: { xAxes: [{ type: 'time', time: { format: 'DD/MM/YYYY' } }] } } 此外
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
xAxes: [{
type: 'time',
time: {
format: 'DD/MM/YYYY'
}
}]
}
}
此外,我还有html(我使用angular flex布局)和typescript:
<div fxFlex style="height: 100%">
<div id="graph">
<canvas id="canvasGraph">{{chart}}</canvas>
</div>
</div>
// Hoping I can change the size of canvas to be the same as the parent
const canvas = <HTMLCanvasElement>document.getElementById('canvasGraph');
canvas.width = document.getElementById('graph').offsetWidth;
canvas.height = document.getElementById('graph').offsetHeight;
{{chart}}
//希望我可以改变画布的大小,使其与父级相同
const canvas=document.getElementById('canvasGraph');
canvas.width=document.getElementById('graph').offsetWidth;
canvas.height=document.getElementById('graph')。offsetHeight;
我有2个(现在只剩下1个)问题:
我终于解决了我的问题。现在,图表已做出响应
#graph{
position: relative;
height: 100%;
width: 100% !important;
}
canvas {
width: 100% !important;
}
我相信我已经提出了正确的要求,并给出了我的代码和尝试的解决方案。