Open hagay3 opened 6 years ago
Could you tell me what this line contains: /home/project15/web/node_modules/ng2-charts/charts/charts.js:24:47
You are trying to use some not-yet-implemented method of the canvas API, but I can't tell exactly which one based on your stacktrace.
Hi is this issue got fixed on using domino with angular5.0 ?
I'm also having this kind of issue using domino in server.ts
Error output: c:\Users\blank\Documents\blank-files\angularapps\rldwebshopv5.0\dist\server.js :23712 throw new Error("NotYetImplemented"); ^
Error: NotYetImplemented
at HTMLCanvasElement.exports.nyi (c:\Users\blank\Documents\blank-files\ang
ularapps\rldwebshopv5.0\dist\server.js:23712:9)
at c:\Users\blank\Documents\blank-files\angularapps\rldwebshopv5.0\dist\se
rver.js:191976:34898
at c:\Users\blank\Documents\blank-files\angularapps\rldwebshopv5.0\dist\se
rver.js:191976:35221
at c:\Users\blank\Documents\blank-files\angularapps\rldwebshopv5.0\dist\se
rver.js:191976:45461
at Object.defineProperty.value (c:\Users\blank\Documents\blank-files\angul
arapps\rldwebshopv5.0\dist\server.js:191976:47139)
at __webpack_require__ (c:\Users\blank\Documents\blank-files\angularapps\r
ldwebshopv5.0\dist\server.js:20:30)
at Object.h9AC (c:\Users\blank\Documents\blank-files\angularapps\rldwebsho
pv5.0\dist\server.js:166616:493649)
at n (c:\Users\blank\Documents\blank-files\angularapps\rldwebshopv5.0\dist
\server.js:166616:149)
at Object.aR8+ (c:\Users\blank\Documents\blank-files\angularapps\rldwebsho
pv5.0\dist\server.js:166616:482366)
at n (c:\Users\blank\Documents\blank-files\angularapps\rldwebshopv5.0\dist
\server.js:166616:149)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rldwebshopv1@1.1.0 serve:ssr: node dist/server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rldwebshopv1@1.1.0 serve:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\blank\AppData\Roaming\npm-cache_logs\2018-02-15T0805 08_044Z-debug.log
I get it too. The problem seems to be here:
BaseChartDirective.prototype.ngOnInit = function () {
this.ctx = this.element.nativeElement.getContext('2d');
this.cvs = this.element.nativeElement;
this.initFlag = true;
if (this.data || this.datasets) {
this.refresh();
}
};
and particularly, here:
this.ctx = this.element.nativeElement.getContext('2d');
In my case, wrapping the canvas element and displaying it conditionally only if the platform is browser seems to be avoiding the error, at least.
The template:
<div style="display: block" *ngIf="isBrowser">
<canvas baseChart
[datasets]="datasets"
[options]="barChartOptions"
[legend]="barChartLegend"
[chartType]="'bar'"
[colors]="statisticsService.colors"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)">
</canvas>
</div>
The typescript file:
constructor(@Inject(PLATFORM_ID) private platformId: Object) {
this.isBrowser = isPlatformBrowser(this.platformId);
}
Any update on this issue?
The
Are you asking for the canvas API to be implemented, or do you want the feature test to work differently or....?
I was using domino to mock the window, but I choose a different way right now, using the node window, jsdom and jsom-canvas...
I've just gotten this with the lottie library. It's happening right as soon as the module is initialized:
var ImagePreloader = (function(){
var proxyImage = (function(){
var canvas = createTag('canvas');
canvas.width = 1;
canvas.height = 1;
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0,0,0,0)';
ctx.fillRect(0, 0, 1, 1);
return canvas;
}())
If it were in my application I would just wrap this in a conditional and only execute if inside the browser. But it seems to be too deep to reach. Anyone have any suggestions?
This problem still exists as of today
got same problem as @pedromcunha - can't wrap it because its not it my code!
For me, the above solution (@rtyx) doesn't work, but if I replace this
<div style="display: block" *ngIf="isBrowser">
<canvas baseChart
[datasets]="datasets"
[options]="barChartOptions"
[legend]="barChartLegend"
[chartType]="'bar'"
[colors]="statisticsService.colors"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)">
</canvas>
</div>
by this, It's works for me!
ngAfterViewInit(): void { if (this.isBrowser) { this.ctx = this.canvas.nativeElement.getContext( '2d', ) as CanvasRenderingContext2D; .... } }
Getting an error with message "NotYetImplemented" from utils.js I get the error while using nodejs server, what this exact error means? When I'm using "ng serve" there is not such error.
I'm using line chart from ng2-charts module. Full Stack Trace:
Using the following: NodeJS: 9.3.0 Angular: 5.1.2 OS: linux x64 "chart.js": "^2.7.1" "ng2-charts": "^1.6.0"