nvd3 line chart, how to remove gridlines and yaxis
Asked Answered
I

4

9

I have made a line chart with view finder.

Here is my initial code

     var chart = nv.models.lineWithFocusChart();

 // chart.transitionDuration(500);
  chart.xAxis
      .tickFormat(d3.format(',g'));
  chart.xAxis
        .axisLabel("Date");
  chart.xAxis.tickPadding(0);


  chart.x2Axis
      .tickFormat(d3.format(',g'));




  chart.yAxis
      .tickFormat(d3.format(',.2g'));
  chart.y2Axis
      .tickFormat(d3.format(',.2h'));
 // chart.showYAxis(false);

I want to remove the y axis labels ( i.e. i want no number showing on the y axis).

I also want to remove all the gridlines.

is there something like chart.yAxis.somethinghere to do this?

Thanks

Impenetrable answered 26/2, 2014 at 22:54 Comment(0)
E
14

To remove tick on y-axis

.nv-axis.nv-y .tick line {
        display:none;
    }

To remove tick on x axis

.nv-axis.nv-x .tick line {
        display:none;
    }

To remove label on x axis

.showXAxis(false)

To remove label on y axis

.showYAxis(false)

To remove all the grid lines

.nv-axis .tick line {
        display:none;
    }
Equatorial answered 13/1, 2016 at 9:48 Comment(1)
@Impenetrable I think you should mark it as an correct answer.Equatorial
S
9

.showYAxis(false) should remove the y axis.

If that doesn't work, you can apply .nv-y text{display: none;} as a style.

Use the style .tick line {display: none;} to get rid of grid lines, and keep x axis.

Get rid of all axis and lines with .tick{display: none;}

:)

Swafford answered 14/3, 2014 at 12:27 Comment(1)
If you want to retain the y-axis label, but not display the values: .nv-axisMaxMin { display: none; }Lorikeet
P
3

To remove the gridlines:

    .nv-axis .tick line {
        display:none;
    }

And axes can be done more straightforwardly:

.showYAxis(false)
.showXAxis(false)
Padishah answered 15/10, 2014 at 11:24 Comment(0)
L
2

To hide grid line, just add this to your css

.tick line {
display: none;
}

and for the X Axis just add .showYAxis(false)

if you want to delete only the yAxis line and keep the ticks you can do it with the CSS:

.nvd3 .nv-axis.nv-y path.domain{
 stroke-opacity: 0;
}

see this plunker for example.

Lexicology answered 1/7, 2016 at 11:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.