9

我用取景器做了一个折线图。

这是我的初始代码

     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);

我想删除 y 轴标签(即我不想在 y 轴上显示数字)。

我还想删除所有网格线。

有没有类似 chart.yAxis.somethinghere 的东西来做到这一点?

谢谢

4

4 回答 4

14

删除 y 轴上的刻度

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

删除 x 轴上的刻度

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

移除 x 轴上的标签

.showXAxis(false)

删除 y 轴上的标签

.showYAxis(false)

删除所有网格线

.nv-axis .tick line {
        display:none;
    }
于 2016-01-13T09:48:43.970 回答
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;}

:)

于 2014-03-14T12:27:44.410 回答
3

要删除网格线:

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

轴可以更直接地完成:

.showYAxis(false)
.showXAxis(false)
于 2014-10-15T11:24:31.707 回答
2

要隐藏网格线,只需将其添加到您的 CSS

.tick line {
display: none;
}

对于 X 轴,只需添加.showYAxis(false)

如果您只想删除 yAxis 线并保留刻度,您可以使用 CSS 执行此操作:

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

例如,看到这个plunker

于 2016-07-01T11:04:26.103 回答