-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlane_pair_chart.js
79 lines (64 loc) · 1.77 KB
/
lane_pair_chart.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
import cf from './cf';
import AverageChart from './average_chart';
import { Reducer } from 'redugator';
import { valueList } from 'redugator/reducers';
import { averageScoreReducer, quartiles } from './reducers';
export default class LanePairChart extends AverageChart {
constructor() {
super();
this.dimension = cf.dimension(d => d.GameLanePair);
const reducer = Reducer.concatAll(
averageScoreReducer,
valueList(x => +x.Score),
quartiles()
)
this.group = Reducer.reduceGroup(reducer, this.dimension.group());
this.sorter = arr => arr.sort((a, b) => parseInt(a.key, 10) - parseInt(b.key, 10));
this.options = {
type: 'boxplot',
renderTo: document.getElementById('lanePairChart'),
title: 'Lane Pair Averages',
height: 300
};
}
data() {
let _all = this.group.all();
this.sorter(_all);
return _all;
}
postRender() {
let _all = this.data();
this.chart.series[0].remove();
this.chart.addSeries({
name: 'Lane Quartiles',
color: Highcharts.theme.colors[0],
data: _all.map(d => {
return {
category: d.key,
low: d.value.min,
q1: d.value.q1,
median: d.value.median,
q3: d.value.q3,
high: d.value.max,
color: this.getColor(d) || Highcharts.theme.colors[0]
};
}),
colorByPoint: true
});
}
postRedraw() {
let _all = this.data();
this.chart.series[0].setData(_all.map(d => {
return {
category: d.key,
low: d.value.min,
q1: d.value.q1,
median: d.value.median,
q3: d.value.q3,
high: d.value.max,
color: this.getColor(d) || Highcharts.theme.colors[0]
};
}), false);
this.chart.render();
}
}