-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewer.js
1281 lines (1207 loc) · 34 KB
/
viewer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// TODO
// * data series
// * we should be rendering _n_ series of data
// * you should be able to style each series as you wish
// * but they all should be shown on the same axes
// * organize all the inputs
// * sections?
// * ability to open and close sections?
// * what's a comparable UI?
// * sorting, autocomplete? glossary?
// * I tried autocomplete and it wasn't a great experience at first blush
// * show UI indication of legal filters
// * permalinks to a graph with a given filter/year/resolution/etc
// * select multiple years
// * view a set of players through years
// * nice transitions between years
// * transitions on graph size change? probs overkill
// * highlight a player or particular set of players
// * something like, one dot stays lit and the others go grey
// * small multiples by team?
// * teams instead of players
// * labels sometimes overlap each other, or dots
// * collision detect after labelling?
// * ability to customize x and y domains
// * handle players that are coincident better
// * right now we just have to ensure we ignore null cells anywhere they're used
// * what even is the right thing to do? I dunno
// * the tooltip sometimes goes off the bottom, it should appear above the dot
// when it's low
// * convert it to an HTML absolutely positioned tooltip?
// * I know I have that in one of my other projects
// * would be cool to be able to set a linear or log scale
// * right now we just choose linear by default but for example, if you
// choose FT% as the circle size, you see that Andre Drummond looks tiny and
// everybody else looks huge.
// * if it were a log scale, the good shooters would jump out at you
// * should I thread a single transition object through all the transitions?
// * checkbox to show all labels no matter what
// * the labels aren't quite where they should be
// * playoffs vs regular season
// * show loading spinner
// * add option to remove traded player stats maybe?
// * fix transferred player bug: select "raptor defensive rating" as y axis and
// you get a bunch of undefined coordinates and players at (0,0)
const $ = (s) => document.querySelector(s);
const settings = {
padding: { left: 60, top: 60, right: 40, bottom: 40 },
width: 800,
height: 800,
dotRadius: 6,
maxRadius: 16,
minRadius: 4,
duration: 750,
domainPadding: 0.05,
};
window.DATA_URL = 'https://cdn.billmill.org/nbastats';
// window.DATA_URL = './data';
function hover(event, tooltip, stats, scales, fields, delaunay, cells) {
const [mx, my] = d3.pointer(event, this);
const nearest = delaunay.find(mx, my);
const closestPlayer = cells[nearest][0];
var rtext = '';
if (statMeta[fields.r]) {
rtext = '\n' + statMeta[fields.r].name + ': ' + closestPlayer[fields.r];
}
tooltip
.attr(
'transform',
`translate(${scales.x(closestPlayer[fields.x])},${scales.y(
closestPlayer[fields.y]
)})`
)
.call(
callout,
`${closestPlayer.name}
${closestPlayer.team}
${statMeta[fields.x].name}: ${closestPlayer[fields.x]}
${statMeta[fields.y].name}: ${closestPlayer[fields.y]}${rtext}`
);
}
function orient(pos, r) {
// TODO: I added a transition to these, which worked for points that were
// already present but failed for entering points. Figure out why so I can
// have nice label transitions everywhere
if (pos == 'top') {
return (text) => text.attr('text-anchor', 'middle').attr('y', -r);
} else if (pos == 'right') {
return (text) =>
text.attr('text-anchor', 'start').attr('dy', '0.35em').attr('x', r);
} else if (pos == 'bottom') {
return (text) =>
text.attr('text-anchor', 'middle').attr('dy', '0.71em').attr('y', r);
} else if (pos == 'left') {
return (text) =>
text.attr('text-anchor', 'end').attr('dy', '0.35em').attr('x', -r);
}
}
function orientText(scales, fields) {
return function([player, cell]) {
// if two players have the same stats on the selected dimension, the
// voronoi cell will be null. Skip this player for now - do something more
// intelligent with coincident players later
if (!cell) {
return;
}
const [cx, cy] = d3.polygonCentroid(cell);
const angle =
(Math.round(
(Math.atan2(
cy - scales.y(player[fields.y]),
cx - scales.x(player[fields.x])
) /
Math.PI) *
2
) +
4) %
4;
const r = scales.r(player[fields.r]) * 1.1;
d3.select(this).call(
angle === 0
? orient('right', r)
: angle === 3
? orient('top', r)
: angle === 1
? orient('bottom', r)
: orient('left', r)
);
};
}
function calcVoronoi(stats, scales, fields) {
const delaunay = d3.Delaunay.from(
stats,
(p) => scales.x(p[fields.x]),
(p) => scales.y(p[fields.y])
);
const voronoi = delaunay.voronoi([
-1,
-1,
settings.width + 1,
settings.height + 1,
]);
var cells = stats.map((d, i) => [d, voronoi.cellPolygon(i)]);
return [delaunay, cells];
}
function pointLabels(svg, stats, scales, fields, cells) {
var orienter = orientText(scales, fields);
const container = svg
.append('g')
.attr('class', 'labels')
.style('font', '10px sans-serif');
container
.selectAll('text')
.data(cells, ([p, _]) => p.name + p.team)
.join('text')
.attr('class', 'pointLabel')
.each(orienter)
.attr(
'transform',
([p, _]) => `translate(${scales.x(p[fields.x])},${scales.y(p[fields.y])})`
)
.attr('display', ([, cell]) =>
!cell || -d3.polygonArea(cell) > 3000 ? null : 'none'
)
.text(([p, _]) => p.name);
return function(stats, scales, fields, cells) {
var orienter = orientText(scales, fields);
// TODO the label immediately changes orientation instead of
// transitioning nicely, though it does move with the point
container
.selectAll('text')
.data(cells, ([p, _]) => p.name + p.team)
.join('text')
.transition()
.duration(settings.duration)
.each(orienter)
.attr(
'transform',
([p, _]) =>
`translate(${scales.x(p[fields.x])},${scales.y(p[fields.y])})`
)
.attr('display', ([, cell]) =>
!cell || -d3.polygonArea(cell) > 3000 ? null : 'none'
)
.text(([p, _]) => p.name);
};
}
function paddedExtent(lst, fn, reversed) {
var [min, max] = d3.extent(lst, fn);
if (reversed === undefined || !reversed) {
return [
min * (1 - settings.domainPadding),
max * (1 + settings.domainPadding),
];
} else {
return [
max * (1 + settings.domainPadding),
min * (1 - settings.domainPadding),
];
}
}
function makeScales(stats, fields) {
const xAxType = statMeta[fields.x].type;
const xreversed = statMeta[fields.x].reversed;
var x;
if (xAxType == 'categorical') {
const domain = new Set(stats.map((p) => p[fields.x]));
x = d3.scaleBand(domain, [
settings.padding.left,
settings.width - settings.padding.right,
]);
} else {
x = d3
.scaleLinear()
.domain(paddedExtent(stats, (s) => s[fields.x], xreversed))
.range([settings.padding.left, settings.width - settings.padding.right]);
}
const yAxType = statMeta[fields.y].type;
const yreversed = statMeta[fields.y].reversed;
var y;
if (yAxType == 'categorical') {
const domain = new Set(stats.map((p) => p[fields.y]));
y = d3.scaleBand(domain, [
settings.padding.top,
settings.height - settings.padding.bottom,
]);
} else {
y = d3
.scaleLinear()
.domain(d3.reverse(paddedExtent(stats, (s) => s[fields.y], yreversed)))
.range([settings.padding.top, settings.height - settings.padding.bottom]);
}
var r;
if (!isNaN(fields.r)) {
// if radius is a number, the scale is just a constant
r = (_) => parseFloat(fields.r);
} else {
r = d3
.scaleLinear()
.domain(d3.extent(stats, (s) => s[fields.r]))
.range([settings.minRadius, settings.maxRadius]);
}
return { x: x, y: y, r: r };
}
// https://observablehq.com/@d3/styled-axes
function axes(svg, stats, scales) {
var xaxis = d3
.axisTop(scales.x)
.tickSize(settings.height - settings.padding.top)
.tickFormat(d3.format('.2r'));
const xaxisg = svg
.append('g')
.attr('transform', `translate(0, ${settings.height - 20})`)
.attr('class', 'xaxis')
.call(xaxis)
.call((g) => g.select('.domain').remove())
.call((g) => g.selectAll('.tick line').attr('stroke-opacity', 0.1))
.call((g) => g.selectAll('.tick text').attr('y', 0).attr('dx', -15));
const yaxis = d3
.axisRight(scales.y)
.tickSize(settings.width - settings.padding.right)
.tickFormat(d3.format('.2r'));
const yaxisg = svg
.append('g')
.attr('transform', `translate(20, 0)`)
.attr('class', 'yaxis')
.call(yaxis)
.call((g) => g.select('.domain').remove())
.call((g) => g.selectAll('.tick line').attr('stroke-opacity', 0.1))
.call((g) => g.selectAll('.tick text').attr('dy', -4).attr('x', 4));
// return an update function
return function(stats, scales, fields) {
const xAxType = statMeta[fields.x].type;
if (xAxType == 'categorical') {
xaxis.scale(scales.x).tickFormat((p) => p);
} else {
xaxis.scale(scales.x).tickFormat(d3.format('.2r'));
}
const yAxType = statMeta[fields.y].type;
if (yAxType == 'categorical') {
yaxis.scale(scales.y).tickFormat((p) => p);
} else {
yaxis.scale(scales.y).tickFormat(d3.format('.2r'));
}
xaxisg
.transition()
.duration(settings.duration)
.call(xaxis)
.on('start', function() {
xaxisg.select('.domain').remove(); // https://stackoverflow.com/a/50254240/42559
})
.call((g) => g.select('.domain').remove())
.call((g) => g.selectAll('.tick line').attr('stroke-opacity', 0.1))
// this looks better with dx set to 15, but then is wong for categorical
// variables; TODO: update this value when categoricals are selected and
// remove it when unselected
.call((g) => g.selectAll('.tick text').attr('y', 0).attr('dx', -15));
yaxisg
.transition()
.duration(settings.duration)
.call(yaxis)
.on(
'start',
() => yaxisg.select('.domain').remove() // https://stackoverflow.com/a/50254240/42559
)
.call((g) => g.select('.domain').remove())
.call((g) => g.selectAll('.tick line').attr('stroke-opacity', 0.1))
// this line causes many <<Error: <text> attribute dy: Expected length,
// "NaN".>> for unknown reasons, but oddly it seems to work fine
.call((g) => g.selectAll('.tick text').attr('x', 4).attr('dy', -4));
};
}
function points(svg, stats, scales, fields) {
var useTeamColors = $('#teamcolors').checked;
const container = svg.append('g').attr('class', 'points');
// points
// https://observablehq.com/@d3/scatterplot-tour
const points = container
.selectAll('g')
.data(stats, (d) => d.name + d.team)
.join('g')
.attr('data-player-name', (d) => d.name)
.attr(
'transform',
(d) => `translate(${scales.x(d[fields.x])},${scales.y(d[fields.y])})`
);
if (useTeamColors) {
points
.append('circle')
.attr('class', 'outer')
.attr('fill', (d) => teams[d.team].colors[0])
.attr('r', (d) => scales.r(d[fields.r]));
points
.append('circle')
.attr('class', 'inner')
.attr('fill', (d) => teams[d.team].colors[1])
.attr('r', (d) => scales.r(d[fields.r]) / 2);
} else {
points
.append('circle')
.attr('class', 'outer')
.attr('fill', '#1f77b4')
.attr('r', (d) => scales.r(d[fields.r]));
}
return function(stats, scales, fields) {
useTeamColors = $('#teamcolors').checked;
d3.selectAll('.player_label').remove();
// TODO: does this handle entries and exits?
container
.selectAll('g')
.data(stats, (d) => d.name + d.team)
.join(
(enter) => {
var g = enter.append('g');
if (useTeamColors) {
g.append('circle')
.attr('class', 'outer')
.attr('fill', (d) => teams[d.team].colors[0])
.attr('r', (d) => scales.r(d[fields.r]));
g.append('circle')
.attr('class', 'inner')
.attr('fill', (d) => teams[d.team].colors[1])
.attr('r', (d) => scales.r(d[fields.r]) / 2);
} else {
g.append('circle')
.attr('class', 'outer')
.attr('fill', '#1f77b4')
.attr('r', (d) => scales.r(d[fields.r]));
}
g.call((enter) => {
enter
.transition()
.duration(settings.duration)
.attr(
'transform',
(d) =>
`translate(${scales.x(d[fields.x])},${scales.y(d[fields.y])})`
);
});
return g;
},
(update) =>
// XXX: the problem here is that we need to update the radius of the
// two circles inside the g, and I don't really know how to do that. I
// think it's important that the sizes transition nicely instead of
// jump to smaller?
update.call((update) =>
update
.each((p, i, ns) => {
d3.select(ns[i])
.select('circle.outer')
.transition()
.duration(settings.duration)
.attr('r', (d) => scales.r(d[fields.r]));
d3.select(ns[i])
.select('circle.inner')
.transition()
.duration(settings.duration)
.attr('r', (d) => scales.r(d[fields.r]) / 2);
})
.transition()
.attr(
'transform',
(d) =>
`translate(${scales.x(d[fields.x])},${scales.y(d[fields.y])})`
)
.duration(settings.duration)
),
(exit) => exit.remove()
);
};
}
function axisLabels(svg, fields) {
// axis labels
//
// I like the axis labels on health & wealth:
// https://observablehq.com/@mbostock/the-wealth-health-of-nations
const xlabel = svg
.append('text')
.attr('class', 'x label')
.attr('text-anchor', 'end')
.attr('x', settings.width - 20)
.attr('y', settings.height - 5)
.text('→' + statMeta[fields.x].name);
const ylabel = svg
.append('text')
.attr('class', 'y label')
.attr('text-anchor', 'left')
.attr('x', 15)
.attr('y', 40)
.text('↑' + statMeta[fields.y].name);
const rlabel = svg
.append('text')
.attr('class', 'r label')
.attr('text-anchor', 'left')
.attr('x', 10)
.attr('y', 20)
.style('display', 'none');
if (isNaN(fields.r)) {
rlabel.text('⬤ ' + statMeta[fields.r].name).style('display', undefined);
} else {
rlabel.style('display', 'none');
}
return function(fields) {
xlabel.text('→' + statMeta[fields.x].name);
ylabel.text('↑ ' + statMeta[fields.y].name);
// don't add a radius label if the value is constant
if (isNaN(fields.r)) {
rlabel.text('⬤ ' + statMeta[fields.r].name).style('display', undefined);
} else {
rlabel.style('display', 'none');
}
};
}
// stats should be a list of player objects
function graph(stats, fields) {
const svg = d3.select('#canvas');
var scales = makeScales(stats, fields);
var [delaunay, voronoiCells] = calcVoronoi(stats, scales, fields);
const updateAxes = axes(svg, stats, scales);
const updateAxisLabels = axisLabels(svg, fields);
const updatePoints = points(svg, stats, scales, fields);
const updateLabels = pointLabels(svg, stats, scales, fields, voronoiCells);
// https://observablehq.com/@d3/line-chart-with-tooltip
var tooltip = svg.append('g').attr('class', 'tooltip');
svg.on('touchmove mousemove', (evt) =>
hover(evt, tooltip, stats, scales, fields, delaunay, voronoiCells)
);
svg.on('touchend mouseleave', () => tooltip.call(callout, null));
// https://observablehq.com/@d3/dot-plot
return Object.assign(svg.node(), {
update(stats, fields) {
scales.y.domain(
d3.reverse(
paddedExtent(stats, (s) => s[fields.y], statMeta[fields.y].reversed)
)
);
scales.x.domain(
paddedExtent(stats, (s) => s[fields.x], statMeta[fields.x].reversed)
);
scales = makeScales(stats, fields);
[delaunay, voronoiCells] = calcVoronoi(stats, scales, fields);
updateAxes(stats, scales, fields);
updateAxisLabels(fields);
updatePoints(stats, scales, fields);
updateLabels(stats, scales, fields, voronoiCells);
// If an event listener was previously registered for the same typename
// on a selected element, the old listener is removed before the new
// listener is added.
// https://github.com/d3/d3-selection/blob/v2.0.0/README.md#selection_on
svg.on('touchmove mousemove', (evt) => {
return hover(
evt,
tooltip,
stats,
scales,
fields,
delaunay,
voronoiCells
);
});
// remove the tooltip and redraw it; otherwise it won't properly appear
// above everything else. SVG has no z-order; last drawn thing wins
tooltip.remove();
tooltip = svg.append('g').attr('class', 'tooltip');
},
});
}
// https://observablehq.com/@d3/line-chart-with-tooltip
function callout(g, value) {
if (!value) return g.style('display', 'none');
g.style('display', null)
.style('pointer-events', 'none')
.style('font', '10px sans-serif');
const path = g
.selectAll('path')
.data([null])
.join('path')
.attr('fill', 'white')
.attr('stroke', 'black');
const text = g
.selectAll('text')
.data([null])
.join('text')
.call((text) =>
text
.selectAll('tspan')
.data((value + '').split(/\n/))
.join('tspan')
.attr('x', 0)
.attr('y', (d, i) => `${i * 1.1}em`)
.style('font-weight', (_, i) => (i ? null : 'bold'))
.text((d) => d)
);
// I don't know why eslint won't accept the _ as a legally unused var :shrug:
/* eslint-disable no-unused-vars */
const { _, y, width: w, height: h } = text.node().getBBox();
/* eslint-enable */
text.attr('transform', `translate(${-w / 2},${15 - y})`);
path.attr(
'd',
`M${-w / 2 - 10},5H-5l5,-5l5,5H${w / 2 + 10}v${h + 20}h-${w + 20}z`
);
}
const statMeta = {
pos: {
name: 'Position',
type: 'categorical',
},
age: {
name: 'Age',
type: 'numeric',
},
g: {
name: 'Games',
type: 'numeric',
},
gs: {
name: 'Games Started',
type: 'numeric',
},
mp: {
name: 'Minutes Played',
type: 'numeric',
},
fg: {
name: 'Field Goals Made',
type: 'numeric',
},
fga: {
name: 'Field Goals Attempted',
type: 'numeric',
},
fg_pct: {
name: 'Field Goal %',
type: 'numeric',
},
fg3: {
name: '3pt Field Goals Made',
type: 'numeric',
},
fg3a: {
name: '3pt Field Goals Attempted',
type: 'numeric',
},
fg3_pct: {
name: '3pt Field Goal %',
type: 'numeric',
},
fg2: {
name: '2pt Field Goals Made',
type: 'numeric',
},
fg2a: {
name: '2pt Field Goals Attempted',
type: 'numeric',
},
fg2_pct: {
name: '2pt Field Goal %',
type: 'numeric',
},
efg_pct: {
name: 'Effective Field Goal %',
type: 'numeric',
},
ft: {
name: 'Free Throws Made',
type: 'numeric',
},
fta: {
name: 'Free Throw Attempts',
type: 'numeric',
},
ft_pct: {
name: 'Free Throw %',
type: 'numeric',
},
orb: {
name: 'Offensive Rebounds',
type: 'numeric',
},
drb: {
name: 'Defensive Rebounds',
type: 'numeric',
},
trb: {
name: 'Total Rebounds',
type: 'numeric',
},
ast: {
name: 'Assists',
type: 'numeric',
},
stl: {
name: 'Steals',
type: 'numeric',
},
blk: {
name: 'Blocks',
type: 'numeric',
},
tov: {
name: 'Turnovers',
type: 'numeric',
},
pf: {
name: 'Personal Fouls',
type: 'numeric',
},
pts: {
name: 'Points',
type: 'numeric',
},
name: {
name: 'name',
type: 'categorical',
},
team: {
name: 'Team',
type: 'categorical',
},
per: {
name: 'PER',
type: 'numeric',
},
ts_pct: {
name: 'True Shooting %',
type: 'numeric',
},
fg3a_per_fga_pct: {
name: '3pt Attempted per Field Goal Attempted',
type: 'numeric',
},
fta_per_fga_pct: {
name: 'Free Throw Attempted per Field Goal Attempted',
type: 'numeric',
},
orb_pct: {
name: 'Offensive Rebound %',
type: 'numeric',
},
drb_pct: {
name: 'Defensive Rebound %',
type: 'numeric',
},
trb_pct: {
name: 'Total Rebound %',
type: 'numeric',
},
ast_pct: {
name: '',
type: 'numeric',
},
stl_pct: {
name: '',
type: 'numeric',
},
blk_pct: {
name: '',
type: 'numeric',
},
tov_pct: {
name: '',
type: 'numeric',
},
usg_pct: {
name: 'Usage %',
type: 'numeric',
},
ows: {
name: 'Offensive Win Shares',
type: 'numeric',
},
dws: {
name: 'Defensive Win Shares',
type: 'numeric',
},
ws: {
name: 'Win Shares',
type: 'numeric',
},
ws_per_48: {
name: 'Win Shares per 48 minutes',
type: 'numeric',
},
obpm: {
name: 'Offensive Box Plus-Minus',
type: 'numeric',
},
dbpm: {
name: 'Defensive Box Plus-Minus',
type: 'numeric',
},
bpm: {
name: 'Box Plus-Minus',
type: 'numeric',
},
vorp: {
name: 'VORP',
type: 'numeric',
},
fg_per_mp: {
name: 'Field Goals per 36 minutes',
type: 'numeric',
},
fga_per_mp: {
name: 'Field Goals Attempted per 36 minutes',
type: 'numeric',
},
fg3_per_mp: {
name: '3pt Field Goals per 36 minutes',
type: 'numeric',
},
fg3a_per_mp: {
name: '3pt Field Goals Attempted per 36 minutes',
type: 'numeric',
},
fg2_per_mp: {
name: '2pt Field Goals per 36 minutes',
type: 'numeric',
},
fg2a_per_mp: {
name: '2pt Field Goals Attempted per 36 minutes',
type: 'numeric',
},
ft_per_mp: {
name: 'Free Throws per 36 minutes',
type: 'numeric',
},
fta_per_mp: {
name: 'Free Throws Attempted per 36 minutes',
type: 'numeric',
},
orb_per_mp: {
name: 'Offensive Rebounds per 36 minutes',
type: 'numeric',
},
drb_per_mp: {
name: 'Defensive Rebounds per 36 minutes',
type: 'numeric',
},
trb_per_mp: {
name: 'Rebounds per 36 minutes',
type: 'numeric',
},
ast_per_mp: {
name: 'Assists per 36 minutes',
type: 'numeric',
},
stl_per_mp: {
name: 'Steals per 36 minutes',
type: 'numeric',
},
blk_per_mp: {
name: 'Blocks per 36 minutes',
type: 'numeric',
},
tov_per_mp: {
name: 'Turnovers per 36 minutes',
type: 'numeric',
},
pf_per_mp: {
name: 'Personal Fouls per 36 minutes',
type: 'numeric',
},
pts_per_mp: {
name: 'Points per 36 minutes',
type: 'numeric',
},
fg_per_poss: {
name: 'Fields Goals per 100 possessions',
type: 'numeric',
},
fga_per_poss: {
name: 'Field Goals Attempted per 100 possessions',
type: 'numeric',
},
fg3_per_poss: {
name: '3pt Field Goals per 100 possessions',
type: 'numeric',
},
fg3a_per_poss: {
name: '3pt Field Goal Attempts per 100 possessions',
type: 'numeric',
},
fg2_per_poss: {
name: '2pt Field Goals per 100 possessions',
type: 'numeric',
},
fg2a_per_poss: {
name: '2p Field Goal Attempts per 100 possessions',
type: 'numeric',
},
ft_per_poss: {
name: 'Free Throws per 100 possessions',
type: 'numeric',
},
fta_per_poss: {
name: 'Free Throws Attempted per 100 possessions',
type: 'numeric',
},
orb_per_poss: {
name: 'Offensive Rebounds per 100 possessions',
type: 'numeric',
},
drb_per_poss: {
name: 'Defensive Rebounds per 100 possessions',
type: 'numeric',
},
trb_per_poss: {
name: 'Rebounds per 100 possessions',
type: 'numeric',
},
ast_per_poss: {
name: 'Assists per 100 possessions',
type: 'numeric',
},
stl_per_poss: {
name: 'Steals per 100 possessions',
type: 'numeric',
},
blk_per_poss: {
name: 'Blocks per 100 possessions',
type: 'numeric',
},
tov_per_poss: {
name: 'Turnovers per 100 possessions',
type: 'numeric',
},
pf_per_poss: {
name: 'Personal Fouls per 100 possessions',
type: 'numeric',
},
pts_per_poss: {
name: 'Points per 100 possessions',
type: 'numeric',
},
off_rtg: {
name: 'Offensive Rating',
type: 'numeric',
},
def_rtg: {
name: 'Defensive Rating',
type: 'numeric',
reversed: true,
},
raptor_defense: {
name: 'Raptor Defensive Rating',
type: 'numeric',
},
raptor_offense: {
name: 'Raptor Offensive Rating',
type: 'numeric',
},
war_reg_season: {
name: '538 Wins Above Replacement',
type: 'numeric',
},
mp_per_g: {
name: 'Minutes per Game',
type: 'numeric',
},
fg_per_g: {
name: 'Field Goals per Game',
type: 'numeric',
},
fga_per_g: {
name: 'Field Goal Attempts per Game',
type: 'numeric',
},
fg3_per_g: {
name: '3pt Field Goals per Game',
type: 'numeric',
},
fg3a_per_g: {
name: '3pt Field Goal Attempts per Game',
type: 'numeric',
},
fg2_per_g: {
name: '2pt Field Goals per Game',
type: 'numeric',
},
fg2a_per_g: {
name: '2pt Field Goal Attempts per Game',
type: 'numeric',
},
ft_per_g: {
name: 'Free Throws per Game',
type: 'numeric',
},
fta_per_g: {
name: 'Free Throws Attempted per Game',
type: 'numeric',
},
orb_per_g: {
name: 'Offensive Rebounds per Game',
type: 'numeric',
},
drb_per_g: {
name: 'Defensive Rebounds per Game',
type: 'numeric',
},
trb_per_g: {
name: 'Total Rebounds per Game',
type: 'numeric',
},
ast_per_g: {