如何禁用d3日志缩放的次要滴答声? [英] How to disable the minor ticks in d3 log scale?
本文介绍了如何禁用d3日志缩放的次要滴答声?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的实时d3日志缩放图,如下所示:
I have my real time d3 log scale graph like below:
我想只显示主要刻度及其标签:10 ^ -2,10 ^ -1, 10 ^ 0,10 ^ 1,10 ^ 2
I would like to show only the major ticks with their labels : 10^-2, 10^-1, 10^0, 10^1, 10^2
但不是次要付款
我想让日志Y轴看起来像这样没有小的刻度:
I would like to have the log Y axis look like this without the minor ticks:
如何做到这一点?
EDIT:发布一些代码
svg = d3.select("#chart1").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom);
y = d3.scale.log().domain([1e-1, 1e2]).range([height, 0]);
yAxis = d3.svg.axis().scale(y).orient("left");
svg.selectAll("g.y.axis")
.call(yAxis)
.selectAll(".tick text")
.text(null)
.filter(powerOfTen)
.text(10)
.append("tspan")
.attr("dy", "-.7em")
.text(function(d) { return Math.round(Math.log(d) / Math.LN10); });
您可能也想知道如何获得powerOfTen的自定义标签。如果是,您可能需要参阅此处
You might also interested to know how to get the custom label of powerOfTen. If so, you might need to refer here
编辑:您可以编辑我的 jsfiddle
推荐答案
由Lars Kotthoff建议
suggested by Lars Kotthoff
var yAxis = d3.svg.axis().scale(y).tickSize(0).tickValues([1e-1,1e0,1e1,1e2]).orient("left");
此回答强制标签
主刻度
未绘制.....
this answer force the label
, but the major tick
is not drawn.....
这篇关于如何禁用d3日志缩放的次要滴答声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文