@@ -94,20 +94,34 @@ function showGraph(problems) {
9494 none : chalk . gray ( '⬚ ' )
9595 } ;
9696
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+
97109 var graph = [ ] ;
98110 _ . each ( problems , function ( problem ) {
99111 graph [ problem . id ] = icons [ problem . state ] || icons . none ;
100112 } ) ;
101113
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 ) ] ;
105115 for ( var i = 1 , n = graph . length ; i <= n ; ++ i ) {
116+ // padding before group
117+ if ( i % 10 === 1 ) line . push ( ' ' ) ;
118+
106119 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 ) {
109123 log . info ( line . join ( '' ) ) ;
110- line = [ sprintf ( ' %03d ' , i ) ] ;
124+ line = [ sprintf ( ' %03d' , i ) ] ;
111125 }
112126 }
113127
0 commit comments