function computeRowPosition(plot, cursor, index, count) {
        var width = plot.width();
        var height = plot.height();
        var textAlign = 'left';
        var fontSizeInPx = Number(cursor.fontSize.substring(0, cursor.fontSize.length - 2));

        var y = cursor.y;
        var x = cursor.x;

        if (x > (width / 2)) {
            x -= constants.labelPadding;
            textAlign = 'right';
        } else {
            x += constants.labelPadding;
        }

        if (y > (height / 2)) {
            y -= constants.labelPadding * (count - index) + fontSizeInPx * (count - 1 - index);
        } else {
            y += constants.labelPadding * (index + 1) + fontSizeInPx * (index + 1);
        }

        return {
            x: x,
            y: y,
            textAlign: textAlign
        };
    }
function computeRowPosition(plot, cursor, index, count) {
        var width = plot.width();
        var height = plot.height();
        var textAlign = 'left';
        var fontSizeInPx = Number(cursor.fontSize.substring(0, cursor.fontSize.length - 2));

        var y = cursor.y;
        var x = cursor.x;

        if (x > (width / 2)) {
            x -= constants.labelPadding;
            textAlign = 'right';
        } else {
            x += constants.labelPadding;
        }

        if (y > (height / 2)) {
            y -= constants.labelPadding * (count - index) + fontSizeInPx * (count - 1 - index);
        } else {
            y += constants.labelPadding * (index + 1) + fontSizeInPx * (index + 1);
        }

        return {
            x: x,
            y: y,
            textAlign: textAlign
        };
    }
function computeRowPosition ( plot , cursor , index , count ) { var width = plot . width ( ) ; var height = plot . height ( ) ; var textAlign = 'left' ; var fontSizeInPx = Number ( cursor . fontSize . substring ( 0 , cursor . fontSize . length - 2 ) ) ; var y = cursor . y ; var x = cursor . x ; if ( x > ( width / 2 ) ) { x -= constants . labelPadding ; textAlign = 'right' ; } else { x += constants . labelPadding ; } if ( y > ( height / 2 ) ) { y -= constants . labelPadding * ( count - index ) + fontSizeInPx * ( count - 1 - index ) ; } else { y += constants . labelPadding * ( index + 1 ) + fontSizeInPx * ( index + 1 ) ; } return { x : x , y : y , textAlign : textAlign } ; }
The text displayed next to the cursor can be stacked as rows and their positions can be calculated with this function.
The bottom one has the index = 0, and the top one has the index = count -1. Depending on the current cursor's possition
relative to the center of the plot, index and count, the positions will be computed like this:

|
two | two
one | one
zero | zero
--------+--------
two | two
one | one
zero | zero
|
The text displayed next to the cursor can be stacked as rows and their positions can be calculated with this function . The bottom one has the index = 0 and the top one has the index = count - 1 . Depending on the current cursor s possition relative to the center of the plot index and count the positions will be computed like this :