This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[graphviz] Implemented Graphviz for Angular; [package.json,package-lo…
…ck.json] Upgraded depdendencies; added d3-graphviz
- Loading branch information
1 parent
a9ae01e
commit 88569b2
Showing
11 changed files
with
545 additions
and
315 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
div { | ||
width: 100%; | ||
height: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div id="{{id}}"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { GraphvizComponent } from './graphviz.component'; | ||
|
||
describe('GraphvizComponent', () => { | ||
let component: GraphvizComponent; | ||
let fixture: ComponentFixture<GraphvizComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ GraphvizComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(GraphvizComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { AfterContentInit, AfterViewInit, Component, Input, OnInit } from '@angular/core'; | ||
|
||
import { graphviz, GraphvizOptions } from 'd3-graphviz'; | ||
|
||
@Component({ | ||
selector: 'app-graphviz', | ||
templateUrl: './graphviz.component.html', | ||
styleUrls: ['./graphviz.component.css'] | ||
}) | ||
export class GraphvizComponent implements OnInit, AfterViewInit, AfterContentInit { | ||
private static count = 0; | ||
private static defaultOptions: GraphvizOptions = { | ||
fit: true, | ||
height: 500, | ||
width: 1000, | ||
zoom: false, | ||
}; | ||
|
||
private id: string; | ||
|
||
@Input('graph') graph: string; | ||
|
||
private props: IGraphvizProps; | ||
|
||
constructor() { | ||
this.id = 'graphviz' + GraphvizComponent.count; | ||
this.renderGraph(); | ||
GraphvizComponent.count++; | ||
} | ||
|
||
ngOnInit() { | ||
this.props = { dot: this.graph }; | ||
this.renderGraph(); | ||
} | ||
|
||
ngAfterViewInit() { | ||
this.renderGraph(); | ||
} | ||
|
||
ngAfterContentInit() { | ||
this.renderGraph(); | ||
} | ||
|
||
private renderGraph() { | ||
if (!this.props || !this.props.dot) { | ||
this.props = { | ||
dot: this.graph | ||
}; | ||
} | ||
if (document.getElementById(this.id)) | ||
graphviz(`#${this.id}`) | ||
.options(this.options()) | ||
.renderDot(this.props.dot); | ||
} | ||
|
||
private options(): GraphvizOptions { | ||
if (!this.props.options) | ||
return GraphvizComponent.defaultOptions; | ||
|
||
const options: GraphvizOptions = GraphvizComponent.defaultOptions; | ||
for (const option of Object.keys(this.props.options)) | ||
options[option] = this.props.options[option]; | ||
|
||
return options; | ||
} | ||
} | ||
|
||
export interface IGraphvizProps { | ||
dot: string; | ||
options?: GraphvizOptions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { GraphvizComponent } from './graphviz.component'; | ||
|
||
|
||
|
||
@NgModule({ | ||
declarations: [GraphvizComponent], | ||
imports: [ | ||
CommonModule | ||
], | ||
exports: [GraphvizComponent] | ||
}) | ||
export class GraphvizModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters