-
Notifications
You must be signed in to change notification settings - Fork 189
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
[Bug]: Sample for @carbon/charts-angular TreeMap does not work with latest Angular #1298
Comments
Is @carbon-charts@0.54.11 not compatible with Angular 13? |
Hi, pls read our angular getting started guide. https://charts.carbondesignsystem.com/?path=/story/docs-getting-started--angular Also you need to import styles in a place where it'll actually take effect. I usually try |
Feel free to reply with additional comments 🙂 |
I did read it. Do you see where I made a mistake? |
Your Now regarding the styles, if you've imported it and it still isn't looking correct, I would assume that the styles aren't being applied. I would try importing in a different file (this doesn't seem like a bug, just a matter of your css styles not being properly applied onto the page) Pls try the above and lmk if you're still having issues 🙂 |
Just got it working with Angular 13 but it's different from what's on the Carbon Charts Angular documentation website for TreeMap. File: package.json (had to do an {
"name": "my-treemap",
"version": "0.0.1",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.2.1",
"@angular/common": "~13.2.1",
"@angular/compiler": "~13.2.1",
"@angular/core": "~13.2.1",
"@angular/forms": "~13.2.1",
"@angular/platform-browser": "~13.2.1",
"@angular/platform-browser-dynamic": "~13.2.1",
"@angular/router": "~13.2.1",
"@carbon/charts": "^0.54.12",
"@carbon/charts-angular": "^0.54.12",
"@carbon/themes": "^10.50.0",
"carbon-components": "^10.52.0",
"rxjs": "~7.5.2",
"tslib": "^2.3.1",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.2.2",
"@angular/cli": "~13.2.2",
"@angular/compiler-cli": "~13.2.1",
"@types/jasmine": "~3.10.3",
"@types/node": "^17.0.15",
"jasmine-core": "~4.0.0",
"karma": "~6.3.15",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.1",
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.5.5"
}
} Note: had to install carbon-components and @carbon/themes. File: /src/styles.scss (could have loaded some of this from app.component.scss I suppose): @import "https://fonts.googleapis.com/css?family=IBM+Plex+Sans+Condensed|IBM+Plex+Sans:400,600&display=swap";
@import '@carbon/themes/scss/themes';
@import 'carbon-components/scss/globals/scss/styles.scss';
@import "@carbon/charts/styles/styles.scss"; Would it make sense to:
|
I'll think on this some more. It's tough to provide angular code samples when they keep releasing so many new versions. I think they key takeaway of our code samples could be the essentials of how you'd use the library in angular, rather than angular-specific or version-specific code that you can just copy & paste. |
I did manage to get a v13-compatible build process. Tested the bundle on codesandbox and charts work smoothly. However, storybook is not working now, and I'm having a hard time figuring out why. There are also not too many examples on storybook's website for angular 13. Just found this PR storybookjs/storybook#17387 WIP PR #1304 |
Awesome - thanks! I've been able to put together a decent example using @carbon/charts-angular's TreeMapComponent including rounding the rects. One thing I didn't spot in the docs... is there a way to add space between the rects? Looked through the component's properties and didn't see anything. Did I miss something or will I have to manipulate the rects directly in the DOM? |
Not currently. I think we'd need to add this as a customizable https://github.com/d3/d3-hierarchy/blob/main/README.md#treemap_padding This makes me think... maybe we should expose the treemap object itself so devs can add their own customizations as well |
That would be great. I've had the opportunity to try a variety of treemaps - Apex, Google Charts, and Carbon Charts. In my opinion, Carbon Charts compares very favorably. Carbon Charts provides a lot of control around assigning colors to groups which was critical for our use-case. We also need to adjust look and feel so I also appreciate the leaf class being assigned to each rect. Made it easy to put them all in an array with a simple |
Glad to know that! I've got lots more I want to do here, if I get to it. I'll keep thinking about those further customizations |
Perhaps of interest... my repo experimenting with the Angular version of the treemap... |
Solved in |
Contact Details
nstuyvesant@gmail.com
What happened?
Followed steps on https://charts.carbondesignsystem.com/angular/?path=/story/complex-charts-treemap--treemap for TreeMap with these exceptions:
npx @angular/cli new my-treemap --style=scss cd my-treemap npm install --save @carbon/charts@0.54.11 @carbon/charts-angular@0.54.11 d3@7.0.0
System:
OS: macOS 12.2
CPU: (10) arm64 Apple M1 Pro
Memory: 429.22 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.2 - /opt/homebrew/bin/node
npm: 8.3.2 - /opt/homebrew/bin/npm
Browsers:
Chrome: 97.0.4692.99
Safari: 15.3
Angular: 13.2.1
When I run Angular in dev mode:
I get...
So then I install carbon-components
npm install --save carbon-components@10.52.0
and tryng serve
again. Now it runs but looks horrible. The JavaScript console says "dom-utils.js:334 Missing CSS styles for Carbon Charts. Please read the Carbon Charts getting started guide."plex-and-carbon-components.css:
Version
@carbon/charts@0.54.11
@carbon/charts-angular@0.54.11
Data & options used
No response
Relevant log output
Codesandbox example
No response
The text was updated successfully, but these errors were encountered: