Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am making a bar graph in nvd3.js, similar to this example: http://nvd3.org/ghpages/discreteBar.html. I was wondering if there was a way to remove the gridline so the background would be plain white. All of the examples use gridlines. I also checked the source code and didn't see anything in the discreteBar model that would make this possible.

like image 547
amauboussin Avatar asked Jan 22 '13 22:01

amauboussin


2 Answers

.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;
}
like image 196
Tegan Mulholland Avatar answered Oct 05 '22 20:10

Tegan Mulholland


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.

like image 45
nautat Avatar answered Oct 05 '22 22:10

nautat