-
-
Notifications
You must be signed in to change notification settings - Fork 836
Responsive property doesn't work #539
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
Comments
I can confirm this. I am using vue 2.6.10, vue-chartjs 3.4.2 and chart.js 2.8.0 |
Can you maybe provide a codepen or other runable reproduction? |
@apertureless -- I believe I have found the cause of this (or at least a related issue) and have a suggestion for a fix. Chart.js docs when describing 'aspectRatio': "Note that this option is ignored if the height is explicitly defined either as attribute or via the style." per https://www.chartjs.org/docs/latest/general/responsive.html#configuration-options vue-chartjs does not offer any facility to NOT define the height and width. They always default to being 400x400 inlined in the html, even when they are not defined, which means the "aspectRatio" property (and responsive design in general?) will simply never work. This is the problematic code: https://github.com/apertureless/vue-chartjs/blob/develop/src/BaseCharts.js#L16 I have verified that the following modification to BaseChart.js enables a responsive design and aspectRatio to function as intended: The reproduction case would basically be the inability of the current code to utilize the aspectRatio property. When you make ANY chart with the following configuration you should see a chart that is 4 times as wide as it is tall. The chart should expand to fill the full width of the browser:
Conversely, this code should make a chart that is 4 times as tall as it is wide:
With the current version of your code, this functionality is only partially working. The chart does expand to fill the full width of the browser, but it does not respect the aspectRatio property at all and always has a 1:1 height/width ratio. Fortunately, because the observed default behavior of not specifying a height and width is the same between both versions of the code (ie, they both result in 100% width, and not 400px width), I wouldn't consider this bug fix a breaking change and am hoping you can get it deployed to npm soon, if you are able and agree with the proposed solution. I'm happy to send it through as a PR if that might expedite things. Thanks. |
Ah nice finding! However, removing the defaults is a breaking change. Thus I wanted to rewrite the reactive mixins, before merging this. |
@apertureless Any updates on that? No movement in a while. |
@DrLongGhost you are a life saver! |
I used Line chart with options:
And use wrappers for chart:
but chart doesn't scale by height
The text was updated successfully, but these errors were encountered: