Accepted answer

chart.js has a property (responsive) that you can configure at the global or chart level via options that will make the chart responsive. see > responsive

// boolean - whether or not the chart should be responsive and resize when the browser does.
responsive: true,

true makes it responsive. false (default) makes it non-responsive.

example usage (only the relevant part, check out the codepen for the full exam)

var ctx = $("#bar").get(0).getcontext("2d");
var mychart = new chart(ctx).bar(bardata, {
  responsive: true

codepen -

you might also want to check out the maintainaspectratio option, if you want to maintain the ratio of width to height.

Related Query

More Query from same tag