Skip to content

Commit b6ed5b3

Browse files
committed
Changed the circular heatmap section to grey for the sub-dimension that have no tasks for that level
1 parent a1e0ff3 commit b6ed5b3

1 file changed

Lines changed: 32 additions & 22 deletions

File tree

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

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import { Component, OnInit } from '@angular/core';
22
import { ymlService } from '../../service/yaml-parser/yaml-parser.service';
33
import * as d3 from 'd3';
44

5-
export interface task{
5+
export interface taskSchema{
66
name:string
77
done:boolean
88
}
99

10-
export interface dataset{
10+
export interface cardSchema{
1111
Name:string
1212
Level:string
1313
"Done%":number
14-
Task:task[]
14+
Task:taskSchema[]
1515
}
1616

1717
@Component({
@@ -25,8 +25,7 @@ export class CircularHeatmapComponent implements OnInit {
2525
header:string=''
2626
subheader:string=''
2727
tasks:any[]=[]
28-
tempdata:dataset[]=[]
29-
data:dataset[] =[];
28+
data:cardSchema[] =[];
3029
radial_labels:string[]= [];
3130
YamlObject:any;
3231
segment_labels:string[] = [];
@@ -58,34 +57,35 @@ export class CircularHeatmapComponent implements OnInit {
5857
}
5958
for(var l=0 ; l<this.maxLevel; l++){
6059
for(var x in this.YamlObject['dimension']){
61-
var tempdata:dataset={
60+
var tempdata:cardSchema={
6261
"Name": "",
6362
"Level": "",
64-
"Done%":0,
63+
"Done%":-1,
6564
"Task":[]
6665
}
67-
var totalDone:number=0
66+
var totalImplemented:number=0
6867
try{
6968
tempdata["Name"]=this.YamlObject['dimension'][x]['subdimension']['name']
7069
tempdata["Level"]="Level "+(l+1)
7170
for(var i=0;i<this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)].length;i++){
7271
var nameOfTask=this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)][i]['name']
7372
var Status:boolean=this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)][i]['isImplemented']
7473
if(Status){
75-
totalDone+=1
74+
totalImplemented+=1
7675
}
7776
tempdata["Task"].push({"name":nameOfTask,"done":Status})
7877
}
79-
tempdata["Done%"]=totalDone/this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)].length
78+
tempdata["Done%"]=totalImplemented/this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)].length
8079
}
8180
catch{
82-
tempdata["Done%"]=0
81+
tempdata["Done%"]=-1
8382
}
8483
this.data.push(tempdata)
8584
}
8685
}
8786
console.log(this.data)
8887
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
88+
this.noTasktoGrey()
8989
})
9090
}
9191

@@ -190,9 +190,9 @@ export class CircularHeatmapComponent implements OnInit {
190190
// increase the segment height of the one being hovered as well as all others of the same date
191191
// while decreasing the height of all others accordingly
192192
//console.log(d)
193-
d3.selectAll("#segment-" + curr.Name+'-'+curr.Level.replaceAll(' ','-')).attr("fill", function(p) {
194-
return "white"
195-
});
193+
if(curr["Done%"]!=-1){
194+
d3.selectAll("#segment-" + curr.Name+'-'+curr.Level.replaceAll(' ','-')).attr("fill","white")
195+
};
196196

197197
})
198198

@@ -204,13 +204,17 @@ export class CircularHeatmapComponent implements OnInit {
204204
// var segment = d3.select("#segment-"+d.Day +"-"+timeCleaned); //designate selector variable for brevity
205205
// var fillcolor = segment.select("desc").text(); //access original color from desc
206206
// segment.style("fill", fillcolor);
207-
208-
d3.selectAll("#segment-" + curr.Name+'-'+curr.Level.replaceAll(' ','-')).attr("fill", function(p) {
209-
var color = d3.scaleLinear<string,string>().domain([0,1]).range(["white", "green"]);
210-
// how to access a function within reusable charts
211-
//console.log(color(d.Done));
212-
return color(curr["Done%"]);
213-
});
207+
if(curr["Done%"]!=-1){
208+
d3.selectAll("#segment-" + curr.Name+'-'+curr.Level.replaceAll(' ','-')).attr("fill", function(p) {
209+
var color = d3.scaleLinear<string,string>().domain([0,1]).range(["white", "green"]);
210+
// how to access a function within reusable charts
211+
//console.log(color(d.Done));
212+
return color(curr["Done%"]);
213+
});
214+
}
215+
else{
216+
d3.selectAll("#segment-" + curr.Name+'-'+curr.Level.replaceAll(' ','-')).attr("fill", "#DCDCDC");
217+
}
214218
})
215219
}
216220

@@ -379,6 +383,12 @@ export class CircularHeatmapComponent implements OnInit {
379383
return chart;
380384
}
381385

382-
386+
noTasktoGrey():void{
387+
for (var x in this.data){
388+
if (this.data[x]["Done%"]==-1){
389+
d3.selectAll("#segment-" + this.data[x]["Name"]+'-'+this.data[x]["Level"].replace(' ','-')).attr("fill","#DCDCDC");
390+
}
391+
}
392+
}
383393

384394
}

0 commit comments

Comments
 (0)