Search code examples
angularproduction-environmentc3.js

ERROR TypeError: t.rgb is not a function issue with C3JS in angular prod environment


I have done a lot of research to resolve this issue but, didn't find any solution. I have used c3 js version 0.7.11 with Angular CLI version 7.0.7. can somebody help me into this?

main.b5c5d0251120bfab71af.js:1 ERROR TypeError: t.rgb is not a function
    at xe (main.b5c5d0251120bfab71af.js:1)
    at we (main.b5c5d0251120bfab71af.js:1)
    at main.b5c5d0251120bfab71af.js:1
    at Vm (main.b5c5d0251120bfab71af.js:1)
    at Module.UQyC (main.b5c5d0251120bfab71af.js:1)
    at f (runtime.ec2944dd8b20ec099bf3.js:1)
    at new e (main.b5c5d0251120bfab71af.js:1)
    at new r (main.b5c5d0251120bfab71af.js:1)
    at Object.generate (main.b5c5d0251120bfab71af.js:1)
    at t.ngAfterViewInit (main.b5c5d0251120bfab71af.js:1)

Solution

  • Finally, I got a solution to this problem. It's a problem with the version of D3. They have released the 4.x.x + versions in a rollupJs fashion. which generate the main D3.js on the fly. because of these changes it is not getting bundled in main.js file when we give a build with --prod.

    So, here is the solution to a problem.

    step-1: We need to install an updated version of d3. i.e.5.14.2.

    step-2: Add ./node_modules/d3/dist/d3.js to the script block under configuration -> production section. in angular.json file.

    Here step-2 will build the added file additionally for you.