d3 y轴的间隙为25个数字
我的D3 JS代码低于
const svg = select(svgRef.current);
const { width, height } = wrapperRef.current.getBoundingClientRect();
const stackGenerator = stack().keys(keys);
const layers = stackGenerator(data);
const extent = [0, 100];
const yScale = scaleLinear().domain(extent).range([height, 0]);
const x0Scale = scaleBand()
.domain(data.map((d) => d.name))
.range([0, width])
.padding(0.46);
const x1Scale = scaleBand()
// .domain(data.map((d) => d.type))
.rangeRound([0, x0Scale.bandwidth()])
.padding(0.12);
const xAix = axisBottom(x0Scale);
const yAix = axisLeft(yScale);
svg.select(".x-axis").attr("transform", `translate(0, ${height})`).call(xAix);
svg
.select(".y-axis")
.attr("transform", `translate(${0 + 25}, 0 )`)
.call(yAix);
D3 -y轴的范围为0到100。我在10分的组中获得Y轴 - (0,10,20,30,40,50,60,70,80,90,100)
我想在其差距中绘制它25 - (0,25,50,75,100)
如何实现?
I have below D3 js code -
const svg = select(svgRef.current);
const { width, height } = wrapperRef.current.getBoundingClientRect();
const stackGenerator = stack().keys(keys);
const layers = stackGenerator(data);
const extent = [0, 100];
const yScale = scaleLinear().domain(extent).range([height, 0]);
const x0Scale = scaleBand()
.domain(data.map((d) => d.name))
.range([0, width])
.padding(0.46);
const x1Scale = scaleBand()
// .domain(data.map((d) => d.type))
.rangeRound([0, x0Scale.bandwidth()])
.padding(0.12);
const xAix = axisBottom(x0Scale);
const yAix = axisLeft(yScale);
svg.select(".x-axis").attr("transform", `translate(0, ${height})`).call(xAix);
svg
.select(".y-axis")
.attr("transform", `translate(${0 + 25}, 0 )`)
.call(yAix);
I have extent 0 to 100 for Y Axis. I am getting Y-Axis in the group of 10 points - (0,10,20,30,40,50,60,70,80,90,100)
I want to plot it in the gap of 25 - (0,25,50,75,100)
How can I achieve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建
y轴
时,您可以传递ticks
要渲染的的数量,将使用
tickvalues
when creating the
y-axis
you can pass the number ofticks
that you want to renderthe other way would be using
tickValues