Major and minor ticks with different style, whole page covered D3?

后端 未结 2 2041
没有蜡笔的小新
没有蜡笔的小新 2021-01-26 06:59

I want to draw an axis with major and minor ticks that cover my whole page styled differently. I followed structure of this example, but I can\'t get it to work make different b

2条回答
  •  难免孤独
    2021-01-26 07:27

    The new way to do this is to have several axes, one for the major ticks and another one for the minor ones. You would select the ticks that also appear on the major axis for the minor one and remove them.

    svg.append("g")
    .attr("class", "grid")
    .attr("transform", "translate(0," + height + ")")
    .call(d3.svg.axis().scale(x).ticks(20).tickSize(-height))
    .selectAll(".tick")
    .data(x.ticks(10), function(d) { return d; })
    .exit()
    .classed("minor", true);
    
    svg.append("g")
     .attr("class", "axis")
     .attr("transform", "translate(0," + height + ")")
     .call(d3.svg.axis().scale(x).ticks(10));
    

    More information here.

提交回复
热议问题