يؤثر عنوان المحور عند استخدام "الدوران" - Dojo-Charts
-
14-11-2019 - |
سؤال
قد أعطيت "دوران: -90" لجعل Lables of X-Axis لتدويرها. ولكن هذا الدوران يتم تطبيقه على عنوان المحور أيضا. كيف يمكنني التوقف عن ذلك؟يرجى أي واحد مساعدتي. أدناه هو الرمز الذي أستخدمه .. giveacodicetagpre.
المحلول 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
نصائح أخرى
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