在 td 之上执行一些计算后,我试图画一个圆圈。当我运行以下代码时,它可以工作:
$('#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');
}
看看这有什么问题吗?谢谢。