Skip to content

Commit b02d476

Browse files
committed
Added expansion of fields in implementation by clicking on it + Initial commit for dependency tree
1 parent 984dfe6 commit b02d476

9 files changed

Lines changed: 177 additions & 5 deletions

File tree

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { MappingComponent } from './component/mapping/mapping.component';
2020
import { ReadmeToHtmlComponent } from './component/readme-to-html/readme-to-html.component';
2121
import { UsageComponent } from './component/usage/usage.component';
2222
import { AboutUsComponent } from './component/about-us/about-us.component';
23+
import { TreeMapComponent } from './component/tree-map/tree-map.component';
2324

2425

2526
@NgModule({
@@ -36,6 +37,7 @@ import { AboutUsComponent } from './component/about-us/about-us.component';
3637
ReadmeToHtmlComponent,
3738
UsageComponent,
3839
AboutUsComponent,
40+
TreeMapComponent,
3941

4042
],
4143
imports: [

src/app/component/circular-heatmap/circular-heatmap.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export class CircularHeatmapComponent implements OnInit {
234234
//console.log(_self.tasksData)
235235
})
236236
.on('mouseover', function(d) {
237-
console.log(d.toElement.__data__.Name)
237+
//console.log(d.toElement.__data__.Name)
238238
try{
239239
curr=d.explicitOriginalTarget.__data__
240240
}

src/app/component/matrix/matrix.component.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ button{
3131
background-color: white;
3232
border: none;
3333
text-align: left;
34+
cursor:pointer;
3435
}
3536

src/app/component/matrix/matrix.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<li *ngFor="let task of element[lvl]; index as j" >
5252
<button (click)="navigate(element.Dimension,element.SubDimension,i+1,task)">
5353
{{task}}
54-
</button>
54+
</button>
5555
</li>
5656
</ul>
5757
</td>

src/app/component/task-description/task-description.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ <h1>{{currentTask.dimension}} -> {{currentTask.subDimension}}: {{currentTask.tas
6363
</mat-expansion-panel-header>
6464
<p>
6565
<mat-accordion multi="true">
66-
<mat-expansion-panel>
66+
<mat-expansion-panel [expanded]="true">
6767
<mat-expansion-panel-header>
6868
<mat-panel-title>
6969
<b>Tags</b>
@@ -73,15 +73,15 @@ <h1>{{currentTask.dimension}} -> {{currentTask.subDimension}}: {{currentTask.tas
7373
<li [innerHTML]="tag"></li>
7474
</ul>
7575
</mat-expansion-panel>
76-
<mat-expansion-panel>
76+
<mat-expansion-panel [expanded]="true">
7777
<mat-expansion-panel-header>
7878
<mat-panel-title>
7979
<b>URL</b>
8080
</mat-panel-title>
8181
</mat-expansion-panel-header>
8282
<p [innerHTML]="implement['url']"></p>
8383
</mat-expansion-panel>
84-
<mat-expansion-panel>
84+
<mat-expansion-panel [expanded]="true">
8585
<mat-expansion-panel-header>
8686
<mat-panel-title>
8787
<b>Description</b>
@@ -134,6 +134,7 @@ <h1>{{currentTask.dimension}} -> {{currentTask.subDimension}}: {{currentTask.tas
134134
</mat-expansion-panel-header>
135135
<ul *ngFor="let dependency of this.currentTask.dependsOn">
136136
<li>{{dependency}}</li>
137+
<app-tree-map></app-tree-map>
137138
</ul>
138139
</mat-expansion-panel>
139140
</mat-accordion>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
body {
2+
background-color: #eee;
3+
}
4+
5+
.node circle {
6+
fill: #fff;
7+
stroke: steelblue;
8+
stroke-width: 3px;
9+
}
10+
11+
.node text { font: 16px sans-serif; }
12+
13+
.link {
14+
15+
stroke: #ccc;
16+
stroke-width: 2px;
17+
fill: none;
18+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div id="tree">
2+
3+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { TreeMapComponent } from './tree-map.component';
4+
5+
describe('TreeMapComponent', () => {
6+
let component: TreeMapComponent;
7+
let fixture: ComponentFixture<TreeMapComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ TreeMapComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(TreeMapComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import * as d3 from 'd3';
3+
4+
@Component({
5+
selector: 'app-tree-map',
6+
templateUrl: './tree-map.component.html',
7+
styleUrls: ['./tree-map.component.css']
8+
})
9+
export class TreeMapComponent implements OnInit {
10+
11+
treeData = {
12+
"name": "Eve",
13+
"value": 15,
14+
"children": [
15+
{
16+
"name": "Cain",
17+
"value": 10,
18+
},
19+
{
20+
"name": "Seth",
21+
"value": 10,
22+
"children": [
23+
{
24+
"name": "Enos",
25+
"value": 7.5,
26+
},
27+
{
28+
"name": "Noam",
29+
"value": 7.5,
30+
}
31+
]
32+
},
33+
{
34+
"name": "Abel",
35+
"value": 10,
36+
},
37+
{
38+
"name": "Awan",
39+
"value": 10,
40+
"children": [
41+
{
42+
"name": "Enoch",
43+
"value": 7.5,
44+
}
45+
]
46+
},
47+
{
48+
"name": "Azura",
49+
"value": 10,
50+
}
51+
]
52+
};
53+
54+
constructor() { }
55+
56+
ngOnInit(): void {
57+
this.generateTree()
58+
}
59+
60+
generateTree():void{
61+
// set the dimensions and margins of the diagram
62+
const margin = {top: 20, right: 90, bottom: 30, left: 90},
63+
width = 660 - margin.left - margin.right,
64+
height = 500 - margin.top - margin.bottom;
65+
66+
// declares a tree layout and assigns the size
67+
const treemap = d3.tree().size([height, width]);
68+
69+
// assigns the data to a hierarchy using parent-child relationships
70+
var nodes:any = d3.hierarchy(this.treeData, (d:any) => d.children);
71+
72+
// maps the node data to the tree layout
73+
nodes = treemap(nodes);
74+
75+
// append the svg object to the body of the page
76+
// appends a 'group' element to 'svg'
77+
// moves the 'group' element to the top left margin
78+
const svg = d3.select("#tree").append("svg")
79+
.attr("width", width + margin.left + margin.right)
80+
.attr("height", height + margin.top + margin.bottom),
81+
g = svg.append("g")
82+
.attr("transform",
83+
"translate(" + margin.left + "," + margin.top + ")");
84+
85+
// adds the links between the nodes
86+
const link = g.selectAll(".link")
87+
.data( nodes.descendants().slice(1))
88+
.enter().append("path")
89+
.attr("class", "link")
90+
.style("stroke", "black")
91+
.style("fill","none")
92+
.attr("d", (d:any) => {
93+
return "M" + d.y + "," + d.x
94+
+ "C" + (d.y + d.parent.y) / 2 + "," + d.x
95+
+ " " + (d.y + d.parent.y) / 2 + "," + d.parent.x
96+
+ " " + d.parent.y + "," + d.parent.x;
97+
});
98+
99+
// adds each node as a group
100+
const node = g.selectAll(".node")
101+
.data(nodes.descendants())
102+
.enter().append("g")
103+
.attr("class", (d:any) => "node" + (d.children ? " node--internal" : " node--leaf"))
104+
.attr("transform", (d:any) => "translate(" + d.y + "," + d.x + ")");
105+
106+
// adds the circle to the node
107+
node.append("circle")
108+
.attr("r", (d:any) => d.data.value)
109+
.style("stroke", "black")
110+
.style("fill", "green");
111+
112+
// adds the text to the node
113+
node.append("text")
114+
.attr("dy", ".35em")
115+
.attr("x", (d:any) => d.children ? (d.data.value + 5) * -1 : d.data.value + 5)
116+
.attr("y", (d:any) => d.children && d.depth !== 0 ? -(d.data.value + 5) : d)
117+
.style("text-anchor", (d:any) => d.children ? "end" : "start")
118+
.text((d:any) => d.data.name);
119+
}
120+
121+
122+
}

0 commit comments

Comments
 (0)