D3转换循环抛出Uncaught TypeError:t.call不是函数
D3 transition looping throwing Uncaught TypeError: t.call is not a function
对D3来说非常新,对JS来说相对较新。我试图在点击时创建一个圆圈,这个圆圈一旦创建,就需要永远重复跳动。现在,它被正确地创建,并进行了一次转换,但后来由于错误,它有点死了。这是我的代码:
var shapesAtt = shapes
// omitted: assigning fill, position, etc; working as intended
.on("click", circleMouseClick);
function circleMouseClick(d, i)
{
createPulse(this);
}
function createPulse(focusElement)
{
// takes in "focal circle" element
// some things here are hard coded for ease of reading
// (i.e. these variables aren't all useless)
var focus = d3.select(focusElement);
var origR = focus.attr("r");
var origX = focus.attr("cx");
var origY = focus.attr("cy");
var origFill = focus.style("fill");
var strokeColor = "black";
var newG = svgContainer.append("g");
var pulser = newG.append("circle").attr("id", "pulser")
.style("fill", "none").style("stroke", strokeColor)
.attr("cx", 150).attr("cy", 150)
.attr("r", origR)
.transition()
.duration(2000)
.each(pulsate);
}
function pulsate()
{
var pulser = d3.select(this);
pulser = pulser
.transition().duration(2000)
.attr("r", 25)
.attr("stroke-width", 50)
.transition().duration(2000)
.attr("r", 90)
.attr("stroke-width", 10)
.each("end", pulsate);
}
我在Chrome中运行时收到的错误是:
Uncaught TypeError: t.call is not a function d3.v4.min.js:4
我认为我的代码有问题的部分是:
function pulsate()
{
// ...
.each("end", pulsate);
}
这是因为您使用的是d3版本4。v4 API发生了重大变化,因此:
而不是使用
// ...
.each("end", pulsate);//in d3 version 3
进行
// ...
.on("end", pulsate);//in d3 version 4
参考:https://github.com/d3/d3-transition#transition_on
相关文章:
- 如何对jquery中的未命名函数执行.call()
- JavaScript.call()函数“;这个“;值返回3
- 在setInterval函数内部使用.call()传递参数
- swf 文件可以使用 'ExternalInterface.call()' 函数为 javascript 初始化自身
- Iron router on Action 使用 Meteor.call 抛出 writeHead 不是一个函数
- 调用带有挂起的 Parens 与 Function.prototype.call 的函数表达式
- 下划线模板错误:函数(n){return a.call(this,n,h)}
- Javascript call()函数-额外的参数
- 为什么'call()'将属性添加到函数's的例子??(参见小代码)
- call函数无法工作
- 为什么我可以't使用forEach对函数数组使用Function.prototype.call
- .call()函数将函数作为参数而不是结果传递
- 使用js-apply-and-call创建一个webtrend函数来消除重复
- node.js中的回调函数.TypeError: Cannot call method 'emit'的定
- () .prototype.call()函数的实现
- 有人能向我解释函数.protype.call()和函数.protype=对象.create()吗
- Highcharts工具提示格式化器返回函数抛出未捕获的TypeError: j.i call不是函数
- 为什么.call和.apply比JavaScript中直接调用函数要慢?
- 不能使用“应用”'或“;call"函数不止一次
- call()函数与调用继承类的隐式构造函数的区别