height stay at fixed size (px) even with maintainAspectRatio #9058
Unanswered
AndreaBarghigiani
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all and thanks for this amazing library, I am using it for a while and I have to say that has been a pleasure to work with it so first and foremost congrats to the developers and maintainers 💪
Recently I have started to use it in a Rails application and I've implemented it with Chartkick but I am facing a problem here because I am not able to leverage the
maintainAspectRatio
option.The chart is responsive and it adapts to the changes in the
width
but I see theheight
set at a fixed value,300px
to be precise.Reading the documentation and the previous issues I noticed that
Since Chartkick does not allow me to set a class to the
div
that wraps thecanvas
element I have wrapped it with a customdiv
and set the following CSS:In this way I am setting the
div
positioned as relative and also give it aheight
but checking at the code it is still300px
🤔I tried also to check the option passed via the JavaScript API that Chartkick offers but they seems good from my point of view:

PS: if you think that I shall post this in the Chartkick repo let me know, wrote here because to me seems related with Chart.js
Beta Was this translation helpful? Give feedback.
All reactions