How do you remove the background gridlines in nvd3.js?

老子叫甜甜 提交于 2019-12-03 10:19:42

You can select those grid lines in your CSS and set their opacity 0:

.tick {
  opacity: 0;
}

If you still want to see the baseline, you could modify this to:

.tick:not(.zero) {
  opacity: 0;
}

Use your browser's inspector tools to see what class the individual elements have that you want to modify and use the power of CSS.

.tick {
  opacity: 0;
}

Doesn't work for the vertical lines in the discreteBar chart because they use inline css to set the opacity to 1. But this works:

.tick {
  display: none;
}

This will also hide the labels on axes. If you want to remove the lines but keep the labels, use:

.tick line {
  display: none;
}

I found a more specific solution that worked well:

(This removes all grids, but you can be selective, ie: .y1.axis)

.nvd3.multiChart .axis .nv-axis line {
stroke: none;
fill: none;
}

To get rid of the guidelines and keep the labels use

.tick line {
  opacity: 0;
}

just need to update the css with

.tick line {
display: none;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!