question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is Chart using available space properly in responsive mode

See original GitHub issue

I’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

2017-02-14 1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
StanFishercommented, Sep 6, 2017

@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.

1reaction
marjan-georgievcommented, May 13, 2019

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found