Skip to content

Commit

Permalink
Add label to yAxis
Browse files Browse the repository at this point in the history
Credits to wangshijun2010, pull request shutterstock#404
  • Loading branch information
Jérémie Foucault authored and Jérémie Foucault committed Mar 26, 2014
1 parent ef5e02b commit a09fc84
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/js/Rickshaw.Graph.Axis.Y.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Rickshaw.namespace('Rickshaw.Graph.Axis.Y');
Rickshaw.Graph.Axis.Y = Rickshaw.Class.create( {

initialize: function(args) {


this.args = args;
this.graph = args.graph;
this.orientation = args.orientation || 'right';

Expand Down Expand Up @@ -101,6 +102,21 @@ Rickshaw.Graph.Axis.Y = Rickshaw.Class.create( {
.attr("transform", transform)
.call(axis.ticks(this.ticks).tickSubdivide(0).tickSize(this.tickSize));

// add label
if (this.args.label && this.args.label.text) {
var label = this.args.label;
this.vis.append("text")
.attr("class", "axis-label")
.attr("text-anchor", "end")
.attr("y", label.offsetX || "1em")
.attr("x", label.offsetY || "1em")
.style("color", label.color || "black")
.style("opacity", label.opacity || "0.5")
.style("font-size", label.fontSize || "10px")
.attr("transform", "rotate(-90)")
.text(label.text);
}

return axis;
},

Expand Down

0 comments on commit a09fc84

Please sign in to comment.