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});
기본적으로 레이블은 고정되어 있습니다. 코드에서 포인트 레이블은 다음과 같이 생성 된 경우 드래그 할 수 있습니다.
qr[1] = board.create('point', [0,0],
{style:5, fillColor:'#ff00ff', label:{ fixed:false }});
qr[2] = board.create('point', [5,0],
{style:5, fillColor:'#ff00ff', label:{ fixed:false }});
qr[3] = board.create('point', [3.85,4.4],
{style:5, fillColor:'#ff00ff', label:{ fixed:false }});
터치 장치에서 더 잘 처리하려면 다음을 설정 ignoreLabels:false
하는 것이 좋습니다 initBoard()
.
board = JXG.JSXGraph.initBoard('jxgbox3',
{
axis: true,
ignoreLabels: false,
boundingbox:[-5.9,8,5.9,-5.9],
keepaspectratio:true,
showCopyright:false,
showNavigation:false
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다