Skip to content

Commit

Permalink
Added basic x-axis ticks for years
Browse files Browse the repository at this point in the history
  • Loading branch information
karmi committed Jan 15, 2011
1 parent f18759d commit 9e49c1c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions js/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ Chart = {
.text(y.tickFormat)
.textStyle( function(d) { return utils.value_to_color(d) } );

/* X-axis and ticks. */
/* X-axis: Years */
vis.add(pv.Rule)
.data(data.rows)
.left(function(d) { return x(this.index); })
.bottom(10)
.bottom(5)
.height(5)
.anchor("bottom").add(pv.Label)
.text( function(d) { return d.key.slice(-1).join('') } )
.anchor("right").add(pv.Label)
.def("previous_year", data.rows[0].key.slice(0, 1)-1)
.text( function(d) { return d.key.slice(0, 1); } )
.visible( function(d) {
var current_year = d.key.slice(0, 1), visible = current_year > this.previous_year();
this.previous_year( current_year );
return visible;
})
.textStyle('#666');

/* The area with top line. */
Expand Down

0 comments on commit 9e49c1c

Please sign in to comment.