11import { Component , OnInit } from '@angular/core' ;
22import { ymlService } from '../../service/yaml-parser/yaml-parser.service' ;
33import * as d3 from 'd3' ;
4+ import * as yaml from "js-yaml"
45
56export interface taskSchema {
6- name :string
7- done :boolean
7+ taskName :string
8+ ifTaskDone :boolean
89}
910
1011export interface cardSchema {
@@ -20,12 +21,12 @@ export interface cardSchema{
2021 styleUrls : [ './circular-heatmap.component.css' ]
2122} )
2223export class CircularHeatmapComponent implements OnInit {
23- maxLevel :number = - 1
24- show :boolean = false
25- header :string = ''
26- subheader :string = ''
27- tasks :any [ ] = [ ]
28- data :cardSchema [ ] = [ ] ;
24+ maxLevelOfTasks :number = - 1
25+ showTaskCard :boolean = false
26+ taskHeader :string = ''
27+ taskSubheader :string = ''
28+ tasksData :any [ ] = [ ]
29+ ALL_CARD_DATA :cardSchema [ ] = [ ] ;
2930 radial_labels :string [ ] = [ ] ;
3031 YamlObject :any ;
3132 segment_labels :string [ ] = [ ] ;
@@ -41,7 +42,7 @@ export class CircularHeatmapComponent implements OnInit {
4142 for ( let x in this . YamlObject [ 'strings' ] [ 'en' ] [ 'maturity_levels' ] ) {
4243 var y = parseInt ( x ) + 1
4344 this . radial_labels . push ( 'Level ' + y )
44- this . maxLevel = y
45+ this . maxLevelOfTasks = y
4546 }
4647
4748 } ) ;
@@ -55,7 +56,7 @@ export class CircularHeatmapComponent implements OnInit {
5556 for ( var x in this . YamlObject [ 'dimension' ] ) {
5657 this . segment_labels . push ( this . YamlObject [ 'dimension' ] [ x ] [ 'subdimension' ] [ 'name' ] )
5758 }
58- for ( var l = 0 ; l < this . maxLevel ; l ++ ) {
59+ for ( var l = 0 ; l < this . maxLevelOfTasks ; l ++ ) {
5960 for ( var x in this . YamlObject [ 'dimension' ] ) {
6061 var tempdata :cardSchema = {
6162 "Name" : "" ,
@@ -73,57 +74,67 @@ export class CircularHeatmapComponent implements OnInit {
7374 if ( Status ) {
7475 totalImplemented += 1
7576 }
76- tempdata [ "Task" ] . push ( { "name " :nameOfTask , "done " :Status } )
77+ tempdata [ "Task" ] . push ( { "taskName " :nameOfTask , "ifTaskDone " :Status } )
7778 }
7879 tempdata [ "Done%" ] = totalImplemented / this . YamlObject [ 'dimension' ] [ x ] [ 'subdimension' ] [ 'level-' + ( l + 1 ) ] . length
7980 }
8081 catch {
8182 tempdata [ "Done%" ] = - 1
8283 }
83- this . data . push ( tempdata )
84+ this . ALL_CARD_DATA . push ( tempdata )
8485 }
8586 }
86- console . log ( this . data )
87- this . loadCircularHeatMap ( this . data , "#chart" , this . radial_labels , this . segment_labels ) ;
87+ console . log ( this . ALL_CARD_DATA )
88+ this . loadCircularHeatMap ( this . ALL_CARD_DATA , "#chart" , this . radial_labels , this . segment_labels ) ;
8889 this . noTasktoGrey ( )
8990 } )
9091 }
9192
92- checkboxToggle ( taskIndex :number ) {
93+ toggleCheckbox ( taskIndex :number ) {
9394 //console.log('fo')
9495 let _self = this
9596 var index = 0 ;
9697 var cnt = 0 ;
97- for ( var i = 0 ; i < this . data . length ; i ++ ) {
98- if ( this . data [ i ] [ "Name" ] === this . header && this . data [ i ] [ "Level" ] === this . subheader ) {
98+ for ( var i = 0 ; i < this . ALL_CARD_DATA . length ; i ++ ) {
99+ if ( this . ALL_CARD_DATA [ i ] [ "Name" ] === this . taskHeader && this . ALL_CARD_DATA [ i ] [ "Level" ] === this . taskSubheader ) {
99100 index = i
100101 break ;
101102 }
102103 }
103- if ( this . data [ index ] [ "Task" ] [ taskIndex ] [ "done " ] ) {
104- this . data [ index ] [ "Task" ] [ taskIndex ] [ "done " ] = false
104+ if ( this . ALL_CARD_DATA [ index ] [ "Task" ] [ taskIndex ] [ "ifTaskDone " ] ) {
105+ this . ALL_CARD_DATA [ index ] [ "Task" ] [ taskIndex ] [ "ifTaskDone " ] = false
105106 }
106107 else {
107- this . data [ index ] [ "Task" ] [ taskIndex ] [ "done " ] = true
108+ this . ALL_CARD_DATA [ index ] [ "Task" ] [ taskIndex ] [ "ifTaskDone " ] = true
108109 }
109110 //console.log(this.data[i]["Task"][taskIndex]["done"])
110- for ( var i = 0 ; i < this . data [ index ] [ "Task" ] . length ; i ++ ) {
111- console . log ( this . data [ index ] [ "Task" ] [ i ] [ "done " ] )
112- if ( this . data [ index ] [ "Task" ] [ i ] [ "done " ] ) {
111+ for ( var i = 0 ; i < this . ALL_CARD_DATA [ index ] [ "Task" ] . length ; i ++ ) {
112+ console . log ( this . ALL_CARD_DATA [ index ] [ "Task" ] [ i ] [ "ifTaskDone " ] )
113+ if ( this . ALL_CARD_DATA [ index ] [ "Task" ] [ i ] [ "ifTaskDone " ] ) {
113114 cnt += 1
114115 }
115116 }
116- this . data [ index ] [ 'Done%' ] = cnt / this . data [ index ] [ "Task" ] . length
117+ this . ALL_CARD_DATA [ index ] [ 'Done%' ] = cnt / this . ALL_CARD_DATA [ index ] [ "Task" ] . length
117118 //console.log(this.data[index]['Done%'],cnt)
118119 var color = d3 . scaleLinear < string , string > ( ) . domain ( [ 0 , 1 ] ) . range ( [ "white" , "green" ] ) ;
119120
120- this . loadCircularHeatMap ( this . data , "#chart" , this . radial_labels , this . segment_labels ) ;
121- d3 . selectAll ( "#segment-" + this . data [ index ] [ "Name" ] + '-' + this . data [ index ] [ "Level" ] . replace ( ' ' , '-' ) ) . attr ( "fill" , function ( p ) {
122- return color ( _self . data [ index ] [ "Done%" ] )
121+ this . loadCircularHeatMap ( this . ALL_CARD_DATA , "#chart" , this . radial_labels , this . segment_labels ) ;
122+ d3 . selectAll ( "#segment-" + this . ALL_CARD_DATA [ index ] [ "Name" ] + '-' + this . ALL_CARD_DATA [ index ] [ "Level" ] . replace ( ' ' , '-' ) ) . attr ( "fill" , function ( p ) {
123+ return color ( _self . ALL_CARD_DATA [ index ] [ "Done%" ] )
123124 } ) ;
124125
125126 }
126127
128+ SaveDemo ( ) {
129+ let yamlStr = yaml . dump ( this . YamlObject ) ;
130+ let file = new Blob ( [ yamlStr ] , { type : 'text/csv;charset=utf-8' } ) ;
131+ var link = document . createElement ( 'a' ) ;
132+ link . href = window . URL . createObjectURL ( file ) ;
133+ link . download = './hlll.txt'
134+ link . click ( ) ;
135+ link . remove ( ) ;
136+ }
137+
127138 loadCircularHeatMap ( dataset :any , dom_element_to_append_to :string , radial_labels :string [ ] , segment_labels :string [ ] ) {
128139 //d3.select(dom_element_to_append_to).selectAll('svg').exit()
129140 //console.log(dataset)
@@ -177,11 +188,11 @@ export class CircularHeatmapComponent implements OnInit {
177188
178189 svg . selectAll ( "path" )
179190 . on ( 'click' , function ( d ) {
180- _self . subheader = d . explicitOriginalTarget . __data__ . Level
181- _self . tasks = d . explicitOriginalTarget . __data__ . Task ;
182- _self . header = d . explicitOriginalTarget . __data__ . Name
183- _self . show = true
184- console . log ( _self . tasks )
191+ _self . taskSubheader = d . explicitOriginalTarget . __data__ . Level
192+ _self . tasksData = d . explicitOriginalTarget . __data__ . Task ;
193+ _self . taskHeader = d . explicitOriginalTarget . __data__ . Name
194+ _self . showTaskCard = true
195+ console . log ( _self . tasksData )
185196 } )
186197 . on ( 'mouseover' , function ( d ) {
187198
@@ -384,9 +395,9 @@ export class CircularHeatmapComponent implements OnInit {
384395 }
385396
386397 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" ) ;
398+ for ( var x in this . ALL_CARD_DATA ) {
399+ if ( this . ALL_CARD_DATA [ x ] [ "Done%" ] == - 1 ) {
400+ d3 . selectAll ( "#segment-" + this . ALL_CARD_DATA [ x ] [ "Name" ] + '-' + this . ALL_CARD_DATA [ x ] [ "Level" ] . replace ( ' ' , '-' ) ) . attr ( "fill" , "#DCDCDC" ) ;
390401 }
391402 }
392403 }
0 commit comments