Is Chart using available space properly in responsive mode
See original GitHub issueI’m submitting a … (check one with “x”)
[ x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here
Current behavior Charts in responsive mode (no view set) not using up available parent space (Marjan asked to raise from gitter)
Expected behavior Charts would use up more of the available space
Reproduction of the problem
<div class="col-12"> <div class="card"> <div class="card-header"> State Of The Parties </div> <div class="card-block" style="min-height: 400px;width:100%"> <ngx-charts-pie-chart [scheme]="colorScheme" [results]="partyTotals" [legend]="false" [explodeSlices]="false" [labels]="true" [doughnut]="false" [gradient]="gradient" (select)="onSelect($event)"> </ngx-charts-pie-chart> </div> </div> </div>What is the motivation / use case for changing the behavior? Charts would be better responsive if they used the space available better on smaller viewports
Windows 10
- ngx-charts version: 4.1.2
- Angular version: 2.4.7
- Browser: all
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Charts.js graph not scaling to canvas size - Stack Overflow
The width and height property that you set for the canvas only work if the Chartjs' responsive mode is false (which is true...
Read more >Responsive charts | Highcharts
In general, the responsive configuration lets you define size-dependent settings for all aspects of the chart. Typical use could be to move the ......
Read more >How we made the State of CSS more responsive and accessible
The charts are the main show of the State of CSS results so I wanted to make sure they had as much space...
Read more >Responsive Data Tables | CSS-Tricks
Data tables don't do so well with responsive design. Just sayin'. He has a good point. Data tables can be quite wide, and...
Read more >Migrate your UI to responsive layouts - Android Developers
This will delineate the space that is left for content. In the following snippet, the activity uses a bottom bar for compact screens...
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
@marjan-georgiev I see the problem. If you take a look at PieChartComponent starting at line 87, you will see that when deselecting Show Labels, margins still contains
[30, 80, 30, 80]
. The update needs to reset the margins to the intended default of[20, 20, 20, 20]
.This brings up another question though. Why are the margins being set at all? I would think that when I want to fit to the container, there should be no margins. Do you agree?
Also, since the margin is hard-coded to 20 pixels all around and the calculations for the height and width are made using the margins, you will see the effective margins get bigger as the size gets smaller. This is another reason why I think the margins should be removed. Instead, the spacing inside a container should be handled by CSS.
Hi all, just merged the PR, will be in the next release. Would need to add the
margins
input to all charts before we release, so they are all consistent. If anyone is interested in working on that, please let me know.Thanks!