Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit d074f76

Browse files
committed
adjust padding
1 parent 7a1e63a commit d074f76

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

app/directives/history-graph/history-graph.directive.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
h = 400,
6161
padding = { top: 20, right: 5, bottom: 30, left: 50 };
6262

63+
var totalH = h + padding.top + padding.bottom;
64+
var totalW = w + padding.left + padding.right;
65+
6366
activate();
6467

6568
function activate() {
@@ -71,11 +74,11 @@
7174
});
7275

7376
var x = d3.time.scale()
74-
.range([0 + padding.left, w + padding.left])
77+
.range([padding.left + 5, w + padding.left - 5])
7578
.domain(d3.extent(history, function(d) { return d.ratingDate; }));
7679

7780
var y = d3.scale.linear()
78-
.range([h + padding.top, padding.top])
81+
.range([h + padding.top - 5, padding.top + 5])
7982
.domain(d3.extent(history, function(d) { return d.newRating; }));
8083

8184

@@ -151,6 +154,36 @@
151154
.attr('class', 'line')
152155
.attr('d', line)
153156

157+
158+
svg.append('g')
159+
.selectAll('line')
160+
.data($scope.colors)
161+
.enter()
162+
.append('line')
163+
.attr('x1', totalW - 3)
164+
.attr('x2', totalW - 3)
165+
.attr('y1', function(d) {
166+
return processRatingStripePoint(y(d.start));
167+
})
168+
.attr('y2', function(d) {
169+
return processRatingStripePoint(y(d.end));
170+
})
171+
.attr('stroke', function(d) {
172+
return d.color;
173+
})
174+
.attr('stroke-width', 3)
175+
176+
function processRatingStripePoint(y) {
177+
console.log('y:' + y)
178+
if (y < padding.top) {
179+
return padding.top;
180+
} else if (y > totalH - padding.bottom) {
181+
return padding.bottom;
182+
} else {
183+
return y;
184+
}
185+
}
186+
154187
svg.selectAll('circle')
155188
.data(history)
156189
.enter()

0 commit comments

Comments
 (0)