@@ -12,7 +12,7 @@ function renderAll() {
12
12
d3 . select ( "#active" ) . text ( formatNumber ( gr_all . value ( ) ) ) ;
13
13
numWins = _ . find ( winGrp . all ( ) , function ( grp ) { return grp . key } ) . value
14
14
pctWins = Math . round ( 1000.0 * numWins / gr_all . value ( ) ) / 10.0 ;
15
- console . log ( "wins:" , numWins , pctWins ) ;
15
+ // console.log("wins:", numWins, pctWins);
16
16
d3 . select ( "#winrate" ) . text ( pctWins ) ;
17
17
}
18
18
@@ -220,24 +220,37 @@ function barChart() {
220
220
} ;
221
221
222
222
function scout_init ( ) {
223
+ var start = Date . now ( ) ;
224
+
223
225
matches = { } ;
224
226
entities = [ ] ;
225
227
match_winner = { } ;
226
228
match_loser = { } ;
227
229
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 ) {
230
235
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
231
239
matches [ match . id ] = match
232
240
} ) ;
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
+ }
235
248
entities . push ( entity ) ;
236
249
if ( entity . match_id in matches ) {
237
250
match = matches [ entity . match_id ] ;
238
- if ( entity . win == 1 ) {
251
+ if ( entity . win == "true" ) {
239
252
match_winner [ entity . match_id ] = entity ;
240
- } else if ( entity . win == 0 ) {
253
+ } else if ( entity . win == "false" ) {
241
254
match_loser [ entity . match_id ] = entity ;
242
255
}
243
256
if ( entity . match_id in match_winner && entity . match_id in match_loser ) {
@@ -251,6 +264,7 @@ function scout_init() {
251
264
252
265
}
253
266
} ) ;
267
+ var rec_built = Date . now ( ) ;
254
268
gr_cf = crossfilter ( gamerecords ) ;
255
269
gr_all = gr_cf . groupAll ( ) ;
256
270
@@ -280,20 +294,38 @@ function scout_init() {
280
294
281
295
owsDim = gr_cf . dimension ( function ( gr ) { return gr . opponent . w8 } ) ;
282
296
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 ( ) ;
283
308
284
309
charts = [
310
+ barChart ( )
311
+ . dimension ( lgDim )
312
+ . group ( lgGrp )
313
+ . x ( d3 . scale . linear ( )
314
+ . domain ( [ 0 , 6 ] )
315
+ . rangeRound ( [ 0 , 10 * 15 ] ) ) ,
316
+
285
317
barChart ( )
286
318
. dimension ( asDim )
287
319
. group ( asGrp )
288
320
. x ( d3 . scale . linear ( )
289
- . domain ( [ 0 , 1500 ] )
321
+ . domain ( [ 0 , 2000 ] )
290
322
. rangeRound ( [ 0 , 10 * 15 ] ) ) ,
291
323
292
324
barChart ( )
293
325
. dimension ( oasDim )
294
326
. group ( oasGrp )
295
327
. x ( d3 . scale . linear ( )
296
- . domain ( [ 0 , 1500 ] )
328
+ . domain ( [ 0 , 2000 ] )
297
329
. rangeRound ( [ 0 , 10 * 15 ] ) ) ,
298
330
299
331
barChart ( )
@@ -310,6 +342,20 @@ function scout_init() {
310
342
. domain ( [ 0 , 50 ] )
311
343
. rangeRound ( [ 0 , 10 * 20 ] ) ) ,
312
344
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
+
313
359
barChart ( )
314
360
. dimension ( durDim )
315
361
. group ( durGrp )
@@ -348,6 +394,14 @@ function scout_init() {
348
394
349
395
renderAll ( ) ;
350
396
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 ) ;
351
405
} ) ;
352
406
} ) ;
353
407
0 commit comments