任何帮助将不胜感激.
基本上,鼠标悬停工作正常,直到我添加到折线图的过渡.过渡将圆圈的不透明度从零变为一.
var dots = svg.selectAll('circle')
.data(data)
.enter()
.append('svg:circle')
.attr('cx', function(d, i){ return ((width - tickOffset) / (data.length - 1)) * i; })
.attr('cy', function(d){ return y(d.value); })
.attr('r', 4)
.attr('class', 'circle')
.style('opacity', 0)
.transition()
.duration(circleAnimation)
.delay(function(d,i){ return i * (circleAnimation / 4); })
.style('opacity', 1);
dots.on('mouseover', function(d, i){
// show tooltip
})
.on('mouseout', function(d, i){
// hide tooltip
});
Run Code Online (Sandbox Code Playgroud)
当我实现转换时,控制台会引发以下错误
TypeError: 'undefined' is not a function (evaluating 'dots.on')
Run Code Online (Sandbox Code Playgroud)
同样的问题发生在我刚刚创建的条形图上,只是停止方法链接并再次启动它修复了问题.这就是为什么在这个例子中我已经停止了方法链接并用"dots.on('mouseover ......")重新启动它.
我有一个像这样的函数:
check_auth(){
fetch(Urls.check_auth(), {
credentials: 'include',
method: 'GET'
}).then(response => {
if(response.ok) return response.json();
}).then(json => {
return json.user_logged_in;
});
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试这样做:
if(this.check_auth()){
// do stuff
} else {
// do other stuff
}
Run Code Online (Sandbox Code Playgroud)
但是,this.check_auth()始终是undefined。
我在这里缺少什么?我认为在 fetch 中then()是解析的Promise 对象所在的位置,因此我认为true当用户登录时我会得到。但事实并非如此。
任何帮助将不胜感激。