-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrender.js
79 lines (57 loc) · 2.15 KB
/
render.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
function sampleAndRender() {
var tsers = sample()
render(setupBandline(tsers), tsers)
}
function render(curriedBandLine, tsers) {
var margin = {top: 5, right: 40, bottom: 20, left: 120}
var width = 370 - margin.left - margin.right
var height = 370 - margin.top - margin.bottom
var rowPitch = 40
var rowBandRange = rowPitch / 1.3
// Column widths
var nameColumnWidth = 160
var bandLineWidth = 100
var sparkStripWidth = 50
var columnSeparation = 10
// The bandline gets augmented with the View specific settings (screen widths etc.)
var bandLine = curriedBandLine // fixme implement bandline .copy
// Augment partially set up elements
bandLine.xScaleOfBandLine().range([0, bandLineWidth])
bandLine.xScaleOfSparkStrip().range([0, sparkStripWidth])
bandLine.rScaleOfBandLine().range([2, 0, 2])
// Add new elements
bandLine
.rScaleOfSparkStrip(constant(2))
.yRange([rowBandRange / 2 , -rowBandRange / 2])
/**
* Root
*/
var svg = d3.selectAll('svg')
svg
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
var dashboard = bind(svg, 'dashboard', 'g', [{key: 0}])
/**
* Headers
*/
bind(dashboard, 'header', 'text', [{key: 'Name'}, {key: 'Time Series'}, {key: 'Spread'}])
.entered
.text(key)
.attr('transform', translate(function(d, i) {
return [0, nameColumnWidth, nameColumnWidth + bandLineWidth + 3 * columnSeparation][i]
}, rowPitch))
/**
* Rows
*/
var row = bind(dashboard, 'row', 'g', tsers)
row.attr('transform', function rowTransform(d, i) {return translateY((i + 2) * rowPitch)()})
bind(row, 'nameCellText', 'text')
.text(key)
.attr('y', '0.5em')
bind(row, 'assignmentScoresCell')
.attr('transform', translateX(nameColumnWidth + columnSeparation))
.call(bandLine.renderBandLine)
bind(row, 'assignmentScoresVerticalCell')
.attr('transform', translateX(nameColumnWidth + bandLineWidth + 2 * columnSeparation))
.call(bandLine.renderSparkStrip)
}