chart js flexbox width ignored
See original GitHub issueI’m using Bulma v0.6.2
CSS framework with vue-chartjs 3.2.1
, trying to put a Line chart inside a Box container. My chartjs
options are all correct and as advised for achieving responsiveness:
responsive: true,
maintainAspectRatio: false
I also use a container for my chart as advised (the chart-container
class property):
<UserActivity
v-bind:chart-data="datacollection"
v-bind:options="graphOptions"
class="chart-container"
/>
with the following chart-container
CSS:
.chart-container {
position: relative;
height: 40px;
}
but it seems like the chart ignores the parent element’s width:
I looked around found some hints that the issue may be related to Bulma and Flexbox. Did anyone encounter this issue?
EDIT: This jsfiddle reproduces the issue https://jsfiddle.net/c6tu3qgx/1/
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
chart js flexbox width ignored - css - Stack Overflow
I'm using Bulma v0.6.2 CSS framework with vue-chartjs 3.2.1 , trying to put a Line chart inside a Box container. My chartjs options...
Read more >Flex Cheatsheet
The defining aspect of flex layout is the ability to make the flex items “flex”, altering their width/height to fill the available space...
Read more >justify-content - CSS: Cascading Style Sheets - MDN Web Docs
The CSS justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex ...
Read more >react height 100 percent not working with flex - You.com
Making a flexbox container height 100% in react js ... CSS Flex property not working with my React Component ... chart js 2...
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
I had all of the symptoms detailed above but this hacky fix seems to work fine. I have 4 charts displayed in a flexbox row shrinking perfectly.
canvas { width: 100% !important; }
I’ve been through the other tickets on this, but this seems to be the survivor. My example is a simple case with a full-width table with a column containing a sparkline: https://jsfiddle.net/0rg1jesx/ This is a trivial example; my purpose is to point at this defect, not to demonstrate a good way to use HTML. In live I have a Bootstrap grid with a table of data in it, and the table rows contain sparkline charts as well as other data.
The charts grow beautifully, but won’t shrink no matter what I try. Although its the same symptom as this apparent “flexbox” thing the problem persists even when the flexbox is removed. That’s not the root issue.