Login Register

How to add name for axes? I'm not able to

Hello, this must be very trivial question, but i cdnot solve it.

I'm using Dojox.chart2D for plotting bar graph. But, i am not able to name the axeslike minutes for X-axis and date for Y-axis.

Just name beside the axis, dats all. How do i do??

A quick hack to put in axes

I wrote the following function:

var makeAxisTitle=function(chart,axis){
    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 = "Vertical Baby!";
        y=dim.height/2  - offsets.b/2;
        x=0+12;
    }else{
        label = "Horizontal, Oh Yeah!"
        x=dim.width/2 + offsets.l/2;
        y=dim.height;
    }
    var m = dojox.gfx.matrix;
    var elem = axis.group.createText({x:x, y:y, text:label, align: "middle"});
    elem.setFont({family:taFont.family, size: "12pt", weight: "bold"});
    elem.setFill('black');
    elem.setTransform(m.rotategAt(rotate, x,y));
};

Then, after rendering the chart, I call it:

var xA = mychart.axes["x"];
    var yA = mychart.axes["y"];
    mychart.render();
    makeAxisTitle(mychart,xA);
    makeAxisTitle(mychart,yA);

This feature (axis titles) used to be in the old 0.4.3 version of charting, but I always had to rotate the vertical axis label the correct way, so that's how I knew how to do the above---dig into the code, figure out how stuff is drawn, cut out the features like html rendering that give me a headache, and make it work for a special case. Then go back and improve things later.

Anyway, your mileage may vary.
James