NVD3 (D3 JS) how to remove y2 axis

泪湿孤枕 提交于 2019-11-29 15:22:50

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.

Much like Lars' answer, this leaves a gap where the axis used to be, but I hid this with CSS.

.y2-axis {display: none}

another way to handle is by setting yAxis to false:

var chart = nv.models.discreteBarChart()
            .x(function (d) { return d.label })
            .y(function (d) { return d.value })
            .staggerLabels(false)
            .showYAxis(false)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!