Display of graph settings only on second load.
Expected behavior
Hello, I need to periodically update the chart data. But.....
Current behavior
Hello, I have a problem with configuring the appearance of the chart. I have code that periodically calls javascript that redraws the chart, the problem is that the first time it is run, the chart is displayed without my visual modifications. And only when the code loading is called for the second time, the settings will be displayed. I have no idea what it could be. And I will be glad for any advice.
Reproducible sample
Bellow
Optional extra steps/info to reproduce
var data = { labels: x, datasets: [{ label: name, lineTension: 0.3, backgroundColor: "rgba(2,117,216,0.2)", borderColor: "rgba(2,117,216,1)", pointRadius: 0, pointBackgroundColor: "rgba(2,117,216,1)", pointBorderColor: "rgba(255,255,255,0.8)", pointHoverRadius: 5, pointHoverBackgroundColor: "rgba(2,117,216,1)", pointHitRadius: 50, pointBorderWidth: 2, data: y, }] };
var dmin = Math.min.apply(Math, y); var dmax = Math.max.apply(Math, y);
var config = { type: 'line', options: { animation: {duration: 0}, scales: { x: { ticks:{ display: false }, grid: { display: false }, title:{ display: true, text: "Čas" } }, y: { suggestedMin: dmin-10, suggestedMax: dmax+10, title:{ display: true, text: unit[i] }, } } }, data: data };
// Area Chart Example var ctx = document.getElementById("myAreaChart_"+pos[i]); var myLineChart = new Chart(ctx, config); }
Possible solution
No response
Context
No response
chart.js version
3.5
Browser name and version
No response
Link to your project
No response
This seems like an issue with your surrounding code, the code you posted runs fine if you add the missing variables
Please add a fiddle or codepen with a reproducable sample of the issue.
Closing as not reproducible