Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
D3.js 有没有办法给D3创建的类重新命名?_D3.js - Fatal编程技术网

D3.js 有没有办法给D3创建的类重新命名?

D3.js 有没有办法给D3创建的类重新命名?,d3.js,D3.js,svg路径是使用class=“domain”创建的。我假设下面的代码会处理这个问题: yAxis = d3.svg.axis().scale(y).orient("left").tickFormat(d3.format(".2s")).ticks(20).tickSize(width); svg.append("g") .attr("class", "y axis") .attr("transform", "translate(" + width + ", 0)") .c

svg路径是使用
class=“domain”
创建的。我假设下面的代码会处理这个问题:

yAxis = d3.svg.axis().scale(y).orient("left").tickFormat(d3.format(".2s")).ticks(20).tickSize(width);
svg.append("g")
    .attr("class", "y axis")
    .attr("transform", "translate(" + width + ", 0)")
    .call(yAxis);
现在,当我使用以下样式拖动以隐藏路径时:

.domain {
    visibility: hidden;
}

显然,它隐藏了我显示的所有其他图表中的路径。有没有办法重新命名路径类,或者只隐藏特定的路径?

我想你可能想检查一下这个问题(不是100%确定我理解了这个问题,但是)试试这个:

在CSS中:

.domain.hidden {
  visibility: hidden;
}
在JS中:

svg.append("g")
    .attr("class", "y axis")
    .attr("transform", "translate(" + width + ", 0)")
    .call(yAxis)
    .select('.domain')
    .classed('hidden', true);// should add class "hidden" to the domain