Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

javascript - NVD3 (D3 JS) how to remove y2 axis

I'm trying to use the following example which is a line and bar chart combined.

NVD3 Line & Bar Chart combination

The problem I have is that I want the line chart and bar chart to both use the same figures from y1 axis, but I can't find out how to get rid of the y2 axis and do this.

If someone could point me in the right direction it'd be a great help.

Thanks in advance.

Edit:

A JSFiddle of the problem I'm experiencing. I'm just using the example from NVD3's download and have added in Lars' code just before the return chart; line.

JSFiddle

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There's no option to disable the second y axis. What you can do is set it up to have the same scale as the y1 axis and then remove it after creating the graph, i.e.

d3.select('.nv-y2.nv-axis').remove();

This will leave some empty space where the axis used to be, but at least it'll create the impression that there's only one y axis.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...