Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
[graphviz] Implemented Graphviz for Angular; [package.json,package-lo…
Browse files Browse the repository at this point in the history
…ck.json] Upgraded depdendencies; added d3-graphviz
  • Loading branch information
SamuelMarks committed Sep 15, 2019
1 parent a9ae01e commit 88569b2
Show file tree
Hide file tree
Showing 11 changed files with 545 additions and 315 deletions.
625 changes: 366 additions & 259 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 22 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glaucoma-risk-calculator-analytics-web-frontend",
"version": "0.0.20",
"version": "0.0.21",
"description": "Analytics and administrator interface for the glaucoma-risk-calculator",
"repository": {
"url": "https://github.com/SamuelMarks/glaucoma-risk-calculator-analytics-web-frontend"
Expand All @@ -16,47 +16,49 @@
"test": "ng test"
},
"dependencies": {
"@angular/animations": "~8.2.3",
"@angular/cdk": "~8.1.3",
"@angular/common": "~8.2.3",
"@angular/compiler": "~8.2.3",
"@angular/core": "~8.2.3",
"@angular/animations": "~8.2.6",
"@angular/cdk": "~8.2.0",
"@angular/common": "~8.2.6",
"@angular/compiler": "~8.2.6",
"@angular/core": "~8.2.6",
"@angular/flex-layout": "^8.0.0-beta.26",
"@angular/forms": "~8.2.3",
"@angular/material": "^8.1.3",
"@angular/platform-browser": "~8.2.3",
"@angular/platform-browser-dynamic": "~8.2.3",
"@angular/router": "~8.2.3",
"@angular/forms": "~8.2.6",
"@angular/material": "^8.2.0",
"@angular/platform-browser": "~8.2.6",
"@angular/platform-browser-dynamic": "~8.2.6",
"@angular/router": "~8.2.6",
"@swimlane/ngx-charts": "^12.0.1",
"d3-graphviz": "^2.6.1",
"gauge-chart": "https://api.github.com/repos/glaucoma-australia/gauge-chart/tarball/master",
"glaucoma-risk-calculator-engine": "https://api.github.com/repos/glaucoma-australia/glaucoma-risk-calculator-engine-dist/tarball",
"hammerjs": "^2.0.8",
"mat-datetimepicker": "https://github.com/SamuelMarks/mat-datetimepicker/releases/download/ng8/mat-datetimepicker.tar.gz",
"moment": "^2.24.0",
"moment-timezone": "^0.5.26",
"rxjs": "~6.5.2",
"rxjs": "~6.5.3",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.0",
"@angular/cli": "~8.3.0",
"@angular/compiler-cli": "~8.2.3",
"@angular/language-service": "~8.2.3",
"@angular-devkit/build-angular": "~0.803.4",
"@angular/cli": "~8.3.4",
"@angular/compiler-cli": "~8.2.6",
"@angular/language-service": "~8.2.6",
"@types/d3-selection": "^1.4.1",
"@types/jasmine": "~3.4.0",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~12.7.2",
"@types/node": "~12.7.5",
"codelyzer": "^5.1.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.2.0",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.2",
"ts-node": "~8.3.0",
"tslint": "~5.19.0",
"typescript": "~3.5.3"
"tslint": "~5.20.0",
"typescript": ">=3.4.0 <3.6.0"
}
}
1 change: 1 addition & 0 deletions src/api/py_analytics/analytics.services.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface IPyAnalyticsResponse {
behaviour_change: IBehaviourChange;
ethnicity: IEthnicity;
};
big_xgb_gv: string;
_out: string;
}

Expand Down
72 changes: 38 additions & 34 deletions src/app/analytics/analytics.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,42 +85,46 @@
<div fxLayout="row" style="padding: 30px 0" fxLayoutGap="20px" *ngIf="pyAnalyticsData">
<div fxFlex="100" fxLayout="row" fxLayout.lt-sm="column" fxLayoutGap="20px">
<mat-card fxFlex>
<mat-card-content fxFlex>
<dt>client_risk magnitude</dt>
<dd>
<app-mag-table [dataSource]="clientRiskMagTable"></app-mag-table>
</dd>
<mat-card-content fxFlex="100" fxLayout="column" fxLayoutGap="20px">
<div fxFlex>
<dt>client_risk magnitude</dt>
<dd>
<app-mag-table [dataSource]="clientRiskMagTable"></app-mag-table>
</dd>

