@@ -6,7 +6,6 @@ export default Ember.View.extend({
6
6
7
7
elementId : 'mvc_tree' ,
8
8
9
-
10
9
templateName : 'svg' ,
11
10
12
11
attributeBindings : [ 'xmlns' ,
@@ -22,69 +21,8 @@ export default Ember.View.extend({
22
21
preserveAspectRatio : 'xMinYMin' ,
23
22
viewBox : null ,
24
23
25
- treeConfig : {
26
- showGrid : false ,
27
-
28
- paddingT : 6 ,
29
- paddingR : 6 ,
30
- paddingB : 12 ,
31
- paddingL : 6 ,
32
-
33
- colW : 170 + 12 ,
34
- rowH : 64 + 18 ,
35
-
36
- maxCols : 7 ,
37
- maxRows : 20 ,
38
-
39
- viewBoxW : null ,
40
- viewBoxH : null ,
41
-
42
- yearLineFontSize : 12 // see CSS rules .year_line_txt
43
- } ,
44
-
45
- calcViewBox : function ( ) {
46
- var tc = this . get ( 'treeConfig' ) ;
47
- tc . viewBoxW = tc . colW * tc . maxCols ;
48
- tc . viewBoxH = tc . rowH * tc . maxRows ;
49
- var viewBox = '0 0 ' + tc . viewBoxW + ' ' + tc . viewBoxH ;
50
-
51
- this . set ( 'treeConfig' , tc ) ;
52
- this . set ( 'viewBox' , viewBox ) ;
53
- } . observes ( 'treeConfig' ) . on ( 'init' ) ,
54
-
55
- gridLines : function ( ) {
56
- var tc = this . get ( 'treeConfig' ) ,
57
- w = tc . viewBoxW ,
58
- h = tc . viewBoxH ,
59
- gridLines = [ ] ;
60
-
61
- for ( var x = 0 ; x < w ; x += tc . colW ) {
62
- gridLines . push ( 'M' + x + ' 0 V' + h + ' Z' ) ;
63
- }
64
- for ( var y = 0 ; y < h ; y += tc . rowH ) {
65
- gridLines . push ( 'M0 ' + y + ' H' + w + ' Z' ) ;
66
- }
67
-
68
- return gridLines ;
69
- } . property ( 'treeConfig' ) ,
70
-
71
- yearLines : function ( ) {
72
- var tc = this . get ( 'treeConfig' ) ;
73
-
74
- return [
75
- this . _buildYearLine ( 1980 , 2 , tc ) ,
76
- this . _buildYearLine ( 1990 , 5 , tc ) ,
77
- this . _buildYearLine ( 2000 , 9 , tc ) ,
78
- this . _buildYearLine ( 2010 , 13 , tc )
79
- ] ;
80
- } . property ( 'treeConfig' ) ,
81
-
82
- _buildYearLine : function ( year , row , tc ) {
83
- var x = tc . yearLineFontSize * 2 ,
84
- y = row * tc . rowH ,
85
- xLine = tc . yearLineFontSize * 4 ;
24
+ _setViewBox : function ( ) {
25
+ this . set ( 'viewBox' , this . get ( 'controller.svgenv.viewBox' ) ) ;
26
+ } . on ( 'init' ) ,
86
27
87
- return { year : year , x : x , y : y ,
88
- path : 'M' + xLine + ' ' + y + ' H' + tc . viewBoxW } ;
89
- }
90
28
} ) ;
0 commit comments