d3js v4:仅在x轴上显示标签 [英] d3js v4: Only show labels on x-axis
本文介绍了d3js v4:仅在x轴上显示标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建堆积的条形图.我只想在x轴上显示刻度线的标签文本,而没有刻度线和水平x轴线.
I'm creating a stacked bar chart. I would like to show only the tick's label text on the x-axis, but without the ticks and the horizontal x-axis line.
我怎么从这里走?
g.append('g')
.attr('class', 'axis')
.attr('transform', 'translate(0,' + height + ')')
.call(d3.axisBottom(x));
推荐答案
输入以下CSS:
.axis path, .axis line {
fill: none;
stroke: none;
}
这是一个演示:
var svg = d3.select("svg");
var x = d3.scaleLinear().domain([1, 10]).range([10, 390])
svg.append('g')
.attr('class', 'axis')
.attr('transform', 'translate(0,50)')
.call(d3.axisBottom(x));
.axis path, .axis line {
fill: none;
stroke: none;
}
<script src="https://d3js.org/d3.v4.min.js"></script>
<svg width="400" height="80"></svg>
这篇关于d3js v4:仅在x轴上显示标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文