question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] [Angular] "Missing CSS styles for Carbon Charts.."-error after rerendering

See original GitHub issue

I am submitting a…

  • Design defect or
  • Source code defect not sure.

charts version:

@carbon/charts: 0.41.41 @carbon/charts-angular: 0.41.41

if relevant: Angular: ^10.0.0 carbon-components: ^10.30.0 carbon-components-angular: ^4.41.0"

Issue description

We use carbon charts for a statistic dashboard where we load the full dashboard information on startup as a JSON from our API and build the components based on that JSON (rows, cols, charts). When the dashboard is initially loading, everything works fine.

But we have simple functionality to refresh the dashboard, where the hole dashboard is loaded again from our API and the dashboard property of our main component is then updated with the new value. In Angular 8, everything worked fine and everything got rerendered correctly, but since updating to Angular 10 when the dashboard is rerendered due to the change of the main components property, the charts are broken and we get the “Missing CSS styles for Carbon Charts. Please read the Carbon Charts getting started guide.”-error.

Did something change in the rerendering behavior of angular from 8 to 10 or carbon-charts after a property changes?

I tried a lot to fix this issue, even trying to add the checked CSS-properties to the <g>-Tag in the svg (I know i shouldn’t) which produces the missing-styles-error. But I can’t figure out where things go wrong.

Any idea or help would be much appreciated!

Steps to produce the issue

short version of the current code, don`t know what else I could share:

(Main Component) dashboard-shell.html

<div ibmGrid>
  <app-block-row-view
	ibmRow
	*ngFor="let blockRow of dashboard.rows; index as currentBlockRowIdx"
	[blockRow]=blockRow
	[currentBlockRowIdx]=currentBlockRowIdx
	[parentDashboardComponent]=this>
  </app-block-row-view>
</div>

dashboard-shell.ts

export class DashboardShellComponent implements OnInit, AfterViewInit {
  @Input() dashboard: Dashboard;

  ...

  loadDashboard(): void {
    // http-request to our API to get JSON converted to Dashboard-Type
    this.dashboard = response.json;
  }

app-block-row-view.html

<app-block-view ibmCol [columnNumbers]="{'sm': block.smallGridColumns, 'md': block.mediumGridColumns, 'lg': block.largeGridColumns}"
	*ngFor="let block of blockRow.blocks; index as currentBlockIdx"
	[ngStyle]="{
		'padding-bottom': '16px',
		'padding-top': '16px'
	}"
	[block]=block
	[currentBlockIdx]=currentBlockIdx>
</app-block-view>

(nothing interesting in .ts)


app-block-view.html

<app-diagram-view
	*ngFor="let diagram of block.charts; index as currentDiagramIdx"
	[ngStyle]="{}"
	[diagram]=diagram
	[currentDiagramIdx]=currentDiagramIdx
	[parentBlock]=block>
</app-diagram-view>

(nothing interesting in .ts)


app-diagram-view.html

<ibm-tile>
  <div id="diagram-{{ this.diagram.$hash }}"></div>
</ibm-tile>

app-diagram-view-ts

export class DiagramViewComponent implements OnInit, AfterViewInit {
  @Input() diagram: Diagram;
  private chart: any;

  ...

  ngAfterViewInit() {
    ...
    const chartHolder = document.getElementById(
      `diagram-${this.diagram.$hash}`
    );

   // ommited the other charts
   switch (this.diagram.type) {
      case DiagramType.Line: // Custom Enum
        this.chart = new LineChart(chartHolder, {
          data: this.diagram.data,
          options: this.diagram.options,
        });
        
        break;
        ...
    }

Current behavior

On rerendering the charts, we get the “Missing CSS styles for Carbon Charts. Please read the Carbon Charts getting started guide.” error.

Expected behavior

All charts should be rerendered without an error after the main property is changed

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
code-asylumcommented, Aug 18, 2021

I’m sorry that I wasn’t responsive for so long. With the latest carbon-charts(-angular) Version and litte changes to the refresh logic we managed to solve this bug and charts are getting refreshed/repainted properly.

Thanks very much!

1reaction
number-00commented, May 12, 2021

Hi, Is there any way to disable the validator? I am also facing same issue intermittently in react. I have also tried manually adding the min css file, but the error still comes and the complete page goes blank.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing CSS styles for Carbon Charts. Please read the ...
I am importing the css in app.scss which is imported in index.js. @import '~@carbon/charts/styles.css';. It works when I execute the code on ......
Read more >
[Bug]: Sample for @carbon/charts-angular TreeMap does not ...
The JavaScript console says "dom-utils.js:334 Missing CSS styles for Carbon Charts. Please read the Carbon Charts getting started guide.".
Read more >
@carbon/charts - npm
Run the following command using npm: npm install -S @carbon/charts d3. If you prefer Yarn, use the following command instead: yarn add @carbon/charts...
Read more >
crT - River Thames Conditions - Environment Agency - GOV.UK
Ivf cambridgeshire pct, Keep the lights on soundtrack youtube, Micro d'enregistrement pro! Romantic times square restaurants, Beschikte, Best zing bow, ...
Read more >
Get started - Carbon Design System
Get started with Carbon Charts in Vanilla. ... bug fixes, and feature requests to the Carbon Charts core team. ... import '@carbon/charts/styles.css';.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found