Chart.js: responsive behavior not working

Created on 8 Apr 2018  ·  6Comments  ·  Source: chartjs/Chart.js

I'm using two line charts along side in a bootstrap row, each inside a col.

Expected Behavior

It should snap back to normal size when the browser maximizes

Current Behavior

If the browser window is narrowed the canvas fills the row but when you maximize the window it doesn't go back to how it was

Steps to Reproduce (for bugs)

  1. put two canvases in to cols:
<div class="row">
        <div class="col"><canvas id="language-chart"></canvas></div>
        <div class="col"><canvas id="subject-chart"></canvas></div>
</div>
  1. initialize 2 line charts like the docs tells you to
  2. load the page in a maximized browser, everything's normal
  3. change the width of the browser to about the tablet width
  4. go back to maximized

Environment

  • Chart.js version: 2.7.2
  • Browser name and version: Opera 51, Firefox latest
bug

Most helpful comment

That's an issue with flexbox (your .col class), you need to explicitly set .col { min-height: 0 }, see #4156 (comment) and this fiddle.

All 6 comments

@mokhosh is it possible to put together a fiddle that reproduces this issue?

@etimberg sure:
a fiddle that reproduces this issue

as you can see the charts are along side each other as they should be. but when you try to resize the rendering area they are stacked on top of each other, which is still normal. but you can't get them to go back to the first condition no matter how big you make that area.

I think its a responsive issue,try to moniter a window.resize function to redraw the chart

@mokhosh it looks like it's working for me (Firefox on OSX). I tried resizing the entire browser and the charts resize as expected.

well, that's really good. can we do something about windows 10 as well?

That's an issue with flexbox (your .col class), you need to explicitly set .col { min-height: 0 }, see #4156 (comment) and this fiddle.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lbowers picture lbowers  ·  3Comments

benmccann picture benmccann  ·  3Comments

akashrajkn picture akashrajkn  ·  3Comments

nickgoodliff picture nickgoodliff  ·  3Comments

joebirkin picture joebirkin  ·  3Comments