JSXGraphでポイントラベルをドラッグ可能にするにはどうすればよいですか?
JSXGraph を使用して三角形を作成できますが、このグラフのドラッグ可能な頂点を作成できません。
これが私のコードです:
<script type="text/javascript">
board = JXG.JSXGraph.initBoard('jxgbox3',
{
axis:true,
boundingbox:[-5.9,8,5.9,-5.9],
keepaspectratio:true,
showCopyright:false,
showNavigation:false
});
var qr = [], arc2,isInDragMode;
qr[1] = board.create('point', [0,0],
{style:5,fillColor:'#ff00ff'});
qr[2] = board.create('point', [5,0],
{style:5,fillColor:'#ff00ff'});
qr[3] = board.create('point', [3.85,4.4],
{style:5,fillColor:'#ff00ff'});
var triArr1 = [qr[3],qr[2],qr[1]];
var tri = board.createElement('polygon',triArr1,
{strokeWidth:2, strokeColor:'#dd00dd',highlight:false});
var arc1 = board.create('nonreflexangle',triArr1,
{radius:1,name:'θ2'});
var triArr2 = [qr[2],qr[1],qr[3]];
var arc2 = board.create('nonreflexangle',triArr2,
{radius:1,name:'θ1'});
var triArr3 = [qr[1],qr[3],qr[2]];
var arc3 = board.create('nonreflexangle',triArr3,
,{fixed:false}, {radius:1,name:'θ3'});
board.create('text', [-5, 3, function ()
{
if(arc2.Value() > Math.PI)
{
ang2 = (360 - arc2.Value() * 180 / Math.PI).toFixed(1);
ang1 = (360 - arc1.Value() * 180 / Math.PI).toFixed(1);
ang3 = (360 - arc3.Value() * 180 / Math.PI).toFixed(1);
}
else
{
ang2 = (arc2.Value() * 180 / Math.PI).toFixed(1);
ang1 = (arc1.Value() * 180 / Math.PI).toFixed(1);
ang3 = (arc3.Value() * 180 / Math.PI).toFixed(1);
}
return '<p>θ_1 = ' + ang2 + '°</p>'+'<p>θ_2 = ' + ang1 + '°</p>'+'<p>θ_3 = ' + ang3 + '°</p>'+'<p>θ_1 + θ_2 + θ_3 = 180°</p>';
}],{fixed:false});