Comments (23)
Hi,
it seems that the issue comes from "@angular-devkit/build-optimizer".
By keeping "optimization=true" and passing "optimization=false", the issue doesn't appear anymore.
Upgrading Angular version (tried with "8.2.8") also upgrades "@angular-devkit/build-optimizer" and solves that (we can still keep "optimization=true" and "optimization="true" without generating this issue).
So the problem came from "@angular-devkit/build-optimizer" but not D3.
I think that this issue could be closed.
from d3-color.
Closing as an Angular issue.
from d3-color.
This issue is closed but, i figured i'd share for anyone else running into this that updating angular/cli via ng update
worked. ( as suggested by @alan-agius4 )
from d3-color.
No, the code is broken by Angular’s optimizer; my guess is that your only option is disabling the optimizer. Reading angular/angular-cli#11439, it seems to be a known issue that Angular’s optimizer breaks libraries.
from d3-color.
Hi,
I have just downgraded d3 to 4.13.0 and it works.
npm install [email protected]
from d3-color.
Can you share some code that reproduces the error? I can’t investigate from a stack trace or error message alone.
from d3-color.
Hi @mbostock ,
I am using d3 5.7.0 version and internal dependency package d3-color has got updated to 1.4.0 , after this update i am getting the same issue as mentioned above by @sriharshayedlapalli .
@mbostock please let us know the fix for the issue.
from d3-color.
Hi,
Same here. New update of d3-color (1.4.0) breaks my angular 7 app. The production build (--prod) does compile successfully but the app breaks and shows the OP message, it does however work with the dev build.
As a temp fix I reverted to 1.3.0 in the package.json.
from d3-color.
Thank you for the error reports. No one has yet provided a reproduction of this error, and thus I have no way of investigating. If this error is happening to you, please share a minimal reproduction so that we can determine the cause. Thank you.
from d3-color.
Same error for me.
is easy to reproduce:
- create any angular project (with angular cli)
- install d3
- use d3-color -> rgb function, importing it like this: import {rgb} from 'd3-color';
- build the application using ng build --prod
- the resulting application is broken. Where the rgb function is used will produce the error shown above.
If you need more detail I can help you to configure a workspace.
from d3-color.
Are you installing d3
and then importing from d3-color
? You should install d3-color
if you want to import from d3-color
.
I tried using the angular cli to reproduce this example, but I’ve never used Angular before, so while I was able to create a blank Angular project, I don’t know which files to edit, or how, to reproduce the problem. Sorry.
from d3-color.
@mbostock I need d3 in order to make graphical representations. Once I install d3, all related libraries are installed (d3-color, d3-*,...). I can see all of them in my node_modules. I was working under this way with no problem. When d3-color 1.4.0 has been released I started to get this error.
The next hours I will prepare a playground to experiment this error.
from d3-color.
Hi Mike
I uploaded an empty angular project with a basic d3 import (check app.component.ts) (https://github.com/goldieswx/d3color-angular.git)
Should you either serve it or build using the prod argument.
ng serve --prod
ng build --prod
Then the resulting app should crash with the OP stack trace
[Edit] I included the dist folder with the prebuilt app.
PS : It's always a pleasure to read your articles
from d3-color.
Hi, for me it fails only when optimizing the build (having "optimization=true" at angular.json). Maybe due to the uglification?
from d3-color.
Yes @dpinol but optimization is "required" when building for production
from d3-color.
Hello,
Using Angular 7.1.2, I have the same problem as sergidt. It seems that instead of the object color, only the property in hexadecimal is present.
Uncaught TypeError: e.rgb is not a function
from d3-color.
@sergidt What I meant is that you should either do this:
npm install d3-color
import {rgb} from "d3-color";
Or do this:
npm install d3
import {rgb} from "d3";
Never this:
npm install d3
import {rgb} from "d3-color";
from d3-color.
Thanks for the reproduction @goldieswx. As I see it, that code appears to be be missing these lines from color.js:
Lines 242 to 264 in 0b12fa0
Hence, the entire Rgb class is missing all its methods, not just rgb.rgb().
Is the Angular optimization interpreting the sideEffects: false flag added in d0a60ee differently? This was added as part of d3/d3#3131, under the interpretation that a package (such as d3-color) does not have side-effects as long as it does not modify anything outside of its package. Of course the modification of Rgb.prototype inside the color.js file is a side-effect, but it’s modifying something that was defined in the file itself, so it should be fine.
This appears to be an Angular issue.
from d3-color.
Can I use any alternative function similar to rgb?
from d3-color.
Hi,
@sergidt check @Ludo83 answer, this is how we fixed the issue.
from d3-color.
Ok, thanks mates
from d3-color.
Having same issue just appearing on 2 different angular projects : one in 7.xxx and other one on 8.xxx.
Both having the same issue using interpolateLab function. Doesn't that prove it's a d3 issues and not angular ?
from d3-color.
Hi,
it seems that the issue comes from "@angular-devkit/build-optimizer".By keeping "optimization=true" and passing "optimization=false", the issue doesn't appear anymore.
Upgrading Angular version (tried with "8.2.8") also upgrades "@angular-devkit/build-optimizer" and solves that (we can still keep "optimization=true" and "optimization="true" without generating this issue).
So the problem came from "@angular-devkit/build-optimizer" but not D3.
I think that this issue could be closed.
After searching whole day here and there this solution worked for me. Thanks a lot
from d3-color.
Related Issues (20)
- d3.rgb doesn't parse HSL hues with `deg` units HOT 1
- Changing color.s changes luminosity and color.l saturation.
- Security vulnerability fix for d3-color required in version 2.x HOT 7
- Security vulnerability fix for d3-color nice-to-have in version 1.x HOT 4
- Unexpected token 'export' while update from 2.x.x to 3.x.x HOT 2
- Why d3 uses illuminant D50 instead of D65? HOT 1
- d3.hsl doesnt seem to work with grey scale values HOT 2
- Alpha value of 0 breaks rgb HOT 1
- Add formatHex8() to include opacity HOT 7
- Brightening black in RGB HOT 3
- bug: hue is NaN when convert hsl HOT 2
- Unexpected conversion to HSL
- Incorrect conversion from HCL / LCH to hex or rgb HOT 2
- oklab / oklch? HOT 8
- More exports. HOT 9
- Doesn't work - color is not defined HOT 1
- Does the Common JS version of the module work? HOT 1
- Supporting CSS color level 4 HOT 3
- Avoid catastrophic backtracking when parsing HOT 11
- formatHex with alpha channel HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-color.