Chartjs-Chart.js 2.2.1 – Chart doesn't render correctly before resizing

0👍

I had the same issue one time and the issue occurs because the element in which i puted my “chart” didn’t exist on load . Check if your HTML is ok before putting your chart in it.

By The way, do you have more code to provide us? it’ll be more easy to help you

0👍

You need to create a function that will actually run through and build your chart after the parent element has been rendered. You can do this by wrapping that function inside a document ready tag. That way when the document is ready the function will fire and build the chart once it knows the parent elements size.

Something like this:

function buildChart(){
//Build your chart here
}

And then wrap it like this:

$(function(){
 buildChart()
})

0👍

Don’t know what happened, but it’s working correctly now… I just cleaned some files from older versions. Didn’t have time to try any of your solutions, but thanks for answering!

Leave a comment