Positioning of labels: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) (Created page with "<jsxgraph width="6002 height="600"> var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-2,2,2,-2], axis:true, keepaspectratio:false}); var p = []; for (var i=0; i<4; i++) ...") |
A WASSERMANN (talk | contribs) No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<jsxgraph width=" | <jsxgraph width="600" height="600"> | ||
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-2,2,2,-2], axis:true | var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-2,2,2,-2], axis:true}); | ||
var p = []; | var p = []; | ||
for (var i=0; i<4; i++) { | for (var i=0; i<4; i++) { | ||
p.push(brd.create('point', [Math.random()*3.6-1.8, Math.random()*3.6-1.8]); | p.push(brd.create('point', [Math.random()*3.6-1.8, Math.random()*3.6-1.8])); | ||
} | } | ||
Line 13: | Line 13: | ||
return "lala " + p[1].Dist(p[2]).toFixed(2) + "m"; | return "lala " + p[1].Dist(p[2]).toFixed(2) + "m"; | ||
}, | }, | ||
id: p[0].X() + "_" + p[1].Y() | id: p[0].X() + "_" + p[1].Y(), | ||
label: {offset:[-200,100]} // Pixel values | |||
}); | }); | ||
</jsxgraph> | </jsxgraph> | ||
===The JavaScript code=== | |||
<source lang="javascript"> | |||
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 | |||
}); | |||
</source> | |||
[[Category:Examples]] | |||
[[Category:Text]] |
Latest revision as of 16:29, 10 January 2013
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
});