从javascript函数

时间:2015-12-12 16:52:03

标签: javascript d3.js

if(recipe_Num == 0)

{
    color = "rgb(0,191,255)";
}

else if(recipe_Num == 1){
    color = "rgb(255,255,0)";
}
else{
    color = "rgb(255,110,180)";
};
if(recipe[recipe_Num].step[step_Num].stage == 0){
    y_stage = 25;
}
else if(recipe[recipe_Num].step[step_Num].stage == 1){
    y_stage = 50;
}
else if(recipe[recipe_Num].step[step_Num].stage == 2){
    y_stage = 75;
}
else if(recipe[recipe_Num].step[step_Num].stage == 3){
    y_stage = 100;
}
else if(recipe[recipe_Num].step[step_Num].stage == 4){
    y_stage = 125;
}
else{
    y_stage = 150;
};

  if(x_recipe[recipe_Num]>=x_stage[recipe[recipe_Num].step[step_Num].stage]){
    x_start = x_recipe[recipe_Num];
}
else{
    x_start = x_stage[recipe[recipe_Num].step[step_Num].stage];
}

}

     function updatex()

   {
        x_recipe[recipe_Num] = x_start+pt;
        x_stage[recipe[recipe_Num].step[step_Num].stage] = x_start+pt;
    }

     function dragmove(d) 

    {
       d3.select(this)
      .attr("x", Math.round((d3.event.x-80)/25)*25+80);
    }



   function insert()
  {
    var bodySelection = d3.select(".chart");
    var circleSelection = bodySelection.append("rect")
                                  .attr("x", this.x_start)
                                  .attr("y", this.y_stage)
                                  .attr("width", this.pt)
                                  .attr("height", 25)
                                  .style("fill", this.color)
                                  .call(drag);

return this.x_start;
return this.pt;

代码基本上会删除可移动的甘特图中的svg rect元素。当我在图表中移动svg块时,更新了rect的x和y的坐标。我想读取它们并将它们存储在变量中。欢迎提出如何做的建议。提前致谢

0 个答案:

没有答案