Opened 12 years ago
Closed 9 years ago
#7746 closed enhancement (fixed)
Proposal to add axis title
Reported by: | enzo | Owned by: | Eugene Lazutkin |
---|---|---|---|
Priority: | high | Milestone: | 1.6 |
Component: | Charting | Version: | 1.2beta |
Keywords: | Cc: | Tom Trenka, cjolif | |
Blocked By: | Blocking: |
Description
Titles for axes used to be available, but they became collateral damage in the transition to the new charting engine. As I needed them, I slightly modified the code contributed by jmarca at http://www.dojotoolkit.org/forum/dojo-foundation/general-discussion/how-add-name-axes-im-not-able , and found the result quite convenient and useful. What about including this code in the dojox.charting package? The function to add is:
var setAxisTitle=function(chart, axisname, title, fontsizept) { var axis = chart.axes[axisname]; var dim = chart.dim; var offsets=chart.offsets; var ta = chart.theme.axis; var taFont = "font" in axis.opt ? axis.opt.font : ta.font; var x; var y; var label; var rotate=0; if(axis.vertical) { rotate=270 label = title; y=dim.height/2 - offsets.b/2; x=0+2*fontsizept; } else { label = title; x=dim.width/2 + offsets.l/2; y=dim.height-fontsizept/2; } var m = dojox.gfx.matrix; var elem = axis.group.createText({x:x, y:y, text:label, align: "middle"}); elem.setFont({family:taFont.family, size: fontsizept+"pt", weight: "bold"}); elem.setFill('grey'); elem.setTransform(m.rotategAt(rotate, x,y)); }
...and it can be called AFTER the rendering with code like:
mychart.render(); setAxisTitle(mychart,"x","Title for X axis",10); setAxisTitle(mychart,"y","Title for Y axis",10);
Change History (4)
comment:1 Changed 12 years ago by
Milestone: | tbd → future |
---|
comment:2 Changed 12 years ago by
This approach works, but is only a partial solution.
1) The current size computations of the chart for the axes do not account for this title, so the title as drawn in this code can overlap the tick labels.
2) dojox.gfx (VML) does not support rotated text for the vertical axis in Internet Explorer. dojox.gfx for IE would need to use some non-VML code with some HTML tricks to get the vertical text.
comment:3 Changed 9 years ago by
Cc: | cjolif added |
---|
If I'm not mistaken axis do have title now, shouldn't this be closed?
comment:4 Changed 9 years ago by
Milestone: | future → 1.6 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Moving open tickets to the future.