Skip to content

Commit 14df6df

Browse files
committed
Automatic color changes and hot reload of heatmap
1 parent d915bdd commit 14df6df

3 files changed

Lines changed: 13 additions & 16 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
background-color: aquamarine;
1212
}
1313
.example-card {
14-
display:block;
15-
opacity: 2;
16-
background-color:orange;
1714
float: right;
1815
width:25%;
1916
margin:5%;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<div *ngIf="task.done; then trueBlock else falseBlock"></div>
1414
<p>
1515
<ng-template #trueBlock>
16-
<mat-checkbox (click)="this.checkboxToggle(i)" [checked]="true">
16+
<mat-checkbox (click)="this.checkboxToggle(i)" [checked]="true" color="primary">
1717
{{task["name"]}}
1818
</mat-checkbox>
1919
</ng-template>
2020
<ng-template #falseBlock>
21-
<mat-checkbox (click)="this.checkboxToggle(i)" [checked]="false">
21+
<mat-checkbox (click)="this.checkboxToggle(i)" [checked]="false" color="primary">
2222
{{task["name"]}}
2323
</mat-checkbox>
2424
</ng-template>

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class CircularHeatmapComponent implements OnInit {
125125

126126
checkboxToggle(taskIndex:number){
127127
//console.log('fo')
128+
let _self=this
128129
var index=0;
129130
var cnt=0;
130131
for(var i=0;i<this.data.length;i++){
@@ -148,7 +149,12 @@ export class CircularHeatmapComponent implements OnInit {
148149
}
149150
this.data[index]['Done%']=cnt/this.data[index]["Task"].length
150151
//console.log(this.data[index]['Done%'],cnt)
152+
var color = d3.scaleLinear<string,string>().domain([0,1]).range(["white", "green"]);
153+
151154
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
155+
d3.selectAll("#segment-" + this.data[index]["Name"]+'-'+this.data[index]["Level"].replaceAll(' ','-')).attr("fill", function(p) {
156+
return color(_self.data[index]["Done%"])
157+
});
152158

153159
}
154160

@@ -223,9 +229,7 @@ export class CircularHeatmapComponent implements OnInit {
223229
});
224230

225231
})
226-
.on('mousemove', function(d,event) {
227-
228-
})
232+
229233
.on('mouseout', function(d) {
230234
//console.log(d.explicitOriginalTarget.__data__.Day)
231235

@@ -236,16 +240,12 @@ export class CircularHeatmapComponent implements OnInit {
236240
// segment.style("fill", fillcolor);
237241

238242
d3.selectAll("#segment-" + curr.Name+'-'+curr.Level.replaceAll(' ','-')).attr("fill", function(p) {
239-
return d.target.textContent
243+
var color = d3.scaleLinear<string,string>().domain([0,1]).range(["white", "green"]);
244+
// how to access a function within reusable charts
245+
//console.log(color(d.Done));
246+
return color(curr["Done%"]);
240247
});
241248
})
242-
.append("desc") //append the current color as a desc element
243-
.text(function(d:any) {
244-
var color = d3.scaleLinear<string,string>().domain([0,1]).range(["white", "green"]);
245-
// how to access a function within reusable charts
246-
console.log(color(d.Done));
247-
return color(d["Done%"]);
248-
});
249249
}
250250

251251
circularHeatChart(num_of_segments:number) {

0 commit comments

Comments
 (0)