Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

horizontal bar chart increases row height on resize when maintainAspectRatio is set to false #2538

Closed
ThaJay opened this issue May 13, 2016 · 6 comments

Comments

@ThaJay
Copy link

@ThaJay ThaJay commented May 13, 2016

Steps to reproduce:

  • new Chart(ctx, {type: 'horizontalBar', data})
  • maintainAspectRatio: false
  • resize your window

https://jsfiddle.net/pzx1LtqL/3/

@ThaJay ThaJay changed the title horizontal bar chart increases row height on resize horizontal bar chart increases row height on resize when maintainAspectRatio is set to false May 13, 2016
@nealoke

This comment has been minimized.

Copy link

@nealoke nealoke commented May 22, 2016

Same issue with a line chart I am making :/

@nealoke

This comment has been minimized.

Copy link

@nealoke nealoke commented May 22, 2016

@ThaJay if you want a workaround for now, set a max height on the container of the chart which limits how far the chart stretches out in height. To avoid inconsistency I also set a height and max height of the same amount (keeping it constant across all screen heights)

@etimberg

This comment has been minimized.

Copy link
Member

@etimberg etimberg commented May 27, 2016

The good news is that I now know what causes this. The bad news is that I don't yet know the fully cross-browser way to fix it so I need to do some testing on my end. The gist of it is described in http://stackoverflow.com/questions/8600393/there-is-a-4px-gap-below-canvas-video-audio-elements-in-html5

In the fiddle i added some CSS to make the canvas display: block and the problem went away

@etimberg

This comment has been minimized.

Copy link
Member

@etimberg etimberg commented May 27, 2016

Ok, the summary of my research is in the table below. 'Yes' indicates that the browser CSS display combination includes an extra 4 px at the bottom.

CSS Display Chrome Firefox IE11 Edge Safari
inline Yes Yes Yes Yes Yes
block
list-item
inline-list-item Yes Yes Yes Yes
inline-block Yes Yes Yes Yes Yes
inline-table Yes Yes Yes Yes
table
table-cell Yes
table-column Yes
table-column-group Yes
table-footer-group Yes
table-header-group Yes
table-row Yes
table-row-group Yes
flex
inline-flex Yes Yes Yes Yes
grid Yes Yes Yes Yes
inline-grid Yes Yes Yes Yes
run-in Yes Yes Yes Yes
ruby Yes Yes Yes Yes
ruby-base Yes Yes Yes Yes
ruby-text Yes Yes Yes Yes
ruby-base-container Yes Yes Yes Yes
ruby-text-container Yes Yes Yes Yes
contents Yes Yes Yes Yes
@etimberg

This comment has been minimized.

Copy link
Member

@etimberg etimberg commented Jun 21, 2016

Fixed in 2.1.6 we default to a block style if one is not set on the canvas. See https://jsfiddle.net/pxzzo24p/1/

@etimberg etimberg closed this Jun 21, 2016
@Jiia

This comment has been minimized.

Copy link

@Jiia Jiia commented Oct 7, 2016

I ran into this issue on 2.3.0. It occurred because the container had other items in it besides from the canvas. By putting the canvas inside its own container and setting container position:relative everything works beautifully. Example how to break it: https://jsfiddle.net/pxzzo24p/14/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.