@@ -12,7 +12,7 @@ function renderAll() {
1212 d3 . select ( "#active" ) . text ( formatNumber ( gr_all . value ( ) ) ) ;
1313 numWins = _ . find ( winGrp . all ( ) , function ( grp ) { return grp . key } ) . value
1414 pctWins = Math . round ( 1000.0 * numWins / gr_all . value ( ) ) / 10.0 ;
15- console . log ( "wins:" , numWins , pctWins ) ;
15+ // console.log("wins:", numWins, pctWins);
1616 d3 . select ( "#winrate" ) . text ( pctWins ) ;
1717}
1818
@@ -220,24 +220,37 @@ function barChart() {
220220} ;
221221
222222function scout_init ( ) {
223+ var start = Date . now ( ) ;
224+
223225 matches = { } ;
224226 entities = [ ] ;
225227 match_winner = { } ;
226228 match_loser = { } ;
227229 gamerecords = [ ] ;
228- $ . getJSON ( "http://localhost:3000/matches.json" , function ( data ) {
229- $ . each ( data , function ( index , match ) {
230+
231+ entity_non_numerics = [ "race" , "chosen_race" , "win" ]
232+
233+ d3 . csv ( "http://localhost:3000/matches.csv" , function ( error , csv_matches ) {
234+ csv_matches . forEach ( function ( match , index ) {
230235 match . play_date = new Date ( match . play_date ) ;
236+ match . id = + match . id
237+ match . average_league = + match . average_league
238+ match . duration_minutes = + match . duration_minutes
231239 matches [ match . id ] = match
232240 } ) ;
233- $ . getJSON ( "http://localhost:3000/ents.json" , function ( data ) {
234- $ . each ( data , function ( index , entity ) {
241+ d3 . csv ( "http://localhost:3000/ents.csv" , function ( error , csv_ents ) {
242+ csv_ents . forEach ( function ( entity , index ) {
243+ for ( var key in entity ) {
244+ if ( ! ( _ . contains ( entity_non_numerics , key ) ) ) {
245+ entity [ key ] = + entity [ key ] ;
246+ }
247+ }
235248 entities . push ( entity ) ;
236249 if ( entity . match_id in matches ) {
237250 match = matches [ entity . match_id ] ;
238- if ( entity . win == 1 ) {
251+ if ( entity . win == "true" ) {
239252 match_winner [ entity . match_id ] = entity ;
240- } else if ( entity . win == 0 ) {
253+ } else if ( entity . win == "false" ) {
241254 match_loser [ entity . match_id ] = entity ;
242255 }
243256 if ( entity . match_id in match_winner && entity . match_id in match_loser ) {
@@ -251,6 +264,7 @@ function scout_init() {
251264
252265 }
253266 } ) ;
267+ var rec_built = Date . now ( ) ;
254268 gr_cf = crossfilter ( gamerecords ) ;
255269 gr_all = gr_cf . groupAll ( ) ;
256270
@@ -280,20 +294,38 @@ function scout_init() {
280294
281295 owsDim = gr_cf . dimension ( function ( gr ) { return gr . opponent . w8 } ) ;
282296 owsGrp = owsDim . group ( function ( d ) { return Math . floor ( d / 5 ) * 5 } ) ;
297+
298+ mb2Dim = gr_cf . dimension ( function ( gr ) { return Math . floor ( gr . player . miningbase_2 / 60 ) } ) ;
299+ mb2Grp = mb2Dim . group ( function ( d ) { return d ; } )
300+
301+ omb2Dim = gr_cf . dimension ( function ( gr ) { return Math . floor ( gr . opponent . miningbase_2 / 60 ) } ) ;
302+ omb2Grp = omb2Dim . group ( function ( d ) { return d ; } )
303+
304+ lgDim = gr_cf . dimension ( function ( gr ) { return gr . match . average_league } ) ;
305+ lgGrp = lgDim . group ( function ( d ) { return d ; } ) ;
306+
307+ var dims_built = Date . now ( ) ;
283308
284309 charts = [
310+ barChart ( )
311+ . dimension ( lgDim )
312+ . group ( lgGrp )
313+ . x ( d3 . scale . linear ( )
314+ . domain ( [ 0 , 6 ] )
315+ . rangeRound ( [ 0 , 10 * 15 ] ) ) ,
316+
285317 barChart ( )
286318 . dimension ( asDim )
287319 . group ( asGrp )
288320 . x ( d3 . scale . linear ( )
289- . domain ( [ 0 , 1500 ] )
321+ . domain ( [ 0 , 2000 ] )
290322 . rangeRound ( [ 0 , 10 * 15 ] ) ) ,
291323
292324 barChart ( )
293325 . dimension ( oasDim )
294326 . group ( oasGrp )
295327 . x ( d3 . scale . linear ( )
296- . domain ( [ 0 , 1500 ] )
328+ . domain ( [ 0 , 2000 ] )
297329 . rangeRound ( [ 0 , 10 * 15 ] ) ) ,
298330
299331 barChart ( )
@@ -310,6 +342,20 @@ function scout_init() {
310342 . domain ( [ 0 , 50 ] )
311343 . rangeRound ( [ 0 , 10 * 20 ] ) ) ,
312344
345+ barChart ( )
346+ . dimension ( mb2Dim )
347+ . group ( mb2Grp )
348+ . x ( d3 . scale . linear ( )
349+ . domain ( [ 0 , 15 ] )
350+ . rangeRound ( [ 0 , 10 * 20 ] ) ) ,
351+
352+ barChart ( )
353+ . dimension ( omb2Dim )
354+ . group ( omb2Grp )
355+ . x ( d3 . scale . linear ( )
356+ . domain ( [ 0 , 15 ] )
357+ . rangeRound ( [ 0 , 10 * 20 ] ) ) ,
358+
313359 barChart ( )
314360 . dimension ( durDim )
315361 . group ( durGrp )
@@ -348,6 +394,14 @@ function scout_init() {
348394
349395 renderAll ( ) ;
350396
397+ var end = Date . now ( ) ;
398+ var total_time = end - start ;
399+ console . log ( "init took " + ( total_time / 1000 ) + " seconds" ) ;
400+
401+ var build_rec = ( rec_built - start ) / 1000 ;
402+ var build_dims = ( dims_built - rec_built ) / 1000 ;
403+ var build_chart = ( end - dims_built ) / 1000 ;
404+ console . log ( build_rec , build_dims , build_chart ) ;
351405 } ) ;
352406 } ) ;
353407
0 commit comments