@@ -36,9 +36,15 @@ function bar_width(d, i) {
3636 if ( data [ i ] . name === d . name || data [ i ] . name . match ( / ^ r f c / ) ) { break ; }
3737 }
3838
39- var w = i === data . length ? expiration_date ( d ) : data [ i ] . published ;
40- // don't extend the bar past the expiration date of the document
41- w = w > expiration_date ( d ) ? expiration_date ( d ) : w ;
39+ var w ;
40+ if ( d . name . match ( / ^ d r a f t - / ) ) {
41+ // don't extend the bar past the expiration date of the document
42+ w = i === data . length ? expiration_date ( d ) : data [ i ] . published ;
43+ w = w > expiration_date ( d ) ? expiration_date ( d ) : w ;
44+ } else {
45+ // documents other than drafts don't expire after 185 days
46+ w = i === data . length ? new Date ( ) : data [ i ] . published ;
47+ }
4248 return x_scale ( w ) - x_scale ( d . published ) ;
4349}
4450
@@ -58,12 +64,17 @@ function scale_x() {
5864 now = Date . now ( ) ;
5965 if ( tv [ tv . length - 1 ] . published > now ) { tv . push ( new Date ( now ) ) ; }
6066
67+ // x label format
68+ var format = d3 . time . format ( "%b %Y" ) ;
69+
6170 // resort data by publication time to suppress some ticks if they are closer
62- // than 12px, and don't add a tick for the final pseudo entry
71+ // than 12px and have a different label from the one before; and don't add a
72+ // tick for the final pseudo entry
6373 tv = tv . sort ( function ( a , b ) { return a . published - b . published ; } )
6474 . map ( function ( d , i , arr ) {
6575 if ( i === 0 ||
66- x_scale ( d . published ) > x_scale ( arr [ i - 1 ] . published ) + 12 ) {
76+ x_scale ( d . published ) > x_scale ( arr [ i - 1 ] . published ) + 12 &&
77+ format ( d . published ) !== format ( arr [ i - 1 ] . published ) ) {
6778 return d . published ;
6879 }
6980 } ) . filter ( function ( d ) { return d !== undefined ; } ) ;
@@ -72,7 +83,7 @@ function scale_x() {
7283 . scale ( x_scale )
7384 . tickValues ( tv )
7485 . tickFormat ( function ( d ) {
75- if ( d . getTime ( ) < now ) { return d3 . time . format ( "%b %Y" ) ( d ) ; }
86+ if ( d . getTime ( ) < now ) { return format ( d ) ; }
7687 return "Now" ;
7788 } )
7889 . orient ( "bottom" ) ;
@@ -181,8 +192,9 @@ function draw_timeline() {
181192 height : bar_height ,
182193 width : bar_width ,
183194 mask : function ( d , i ) {
184- // apply gradient it the document expired
185- if ( bar_width ( d , i ) >= x_scale ( expiration_date ( d ) ) -
195+ // apply gradient if the document is a draft and expired
196+ if ( d . name . match ( / ^ d r a f t - / ) &&
197+ bar_width ( d , i ) >= x_scale ( expiration_date ( d ) ) -
186198 x_scale ( d . published ) ) {
187199 return "url(#fade)" ;
188200 }
0 commit comments