小编jam*_*non的帖子

D3 Mouseover/Mouseout冲突

我在d3中遇到了mouseover和mouseout事件的问题.

我已经建立了一个区域图,在每个"数据点"我都附加了一个圆圈.这些圆圈在加载时被隐藏(通过将不透明度设置为0).然后,当您将鼠标悬停在某个区域上时,它会显示与该图层相关的圆圈.

我现在需要做到这一点,当你将鼠标悬停在圆圈上时,它会变得更大.但是,当鼠标悬停在圆圈上时,它会触发该区域的鼠标输出事件(隐藏圆圈).

是否有任何方法可以设置事件,以便mouseout事件不会触发,直到鼠标进入另一层或完全离开svg?

这是我当前的转换代码:

var svg = d3.select('svg');

svg.selectAll('.data-circles')
    .attr('opacity', 0);

svg.selectAll('.layer')
    .attr('opacity', 1)
    .on('mouseover', function (d, i) {
        svg.selectAll('.data-circles')
            .transition()
            .duration(250)
            .attr('opacity', function (d, j) {
                return j == i ? 1 : 0;
            });
    }).on('mouseout', function (d, i) {
        console.log(d, i);
        svg.selectAll('.data-circles')
            .transition()
            .duration(250)
            .attr('opacity', 0);
    });

    var dataCircle = svg.selectAll('.data-circle');

    dataCircle.on('mouseover', function (d, i) {
        d3.select(this)
            .transition()
            .duration(500)
            .attr('r', 8)
            .attr('stroke-width', 4);
    }).on('mouseout', function () {
        d3.select(this)
            .transition()
            .duration(500)
            .attr('r', 4)
            .attr('stroke-width', 2);
    });
Run Code Online (Sandbox Code Playgroud)

这里是Jsfiddle代码的链接

谢谢,

javascript svg d3.js

3
推荐指数
1
解决办法
1404
查看次数

意外的PHP解析错误

我意识到这个问题的答案可能很明显,但我很难过.

我创建了一个使用Jeremy Kendall的密码验证器(https://github.com/jeremykendall/password-validator)的类,名为Hash.然而,当这个类被调用时,我得到:

Parse error: syntax error, unexpected '}' in /home/james/Projects/REC/htdocs/classes/Hash.class.php on line 24.
Run Code Online (Sandbox Code Playgroud)

Hash.class.php中存在问题的代码是:

private $validationCallback;

public function __construct(){
    $this->validationCallback = function($credential, $passwordHash){
        if (has('md5', $credential) === $passwordHash) {
            return true;
        }
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

第24行是最后的'}'.任何帮助将不胜感激.

谢谢.

php

2
推荐指数
1
解决办法
65
查看次数

标签 统计

d3.js ×1

javascript ×1

php ×1

svg ×1