Skip to content

Commit

Permalink
fix date ticks; closes #114
Browse files Browse the repository at this point in the history
  • Loading branch information
radekstepan committed Mar 25, 2016
1 parent 5691e01 commit 8ec6c5a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "burnchart",
"version": "3.0.5",
"version": "3.0.6",
"description": "GitHub Burndown Chart as a Service",
"author": "Radek Stepan <[email protected]> (http://radekstepan.com)",
"license": "AGPL-3.0",
Expand Down
29 changes: 20 additions & 9 deletions public/js/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/js/bundle.min.js

Large diffs are not rendered by default.

25 changes: 17 additions & 8 deletions src/js/modules/chart/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,34 @@ import _ from 'lodash';
export default {

time(height, x, span) {
// Tick time format based on number of days we display.
let specifier = (span < 4) ? '' : (span < 14) ? '%a' : (span < 32) ? '%m/%d' : '%b';
let format = d3.time.format.utc(specifier);

return d3.svg.axis().scale(x)
.orient("bottom")
// Show vertical lines...
.tickSize(-height)
// limit the number of ticks
.ticks(7)
// tick time format...
.tickFormat(format)
// and give us a spacer.
.tickPadding(10);
.tickFormat(d3.time.format((() => {
switch (true) {
case span < 4:
return '';
// Two weeks.
case span < 14:
return '%a';
// 3 months.
case span < 3 * 30:
return '%m/%d';
default:
return '%b';
}
})()));
},

year(height, xAxis, span) {
return xAxis
.orient("top")
.tickSize(height)
.tickFormat(d3.time.format.utc('%Y'))
.tickFormat((d) => d.getFullYear())
.ticks(span / 365);
},

Expand Down

0 comments on commit 8ec6c5a

Please sign in to comment.