-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular 6 library, Import highcharts exporting #54
Comments
Hi @vicatcu Did you had to use the second way of loading the files? or are you just sharing an alternative way that also works? If import * as HC_exporting from 'highcharts/modules/exporting'; does't work, then you could try import HC_exporting from 'highcharts/modules/exporting'; It depends on environment configuration and Highcharts version (at least haven't been reported differently so far). It looks like the code you shared is about loading Highcharts. We would like to keep problems about Highcharts among it's other GitHub issues, so if this is a bug report we should move it to the right place. |
Closing due to inactivity, but will reopen if needed. |
I follow the instructions in the readme to use the exporting module with the new version but there is still a typescript error: import * as Highcharts from 'highcharts';
import * as HC_exporting from 'highcharts/modules/exporting';
HC_exporting(Highcharts);
Reading your comment above, i tried: import HC_exporting from 'highcharts/modules/exporting';
HC_exporting(Highcharts); This give me:
I also tried: import * as Highcharts from 'highcharts';
require('highcharts/modules/exporting')(Highcharts);
My versions in the package.json are:
|
@Getz85 |
Indeed, the workaround for the 'require' options works, thank you! |
@Getz85 "dependencies": {
"@angular/common": "^6.0.9",
"@angular/core": "^6.0.9",
"@angular/compiler": "^6.0.9",
"@angular/animations": "^6.0.9",
"@angular/forms": "^6.0.9",
"@angular/http": "^6.0.9",
"@angular/platform-browser": "^6.0.9",
"@angular/platform-browser-dynamic": "^6.0.9",
"@angular/router": "^6.0.9",
"core-js": "^2.4.1",
"highcharts": "^6.1.1",
"highcharts-custom-events": "^2.1.6",
"rxjs": "^6.0.9",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.7.0",
"@angular-devkit/build-ng-packagr": "~0.7.0",
"@angular/cli": "^6.0.9",
"@angular/compiler-cli": "^6.0.9",
"@angular/language-service": "^6.0.9",
"@types/highcharts": "^5.0.27",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.4.2",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"ng-packagr": "^4.0.0",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tsickle": ">=0.27.3",
"tslib": "^1.7.1",
"tslint": "^5.10.0",
"typescript": "~2.7.2"
} I have used this repo as a demo, so I only changed this file. Please check if there are any differences or if you could recreate the problem using this repo as a demo with some modification. |
Well I cloned this repo, do a npm install, change the line 7 in app.component.ts: const HC_exporting = require('highcharts/modules/exporting'); to import * as HC_exporting from 'highcharts/modules/exporting'; And the message is displayed on VS code and when compiling...
That's really strange as we have the same tsconfig... I try to create a stackblitz to reproduce |
And the stackblitz raise an other error... He can't find the exporting module, can't find why: https://stackblitz.com/edit/angular-zgfvbs |
Not sure what's going on in stackblitz. |
I found a solution for this. I had the same problem with Angular 6 and this wrapper whenever I wanted to make usage of the "exporting" module, so instead of doing:
I did:
I don't think it has to be the solution, but at least is a workaround that works |
Thank you @fmorc for sharing your solution. This could be used as a workaround for now - using files with Types definitions are outdated, but we are close to an new types definitions release that should help in this case - please refer to: highcharts/highcharts#4876 (comment) |
Hi @KacperMadej , I am getting the same error, but I am using highcharts with angular universal, client-side rendering is all good but when it comes to server-side rendering, it's giving me that error. Here are my configs: Angular CLI: 6.0.0 Detailed Package Version Please tell me if you need any other info for debugging this. This is my code for chart:
Here is live demo on sandbox - |
I am getting this error while running "npm run serve:ssr" in angular universal project: \node_modules\highcharts\modules\exporting.src.js:49 TypeError: Cannot read property 'navigator' of undefined |
If navigator is not available, then context of Highcharts initialization is wrong and it's not a window, so other features of Highcharts might not work also - not only exporting. The demo you have provided doesn't throw any error and doesn't show any chart. After changing anything the project tries to rebuild, but fails with overload of errors and problems making the demo freeze and unusable. Errors start like:
|
Ok, I will make another working demo on sandbox, and will send you it's link. Thanks for looking into it. Can you please tell me how can I make the demo project as angular-univeral, as I was only able to build angular project on sandbox. |
@yaseen-nadaf Highcharts needs window and document to work, as it's designed to have access to those elements. As explained in the linked docs - you could...
|
Docs are updated now. |
As documentation at angular-highcharts.
|
@mohammedelzanaty Wrong repository? This is highcharts-angular, not angular-highcharts. |
Hi I from Ecuador, I had the same problem but I solved it in Angular 8 this way: I hope help someone. Sorry by my English :) |
I had the same problem and I tried a different option mentioned above, but I solved it in Angular 8 by:
|
In order to get it to work in an Angular 6 library module, I had to do it very slightly differently from what's in the README, and I just wanted to share that back for possible inclusion in the docs.
Instead of:
I did:
As far as I can tell this is just a workaround. It's not something "special" to highcharts, I had to do the same sort of thing for moment. But maybe this will save someone else some search time. This follows from advice I found here: jvandemo/generator-angular2-library#221
The code above lives in any Component in which I want to use highcharts.
The text was updated successfully, but these errors were encountered: