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.

The charts are just resizing it when the window or the viewport change.

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 The charts are just resizing it when the window or the viewport change.

Expected behavior Resize the chart when the parent container change, if the chart doesn’t have the property view defined.

Reproduction of the problem this is a reproduction: https://plnkr.co/edit/eikmlKcVM9vLTbzTQTNs?p=preview. As you can see in the view I put a button to refresh the with of the container but the graph doesn’t resize unless you resize the preview.

What is the motivation / use case for changing the behavior? I’m want to implement the charts in a layout where I have a sidebar that you can toggle, so if the sidebar is hidden then the main container take his place.

Please tell us about your environment:

@angular/cli: 1.0.0
node: 6.11.2
os: win32 x64
@angular/animations: 4.4.3
@angular/common: 4.4.3
@angular/compiler: 4.4.3
@angular/core: 4.4.3
@angular/forms: 4.4.3
@angular/http: 4.4.3
@angular/platform-browser: 4.4.3
@angular/platform-browser-dynamic: 4.4.3
@angular/router: 4.4.3
@angular/cli: 1.0.0
@angular/compiler-cli: 4.4.3
  • ngx-charts version: ^7.0.0
  • Angular version: ^4.0.0

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:19
  • Comments:8

github_iconTop GitHub Comments

12reactions
phanfcommented, Feb 17, 2018

@JulioWar I was able to work around the resize issue with the following code as suggested. ngAfterViewInit(): void { setTimeout(_ => { window.dispatchEvent(new Event(‘resize’)); }); // BUGFIX: }

6reactions
JulioWarcommented, Dec 29, 2017

Maybe we can try to trigger the window resize event like is discribed here: https://stackoverflow.com/questions/1818474/how-to-trigger-the-window-resize-event-in-javascript

Read more comments on GitHub >

github_iconTop Results From Across the Web

Charts do not respond to viewport changes - Vaadin
Hi, if i change the viewport on the https://charts.demo.vaadin.com/ColumnWithMultiLevelDrilldown page the chart stays at the same size.
Read more >
Does adjusting the browser window change the value of the ...
Yes, you can change your viewport size by resizing the browser window. The website What is my Viewport is a neat way to...
Read more >
Dynamically resize canvas on window resize - Stack Overflow
You would dynamically adjust the height and width of the #area-chart. I personally suggest using viewport width to define the height as it...
Read more >
Responsive Charts - Chart.js
When it comes to changing the chart size based on the window size, ... to be relatively positioned and dedicated to the chart...
Read more >
Resizing an SVG When the Window is Resized in d3.js - Chartio
Think of it this way: Images have specific dimensions ( width and height ) and thus when a browser displays them or is...
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