Positioning of labels

From JSXGraph Wiki
Revision as of 10:39, 3 November 2012 by A WASSERMANN (talk | contribs)

The JavaScript code

var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-2,2,2,-2], axis:true});

var p = [];
for (var i=0; i<4; i++) {
    p.push(brd.create('point', [Math.random()*3.6-1.8, Math.random()*3.6-1.8]));
}

var pol = brd.create('polygon',p,{
    withLines:false,
    withLabel: true,
    name: function () {
        return "lala  " + p[1].Dist(p[2]).toFixed(2) + "m";
    },
    id: p[0].X() + "_" + p[1].Y(),
    label: {offset:[-200,100]}           // Pixel values
});