Responsive Width, Fixed Height
See original GitHub issueExpected Behavior
I would like to render a chart width a 100%
width, but a fixed height (e.g. 500px
). I would also like the chart to resize according to those constraints (without maintaining aspect ratio).
Actual Behavior
Currently, I’m having trouble working with the responsive
/maintainAspectRatio
options. Regardless of my styling & options, the height seems to grow beyond it’s containing elements (I believe it’s using a 1:1
aspect ratio).
I can easily get something working when I feed the chart numeric width/height as a landscape ratio w:h
(e.g. <line-chart :chart-data="chartData" :width="5" :height="1" />
). Since the prop validation expects a number, I’m wondering if my desired behavior is possible with the current api.
Environment
- vue.js version:
2.4.2
- vue-chart.js version:
2.8.2
- npm version:
5.3.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Responsive images with fixed height CSS - Stack Overflow
You can set width and height using VW (view width), this means that your image will have width and height based in the...
Read more >Responsive Height Design - Ahmad Shadeed
Set a fixed size (width and height) to the illustration instead of the width only. The absence of height will keep the problem....
Read more >Setting Height And Width On Images Is Important Again
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images.
Read more >Fixed Width Design - GeeksforGeeks
Approach: Fixed-width is generally used when you don't want the width of your content to change according to the changing width of the...
Read more >Turning a Fixed-Size Object into a Responsive Element
I set out to modify the library to make the devices responsive. Here is the final resizable library. Below, we'll walk through the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed
Switching my component definition to the following solved my problem. This makes me think that somewhere in the chain, my
maintainAspectRatio
setting was getting merged with the defaulttrue
in a way that merged the truthy value. Maybe, maybe not. But this works nicely now, so feel free to close this or keep it open for @wannymiarelli .Do you have
maintainAspectRatio
set to true or false?Can you maybe post a minimal codepen for reproduction?