몇 가지 계산을 td 위로 수행 한 후 원을 그리려합니다.Raphael을 사용하여 원을 그리는 중입니다. 동적 일 때 작동하지 않습니다. 동적 일 때 작동하지 않습니다.
$('#priority_one').width($('#learning_streams').width());
$('#priority_one').height($('#learning_streams').height());
var priority_one_paper = new Raphael('priority_one', $('#priority_one').width(), $('#priority_one').height());
var priority_one_circle = priority_one_paper.circle((pos.left).toFixed(0), (pos.top).toFixed(0), (width/2).toFixed(0));
priority_one_circle.attr('stroke','#000000');
을하지만 그것은 동적으로 만들려고 할 때 더 이상 작동합니다 (TD 변경은 사용자가 입력에 따라 없음) : 나는 다음과 같은 코드를 실행하면 작동합니다. 코드 :
function circlePriorityOne() {
//priority_one is a div absolutely positioned over a table called learning_streams
//sets size of priority_one based off the table learning_streams
$('#priority_one').width($('#learning_streams').width());
$('#priority_one').height($('#learning_streams').height());
//creates the 'paper' to draw the circle on
var priority_one_paper = new Raphael('priority_one', $('#priority_one').width(), $('#priority_one').height());
var main = getMax(priority_one_count); //returns the id of the td to circle
var pos = $('#'+main).position();
var width = $('#'+main).width();
//using toFixed() to get rid of decimals
var priority_one_circle = priority_one_paper.circle((pos.left).toFixed(0), (pos.top).toFixed(0), (width/2).toFixed(0));
priority_one_circle.attr('stroke','#000000');
}
이 항목을 참조하십시오. 감사.
"작동하지 않음"... 식사를 조리하지 않습니까? 차는 운전합니까? "안녕하세요"라고하지 않습니까? : D 뭐하는거야? 콘솔에 오류가 있습니까? 변수 (main, pos, width, ...)를 확인 했습니까? – Andreas
오류가 없습니다. 그것은 원을 그려야합니다. 그렇지 않습니다. 나는 td의 위치가 테이블이 아닌 문서에 상대적으로 캡처되고 있다고 생각한다. 그것은 원의 위치에서 벗어날 것입니다. 나는 테이블 주위에 포장 된 div 태그에 상대적인 위치를 잡기 위해 그것을 변경하고있다. 그게 뭐가 달라지는 지 알게 될거야. – ahhchuu
나머지 질문에 답하지 못했습니다. main, pos 및 width는 모두 예상 값을 나타냅니다. – ahhchuu