1- burnify = ( function ( ) {
2- function productChart ( selector , project , width , height ) {
3- var dim = defineChartDimentions ( width , height ) ;
1+ /*
2+ * bunify Prototype
3+ */
4+ Burnify = function ( selector , project , width , height ) {
5+
6+ /*
7+ * Meta information for the rendering
8+ */
9+ this . burnifyProject = project ;
10+
11+ /*
12+ * Meta information for the chart
13+ */
14+ this . chartTargetSelector = selector ;
15+ this . chartMargins = { top : 40 , right : 30 , bottom : 20 , left : 30 }
16+ this . setDimensions ( width , height ) ;
17+
18+ // Chart rendering
19+ return this ;
20+
21+ } ;
22+
23+ /*
24+ * API methods
25+ */
26+ Burnify . prototype . getDimensions = function ( ) {
27+ return {
28+ width : this . chartMargins . width ,
29+ height : this . chartMargins . height ,
30+ margin : {
31+ top : this . chartMargins . top ,
32+ left : this . chartMargins . left ,
33+ right : this . chartMargins . right ,
34+ bottom : this . chartMargins . bottom
35+ }
36+ }
37+ }
38+
39+ Burnify . prototype . setDimensions = function ( width , height , margins ) {
40+ if ( margins ) {
41+ this . chartMarginss . top = margins . top || this . chartMarginss . top ;
42+ this . chartMarginss . left = margins . left || this . chartMarginss . left ;
43+ this . chartMarginss . right = margins . right || this . chartMarginss . right ;
44+ this . chartMarginss . bottom = margins . bottom || this . chartMarginss . bottom ;
45+ }
46+
47+ this . chartDimensions = {
48+ width : width - this . chartMargins . left - this . chartMargins . right ,
49+ height : height - this . chartMargins . top - this . chartMargins . bottom ,
50+ margin : this . chartMargins
51+ }
52+ }
53+
54+ Burnify . prototype . draw = function ( ) {
55+ this . burnify ( this ) ;
56+ }
57+
58+ Burnify . prototype . onSprintBarClick = function ( sprintNumber , sprint ) { }
59+ Burnify . prototype . onFullScopeAreaClick = function ( burnifyProject ) { console . log ( 'Full scope area clicked' ) ; console . log ( burnifyProject ) }
60+ Burnify . prototype . onDoneScopeAreaClick = function ( burnifyProject ) { console . log ( 'Done scope area clicked' ) ; }
61+ Burnify . prototype . onOutScopeAreaClick = function ( burnifyProject ) { console . log ( 'Out scope area clicked' ) ; }
62+
63+ /*
64+ * Functional structure
65+ */
66+ Burnify . prototype . burnify = function ( meta ) {
67+
68+ function productChart ( selector , project , dim ) {
469 var svg = createChartSVG ( selector , dim ) ;
570 renderChart ( dim , svg , project , prepareData ( project ) ) ;
671 }
@@ -197,6 +262,9 @@ burnify = (function () {
197262 . attr ( "width" , x . rangeBand ( ) )
198263 . attr ( "y" , dim . height )
199264 . attr ( "height" , 0 )
265+ . on ( "click" , function ( d ) {
266+ meta . onSprintBarClick ( d . index , d ) ;
267+ } )
200268 . transition ( )
201269 . ease ( "linear" )
202270 . delay ( function ( d , i ) {
@@ -271,8 +339,18 @@ burnify = (function () {
271339 . attr ( "class" , clazz )
272340 . attr ( "d" , function ( d ) {
273341 return area ( d . values ) ;
342+ } )
343+ . on ( "click" , function ( d ) {
344+ if ( clazz == "scopeDone" ) {
345+ meta . onDoneScopeAreaClick ( meta . burnifyProject ) ;
346+ } else if ( clazz == "scopeOut" ) {
347+ meta . onOutScopeAreaClick ( meta . burnifyProject ) ;
348+ } else {
349+ meta . onFullScopeAreaClick ( meta . burnifyProject ) ;
350+ }
274351 } ) ;
275352
353+
276354 svg . selectAll ( "." + clazz )
277355 . data ( stack )
278356 . transition ( )
@@ -486,8 +564,5 @@ burnify = (function () {
486564 }
487565
488566
489- return function ( selector , project , width , height ) {
490- productChart ( selector , project , width , height ) ;
491- } ;
492-
493- } ) ( ) ;
567+ productChart ( meta . chartTargetSelector , meta . burnifyProject , meta . chartDimensions ) ;
568+ }
0 commit comments