@@ -32,9 +32,7 @@ define(
32
32
* labelled 'ticks'. It requires 'start' and 'end' integer values to
33
33
* be specified as attributes.
34
34
*/
35
- function MCTConductorAxis ( conductorService , formatService ) {
36
- var conductor = conductorService . conductor ( ) ;
37
-
35
+ function MCTConductorAxis ( conductor , formatService ) {
38
36
function link ( scope , element , attrs , ngModelController ) {
39
37
var target = element [ 0 ] . firstChild ,
40
38
height = target . offsetHeight ,
@@ -45,25 +43,24 @@ define(
45
43
. attr ( 'width' , '100%' )
46
44
. attr ( 'height' , height ) ;
47
45
var xAxis = d3 . axisTop ( ) ;
46
+ var xScale = d3 . scaleUtc ( ) ;
47
+
48
48
// draw x axis with labels and move to the bottom of the chart area
49
49
var axisElement = vis . append ( "g" )
50
50
. attr ( "transform" , "translate(0," + ( height - padding ) + ")" ) ;
51
51
52
52
function setScale ( ) {
53
- var xScale = undefined ;
54
53
var width = target . offsetWidth ;
55
54
var timeSystem = conductor . timeSystem ( ) ;
56
55
var bounds = conductor . bounds ( ) ;
57
56
58
57
if ( timeSystem . isUTCBased ( ) ) {
59
- xScale = d3 . scaleUtc ( ) ;
60
58
xScale . domain ( [ new Date ( bounds . start ) , new Date ( bounds . end ) ] ) ;
61
59
} else {
62
- xScale = d3 . scaleLinear ( ) ;
63
60
xScale . domain ( [ bounds . start , bounds . end ] ) ;
64
61
}
62
+
65
63
xScale . range ( [ padding , width - padding * 2 ] ) ;
66
- xAxis . scale ( xScale ) ;
67
64
axisElement . call ( xAxis ) ;
68
65
}
69
66
@@ -73,6 +70,13 @@ define(
73
70
var format = formatService . getFormat ( key ) ;
74
71
var b = conductor . bounds ( ) ;
75
72
73
+ if ( timeSystem . isUTCBased ( ) ) {
74
+ xScale = d3 . scaleUtc ( ) ;
75
+ } else {
76
+ xScale = d3 . scaleLinear ( ) ;
77
+ }
78
+
79
+ xAxis . scale ( xScale ) ;
76
80
//Define a custom format function
77
81
xAxis . tickFormat ( function ( tickValue ) {
78
82
// Normalize date representations to numbers
@@ -97,23 +101,16 @@ define(
97
101
setScale ( ) ;
98
102
} ) ;
99
103
100
- setScale ( ) ;
101
-
102
104
if ( conductor . timeSystem ( ) !== undefined ) {
103
105
changeTimeSystem ( conductor . timeSystem ( ) ) ;
106
+ setScale ( ) ;
104
107
}
105
108
}
106
109
107
110
return {
108
- // Only show at the element level
109
111
restrict : "E" ,
110
-
111
112
template : "<div class=\"l-axis-holder\" mct-resize=\"resize()\"></div>" ,
112
-
113
- // ngOptions is terminal, so we need to be higher priority
114
113
priority : 1000 ,
115
-
116
- // Link function
117
114
link : link
118
115
} ;
119
116
}
0 commit comments