<dt>perceived_risk magnitude</dt>
<dd>
<app-mag-table [dataSource]="perceivedRiskMagTable"></app-mag-table>
</dd>
<dt>perceived_risk magnitude</dt>
<dd>
<app-mag-table [dataSource]="perceivedRiskMagTable"></app-mag-table>
</dd>

<dt>behaviour_change</dt>
<dd>
<table mat-table [dataSource]="behaviourChangeTable" style="width: 100%">
<!-- as_recommended Column -->
<ng-container matColumnDef="as_recommended">
<th mat-header-cell *matHeaderCellDef> as_recommended</th>
<td mat-cell *matCellDef="let element"> {{element.as_recommended}} </td>
</ng-container>

<!-- less_likely Column -->
<ng-container matColumnDef="less_likely">
<th mat-header-cell *matHeaderCellDef> less_likely</th>
<td mat-cell *matCellDef="let element"> {{element.less_likely}} </td>
</ng-container>

<!-- no_change Column -->
<ng-container matColumnDef="no_change">
<th mat-header-cell *matHeaderCellDef> no_change</th>
<td mat-cell *matCellDef="let element"> {{element.no_change}} </td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="behaviourChangeColumns"></tr>
<tr mat-row *matRowDef="let row; columns: behaviourChangeColumns;">{{row}}</tr>
</table>
</dd>
<dt>behaviour_change</dt>
<dd>
<table mat-table [dataSource]="behaviourChangeTable" style="width: 100%">
<!-- as_recommended Column -->
<ng-container matColumnDef="as_recommended">
<th mat-header-cell *matHeaderCellDef> as_recommended</th>
<td mat-cell *matCellDef="let element"> {{element.as_recommended}} </td>
</ng-container>

<!-- less_likely Column -->
<ng-container matColumnDef="less_likely">
<th mat-header-cell *matHeaderCellDef> less_likely</th>
<td mat-cell *matCellDef="let element"> {{element.less_likely}} </td>
</ng-container>

<!-- no_change Column -->
<ng-container matColumnDef="no_change">
<th mat-header-cell *matHeaderCellDef> no_change</th>
<td mat-cell *matCellDef="let element"> {{element.no_change}} </td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="behaviourChangeColumns"></tr>
<tr mat-row *matRowDef="let row; columns: behaviourChangeColumns;">{{row}}</tr>
</table>
</dd>
</div>

<app-graphviz fxFlex [graph]="pyAnalyticsData.big_xgb_gv"></app-graphviz>
</mat-card-content>
</mat-card>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/app/analytics/analytics.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { analyticsRoutes } from './analytics.routes';
import { MagTableComponent } from '../mag-table/mag-table.component';
import { CiTableComponent } from '../ci-table/ci-table.component';
import { NoTotalPipe } from '../no-total.pipe';
import { GraphvizModule } from '../graphviz/graphviz.module';


@NgModule({
Expand All @@ -56,7 +57,7 @@ import { NoTotalPipe } from '../no-total.pipe';
MatPaginatorModule, MatSnackBarModule, MatTableModule,
MatTabsModule, NgxChartsModule,

DateRangeModule
DateRangeModule, GraphvizModule
],
providers: [
RiskResService, AnalyticsService, PyAnalyticsService,
Expand Down
4 changes: 4 additions & 0 deletions src/app/graphviz/graphviz.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
div {
width: 100%;
height: 100%;
}
1 change: 1 addition & 0 deletions src/app/graphviz/graphviz.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id="{{id}}"></div>
25 changes: 25 additions & 0 deletions src/app/graphviz/graphviz.component.spec.ts
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();
});
});
71 changes: 71 additions & 0 deletions src/app/graphviz/graphviz.component.ts
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;
}
14 changes: 14 additions & 0 deletions src/app/graphviz/graphviz.module.ts
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 { }
2 changes: 1 addition & 1 deletion src/app/server-status/server-status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ServerStatusComponent implements OnInit {
private alertsService: AlertsService) {}

ngOnInit() {
this.serverStatus = { version: '@ 0.0.20; ' };
this.serverStatus = { version: '@ 0.0.21; ' };
forkJoin([
this.serverStatusService
.get(),
Expand Down

0 comments on commit 88569b2

Please sign in to comment.