@@ -94,20 +94,34 @@ function showGraph(problems) {
94
94
none : chalk . gray ( '⬚ ' )
95
95
} ;
96
96
97
+ // row header is 4 bytes
98
+ // each question takes 2 bytes
99
+ // each group has 10 questions, which takes (2*10=20) + 3 paddings
100
+ var groups = Math . floor ( ( h . width - 4 ) / ( 3 + 2 * 10 ) ) ;
101
+ if ( groups < 1 ) groups = 1 ;
102
+ if ( groups > 5 ) groups = 5 ;
103
+
104
+ var header = _ . range ( groups )
105
+ . map ( function ( x ) { return sprintf ( '%5d%18d' , x * 10 + 1 , x * 10 + 10 ) ; } )
106
+ . join ( '' ) ;
107
+ log . info ( ' ' + header ) ;
108
+
97
109
var graph = [ ] ;
98
110
_ . each ( problems , function ( problem ) {
99
111
graph [ problem . id ] = icons [ problem . state ] || icons . none ;
100
112
} ) ;
101
113
102
- log . printf ( '%8d%19d%5d%18d%5d%18d%5d%18d%5d%18d' , 1 , 10 , 11 , 20 , 21 , 30 , 31 , 40 , 41 , 50 ) ;
103
-
104
- var line = [ sprintf ( ' %03d ' , 0 ) ] ;
114
+ var line = [ sprintf ( ' %03d' , 0 ) ] ;
105
115
for ( var i = 1 , n = graph . length ; i <= n ; ++ i ) {
116
+ // padding before group
117
+ if ( i % 10 === 1 ) line . push ( ' ' ) ;
118
+
106
119
line . push ( graph [ i ] || ' ' ) ;
107
- if ( i % 10 === 0 ) line . push ( ' ' ) ;
108
- if ( i % 50 === 0 || i === n ) {
120
+
121
+ // time to start new row
122
+ if ( i % ( 10 * groups ) === 0 || i === n ) {
109
123
log . info ( line . join ( '' ) ) ;
110
- line = [ sprintf ( ' %03d ' , i ) ] ;
124
+ line = [ sprintf ( ' %03d' , i ) ] ;
111
125
}
112
126
}
113
127
0 commit comments