Frage

Ich habe 'Rotation: -90' gegeben, um die Lecks der X-Achse zu drehen. Diese Rotation wird jedoch sogar für den Titel der Achse angewendet. Wie kann ich das aufhören?Bitte hilft mir jemand. Unten ist der Code, den ich verwende .. generasacodicetagpre.

War es hilfreich?

Lösung 2

I got the solution for this issue... here is the code

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)); 
}

it can be called as

mychart.render();
setAxisTitle(mychart,"x","Title for X axis",10);
setAxisTitle(mychart,"y","Title for Y axis",10);

-- SuryaPavan

Andere Tipps

I have just encountered a similar problem as you and stumbled across a slightly easier solution to the one you proposed above.

From http://dojotoolkit.org/reference-guide/dojox/charting.html#axis-title:

titleOrientation determines the title orientation to the axis, facing to the axis by “axis”, or facing away from the axis by “away”.

I found that by adding titleOrientation: "away" to the x axis parameters this will override the existing rotation parameter and thus solves the problem.

FYI: Similar question

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top