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.

ngx-charts changing route behavior

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 When I introduce ngx-charts into my Angular application, my application no longer uses the configured Angular Route “extra” of “/#/”. Instead, the hash is removed from the route, which throws off the server-side rendering of certain pages / templates.

I have confirmed that this behavior is introduced only when I include the NgxChartsModule in my app module.

Expected behavior I would expect that I can include NgxChartsModule without it changing the route behavior.

Reproduction of the problem When I introduce ngx-charts into my Angular application, my application no longer uses the configured Angular Route “extra” of “/#/”. Instead, the hash is removed from the route, which throws off the server-side rendering of certain pages / templates.

What is the motivation / use case for changing the behavior? Allow a single page web-app to work without loading from many different routes.

Please tell us about your environment: macOS 10.12

  • ngx-charts version: 6.0 and 6.1

  • Angular version: 4.4.3

  • Browser: Chrome 61.0, Firefox 55 / 56, presumably all

  • Language: Typescript, presumably all

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
brianghigcommented, Oct 17, 2017

Following up, it turns out that this behavior only occurs when I include NgxChartsModule after including my App’s RoutingModule that imports the RouterModule. Once I moved the import of NgxChartsModule before the AppRoutingModule, it seems to work fine!

4reactions
gappccommented, Jul 14, 2018

I think I found the culprit: commit edd12467df0aaa0c335508eb1285ab3f68be5a93 sets the LocationStrategy in the ChartCommonModule to PathLocationStrategy.

In case of lazy loaded Angular modules, this seems to prevent the HashLocationStrategy to work properly.

The workaround I use is to explicitly set the location strategy in any of the lazy loaded modules:

@NgModule({
  providers: [
    {
      provide: LocationStrategy,
      useClass: HashLocationStrategy,
    }
  ],
})

I’ve provided a fix in this pull request: https://github.com/swimlane/ngx-charts/pull/915

Read more comments on GitHub >

github_iconTop Results From Across the Web

NgxCharts resizing on data change - Stack Overflow
We solved it using a div around the chart and using CSS added a height of 40 or 50vh. The chart no longer...
Read more >
swimlane/ngx-charts - Gitter
Data that is displayed on the chart is dynamically changed. So approximately every minute I get the new data for each sensor (value...
Read more >
Changelog - ngx-charts - GitBook
Bug: Changed onDeactivate in the gauge component to emit the correct value instead of the event value from the global scope (#613) ...
Read more >
ngx-echarts - npm
[merge], object, null, Used to update a part of the options , especially helpful when you need to update the chart data. In...
Read more >
Ngx-Charts 20.1.0 Angular Chart Framework
{ "name": "Germany", "value": 40632, "extra": { "code": "de" } }, { "name": "United States", "value": 50000, "extra": { "code": "us" } },...
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