title: Cytoscape cannot read property 'className' of null
body: <p>I am trying to integrate cytoscape in angular application.</p>
  
  <p>First of all I downloaded:</p>
  
  <pre><code>npm i --save ngx-cytoscape cytoscape @types/cytoscape
  </code></pre>
  
  <p>then I imported Cytoscape library into module</p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { CommonModule } from '@angular/common';
  import { ItemComponent } from './item/item.component';
  
  import { CytoscapeModule } from 'ngx-cytoscape';
  
  @NgModule({
    imports: [
      CommonModule,
      CytoscapeModule
    ],
    declarations: [
      ItemComponent
    ]
  })
  export class DashboardModule { }
  </code></pre>
  
  <p>and updated Angular.json</p>
  
  <pre><code>"scripts": [
                "node_modules/jquery/dist/jquery.min.js",
                "node_modules/bootstrap/dist/js/bootstrap.min.js",
                "node_modules/cytoscape/dist/cytoscape.js"
              ]
  </code></pre>
  
  <p>From now I can use cytoscape<br/>
  This is my html</p>
  
  <pre><code>&lt;div id="cy" class='row justify-content-center cytograph mt-2' *ngIf="graphData"&gt;
    &lt;ngx-cytoscape [elements]="graphData"&gt;&lt;/ngx-cytoscape&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is my typescript file</p>
  
  <pre><code>@Component({
      selector: 'app-item',
      templateUrl: './item.component.html',
      styleUrls: ['./item.component.css']
  })
  export class ItemComponent {
      traces: Trace[];
  
      private _graphData: any;
  
      constructor(
          private traceService: TraceService
      ) { }
  
      // event that triggers when button is clicked
      showDetails(correlationId: string): void {
          this.traceService.findByCorrelationId(correlationId)
              .subscribe(
                  (traces) =&gt; {
                      this.traces = traces;
                  },
                  (error) =&gt; {
                      // error handling
                  },
                  () =&gt; {
                      this.createGraphData();
                  }
              );
      }
  
      createGraphData(): void {
          const nodes: Node[] = [];
          const edges: Edge[] = [];
          // some logic...
          this._graphData = cytoscape ({ container: document.getElementById('cy'), elements: {nodes, edges }});
      }
  
      get graphData(): any {
          return this._graphData;
      }
  
      set graphData(value: any) {
          this._graphData = value;
      }
  }
  </code></pre>
  
  <p>The problem is this line of code</p>
  
  <pre><code>this._graphData = cytoscape ({ container: document.getElementById('cy'), elements: {nodes, edges }});
  </code></pre>
  
  <p>When I create _graphData <a href="https://github.com/calvinvette/ngx-cytoscape/blob/master/cytodemo/cytodemo.component.ts" rel="nofollow noreferrer">accoring to ngx-cytoscape documentation</a> like this:</p>
  
  <pre><code>this._graphData = { nodes, edges };
  </code></pre>
  
  <p>everything works perfectly the problem is I don't know how to apply 'styles' ngx demo works however they are not showing how to access style [].</p>
  
  <p>When I try to follow this demo <a href="http://embed.plnkr.co/O7mWEfZuIhhtahdAhsAM/" rel="nofollow noreferrer">http://embed.plnkr.co/O7mWEfZuIhhtahdAhsAM/</a> and wrap _graphData into cytoscape object in order to have acces to "style []" I get following error:</p>
  
  <blockquote>
    <p>TypeError: cannot read property 'className' of null</p>
  </blockquote>
  
  <p>Any idea what I am doing wrong or how to apply styles in cytoscape in angular application ?
  Thanks</p>