Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 重新绘制时,Chart.js画布和图表宽度将被覆盖_Javascript_Html_Css_Web_Chart.js - Fatal编程技术网

Javascript 重新绘制时,Chart.js画布和图表宽度将被覆盖

Javascript 重新绘制时,Chart.js画布和图表宽度将被覆盖,javascript,html,css,web,chart.js,Javascript,Html,Css,Web,Chart.js,我用chart.js制作的图表每次重画时都会增长,我不知道为什么。 我的图表cavas代码是: let tempChart=document.getElementById(“tempChart”).getContext('2d'); 让pressureChart=document.getElementById(“pressureChart”).getContext(“2d”); 设O3Chart=document.getElementById(“O3Chart”).getContext(“2d

我用chart.js制作的图表每次重画时都会增长,我不知道为什么。 我的图表cavas代码是:

let tempChart=document.getElementById(“tempChart”).getContext('2d');
让pressureChart=document.getElementById(“pressureChart”).getContext(“2d”);
设O3Chart=document.getElementById(“O3Chart”).getContext(“2d”);
让PM1Chart=document.getElementById(“PM1Chart”).getContext(“2d”)

您正在使用的库(chart.js)似乎在默认情况下覆盖了这些css值

一个选项是在createChart函数的末尾将这些值设置回正确的值

例如:

tempChart.style.width = 45%;

另一个选项是在样式表中为它们添加高功率,
!重要的
,但这取决于(chart.js)的行为方式。

谢谢,但似乎唯一(诚实地退出愚蠢)的错误是我忘了将响应设置为true。一旦我这么做了,它又起作用了,但谢谢你的回答!