Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/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轴-使其具有0个刻度且没有标记_D3.js - Fatal编程技术网

d3.js轴-使其具有0个刻度且没有标记

d3.js轴-使其具有0个刻度且没有标记,d3.js,D3.js,是否可以创建一个d3.js轴,并且没有记号和编号方案?基本上,我可以使轴不可见吗?我正在使用下面的代码创建轴: svg.selectAll("axis") .data(d3.range(angle.domain()[1])) .enter().append("g") .attr("class", "axis") .attr("transform", function(d) { return "rotate(" + angle(d) * 180 / Ma

是否可以创建一个d3.js轴,并且没有记号和编号方案?基本上,我可以使轴不可见吗?我正在使用下面的代码创建轴:

svg.selectAll("axis")
      .data(d3.range(angle.domain()[1]))
    .enter().append("g")
      .attr("class", "axis")
      .attr("transform", function(d) { return "rotate(" + angle(d) * 180 / Math.PI + ")"; })
    .call(d3.svg.axis()
      .scale(radius.copy().range([0,0]))
      .ticks(1)
      .orient("left"))
    .append("text")
    .style("color", "white") 
      .attr("y", 
        function (d) {
          if (window.innerWidth < 455){
            console.log("innerWidth less than 455: ",window.innerWidth);
            return -(0);
          }
          else{
            console.log("innerWidth greater than 455: ",window.innerWidth);
            return -(0);
          }
        })
      .attr("dy", "0em");
svg.selectAll(“轴”)
.data(d3.range(angle.domain()[1]))
.enter().append(“g”)
.attr(“类”、“轴”)
.attr(“变换”,函数(d){return“旋转”(“+angle(d)*180/Math.PI+”);})
.call(d3.svg.axis()
.scale(半径.copy().range([0,0]))
.滴答声(1)
.东方(左)
.append(“文本”)
.风格(“颜色”、“白色”)
.attr(“y”,
职能(d){
如果(窗内宽度<455){
log(“innerWidth小于455:”,window.innerWidth);
返回-(0);
}
否则{
log(“innerWidth大于455:”,window.innerWidth);
返回-(0);
}
})
.attr(“dy”、“0em”);

如果不希望轴可见,只需不绘制它们(基本上注释掉此代码)

如果您真的只想将其变为白色,可以使用以下类:

.axis line, .axis text, .axis path {
   color: white;
}
这将是操纵它们“打开”和“关闭”的最简单方法。此外,如果您需要了解如何设置
d3
图表的样式,您可以像使用html一样在SVG中导航,并以同样的方式使用CSS进行样式设置

例如,这里是用于轴中记号标记的SVG

<line class="tick" y2="6" x2="0"></line>


您可以看到,我以元素(
)为目标,但您也可以以(
。勾选
)为目标。

我知道有人会这么说。我应该补充一点,我需要动态绘制轴。有时候我想要他们在那里,有时候我不想要。有没有办法只将轴及其各种附件(记号/文本)的颜色设置为白色或透明?Thankscan在定义轴时也会打勾(0),至少使用d3的v3。